Skip to main content

Python Moleculer Library

Project description

Pylecular

Pylecular is a Python library that implements the Moleculer protocol, enabling microservices communication and orchestration.

Status

🚧 Early Development: Pylecular is in alpha stage and under active development. Currently, it supports basic Moleculer protocol features and only includes NATS transport integration. The API is not stable, and breaking changes are expected. Use with caution in production environments.

Features

  • Basic implementation of the Moleculer protocol.
  • Support for service-to-service communication.
  • Extensible and modular design.

Installation

You can install Pylecular using pip:

pip install pylecular

For development installation, you can clone the repository and install in editable mode:

git clone https://github.com/alvaroinckot/pylecular.git
cd pylecular
pip install -e .

Usage

Here is a basic example of how to use Pylecular:

For more complete examples, check the /examples folder in the repository:

from pylecular.context import Context
from pylecular.service import Service
from pylecular.decorators import action, event
from pylecular.broker import Broker

broker = ServiceBroker("broker-sample")

class MathService(Service):
    name = "math"

    def __init__(self):
        super().__init__(self.name)

    @action()
     def add(self, ctx):
          # Regular action
          result = ctx.params.get("a") + ctx.params.get("b")
          
          # Emit event to local listeners
          ctx.emit("calculation.done", {"operation": "add", "result": result})
          
          # Broadcast event to all nodes
          ctx.broadcast("calculation.completed", {"operation": "add", "result": result})
          
          return result

     @event(name="calculation.done")
     def calculation_done_handler(self, ctx):
          print(f"Calculation done: {ctx.params}")

broker.register(MathService())

await broker.start()

await broker.call("math.add", { "a": 5, "b": 20 })

Roadmap

  • Add support for more Moleculer features.
  • Improve documentation and examples.
  • Enhance performance and stability.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to help improve Pylecular.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylecular-0.1.3.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pylecular-0.1.3-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file pylecular-0.1.3.tar.gz.

File metadata

  • Download URL: pylecular-0.1.3.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pylecular-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3c8ba36eac4a4717a294ef8d60aa9d42d2a298731eb5ab304409f9ea826f2278
MD5 78f922a2dae4d2d8066d020838f0888d
BLAKE2b-256 7e139956ba1abea9cbbbb114df708165b655b68f54e6e873d0fe1d904455a662

See more details on using hashes here.

File details

Details for the file pylecular-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pylecular-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pylecular-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 246d29a0eb2a5c6c7eddd8004938a0875abc565a87f946e1e8c8ea9a456843ae
MD5 91265e6c923c70696f2ef24fec2c77df
BLAKE2b-256 6176fca7c80002fa22551e306fdea4415cb8bbd5deedad2245c8faf6dc7705e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page