Skip to main content

Tool for agent ecosystem

Project description

https://img.shields.io/pypi/v/microagent.svg https://img.shields.io/pypi/pyversions/microagent.svg https://img.shields.io/pypi/l/microagent.svg https://img.shields.io/pypi/status/microagent.svg https://img.shields.io/pypi/dm/microagent.svg https://readthedocs.org/projects/microagent/badge/?version=latest&style=flat https://github.com/scailer/microagent/workflows/Tests/badge.svg

The goal of this project is to facilitate the creation of microservices interacting via a signal bus and/or queue broker.

The philosophy of this project is to present a microservice as a software agent that directly interacts only with queues and the event bus, and not with other microservices.

Tool is intended for developing:

  • distributed apps with event-driven architecture

  • distributed apps with data-driven architecture

  • multi-processors apps

Tool provide features:

  • running a periodical tasks (interval or as CRON)

  • specification of signals (events), their sending and receiving via the bus (redis)

  • description of queues, sending and receiving messages via the queue broker (aiormq, kafka, redis)

  • limited RPC via signal bus

  • launching sub-services (in the same process)

  • launching a group of microagents (each in a separate process)

  • mocks for bus and broker

See MicroAgent documentation.

class Agent(MicroAgent):

    @on('pre_start')
    async def setup(self):
        pass  # init connections to DB, REDIS, SMTP and other services

    @periodic(period=5)
    async def refresh_cache(self):
        pass  # do something periodicly

    @cron('0 */4 * * *')
    async def send_report(self):
        pass  # do something by schedule

    # subscribe to signals (events)
    @receiver(signals.user_updated, signals.user_deleted)
    async def send_notification(self, **kwargs):
        # send signal (event) to bus
        await self.bus.check_something.send(sender='agent', **kwargs)

    # message consumer from queue
    @consumer(queues.mailer)
    async def send_emails(self, **kwargs):
        # send message to queue
        await self.broker.statistic_collector.send(kwargs)


async def main():
    bus = RedisSignalBus('redis://localhost/7')
    broker = RedisBroker('redis://localhost/7')

    # usage bus and broker separate from agent
    await bus.started.send('user_agent')
    await broker.mailer(data)

    agent = Agent(bus=bus, broker=broker)
    await agent.start()

Installing

With redis backend provide signal bus and list-based queues:

pip install 'microagent[redis]'

With aiormq backend provide queues over AMQP (RabbitMQ):

pip install 'microagent[amqp]'

With kafka backend provide queues over Kafka (experemental):

pip install 'microagent[kafka]'

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

microagent-1.8.2.tar.gz (56.6 kB view details)

Uploaded Source

Built Distribution

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

microagent-1.8.2-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file microagent-1.8.2.tar.gz.

File metadata

  • Download URL: microagent-1.8.2.tar.gz
  • Upload date:
  • Size: 56.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for microagent-1.8.2.tar.gz
Algorithm Hash digest
SHA256 4b0c850d02708f1c30e3472d3c3ce5ff2754abb7041d9855ce9eeb2c6deacd2a
MD5 2a4a58b95918ccdf1d0e49b3d0abd513
BLAKE2b-256 ce7fb28646d84b46af6c7d32e083f8a7687393496c72536fbc380d6f8403e45f

See more details on using hashes here.

File details

Details for the file microagent-1.8.2-py3-none-any.whl.

File metadata

  • Download URL: microagent-1.8.2-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for microagent-1.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 725a3ae676a384e397e7966c207741de1af8c083cd4b048725c6d439b7336b9e
MD5 1e06f9aef332c12189e1eb8a7acaca02
BLAKE2b-256 5dcb0e2c32fa3589f4ef4f6b1760adff05b320479641577a8326377d0a9b8875

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