Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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.

from microagent import (MicroAgent, Queue, Signal, configure,
                        consumer, cron, on, periodic, receiver)
from microagent.tools.redis import RedisBroker, RedisSignalBus

configure('file://signals.json')

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(Signal.user_updated, Signal.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(Queue.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.send(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]'

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.9.0rc1.tar.gz (58.5 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.9.0rc1-py3-none-any.whl (36.1 kB view details)

Uploaded Python 3

File details

Details for the file microagent-1.9.0rc1.tar.gz.

File metadata

  • Download URL: microagent-1.9.0rc1.tar.gz
  • Upload date:
  • Size: 58.5 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.9.0rc1.tar.gz
Algorithm Hash digest
SHA256 a30c965224c99cb5255cdc46f03adbc7aea59ee5c5aec66c9ac064e2f62668c2
MD5 f0e8c4765be01dee9f793383a9c0dd8c
BLAKE2b-256 a683f11e423c78eab20320e004bec2cf13f7890181b27aafef86f2cdc714ffb2

See more details on using hashes here.

File details

Details for the file microagent-1.9.0rc1-py3-none-any.whl.

File metadata

  • Download URL: microagent-1.9.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 36.1 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.9.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 3f91468d900839aaa74efe95eea603356d3e69d82282f99d535078adc7ae0078
MD5 0141ac35cda6aebaae32b80626c115de
BLAKE2b-256 9868f2d2f9bd084a87ad1805fa9cf7df272090525301c7f478ddd88f7ab79ea8

See more details on using hashes here.

Release history Release notifications | RSS feed

1.9.0

2 files

This release

1.9.0rc1 This release

2 files

1.8.3

2 files

1.8.2

2 files

1.8.1

2 files

1.8.0

2 files

1.7.3

2 files

1.7.2

2 files

1.7.1

2 files

1.7.0rc3

2 files

1.7.0rc2

2 files

1.7.0rc1

2 files

1.6.1

2 files

1.6

2 files

1.5.1

2 files

1.4

2 files

1.3

2 files

1.2

2 files

1.1

2 files

1.0

2 files

0.9

2 files

0.8

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page