Python implementation of Moleculer JS framework.
pip install pymoleculer
from pymoleculer.broker import MolecularBroker
broker = MolecularBroker(
namespace="test",
node="node-1",
transporter="mqtt://localhost:1883",
serializer="json",
)
@broker.action(
service="hello",
version="api.v1",
rest="GET /",
params={
"name": {
"type": "string",
"optional": True,
"default": "World"
}
}
)
def hello(ctx):
name = ctx.params["name"] if "name" in ctx.params else "World"
data = ctx.call("api.v1.search.search" ,{
"type": "product"
})
return {
"status": True,
"code": 200,
"error": -1,
"message": f"Hello {name}!",
"data": data
}
broker.start()
- Create a broker
- Create a service with action decorators
- Call an action from another service
- Handle events
- Handle permissions on actions
- Improve disconnecting