Skip to content

sayheymirza/pymoleculer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moleculer Python

PyPI version License: MIT

Python implementation of Moleculer JS framework.

Installation

pip install pymoleculer

Usage

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()

Features

  • Create a broker
  • Create a service with action decorators
  • Call an action from another service

Roadmap

  • Handle events
  • Handle permissions on actions
  • Improve disconnecting

About

Python implementation of Moleculer framework

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published