Skip to main content

A Fast Asynchronous MicroService Environment compatible with asyncio and pyfase

Project description

🛰️ Async MicroService Framework com ZeroMQ

Este projeto é um framework leve e assíncrono para criar microsserviços em Python, utilizando zmq.asyncio como mecanismo de comunicação entre processos ou entre máquinas.

🚀 Recursos

  • 📡 Comunicação assíncrona entre microsserviços com ZeroMQ (PUSH/PULL + PUB/SUB)
  • 🧠 Suporte a ações (@action) e tarefas (@task) com execução assíncrona
  • 📢 Suporte a mensagens broadcast, requisições diretas e respostas
  • 🔌 Sistema de descoberta de serviços simples e leve
  • ⚙️ Customização com hooks para eventos (on_connect, on_new_service, etc.)

📦 Requisitos

  • Python 3.8+
  • pyzmq
  • asyncio
poetry install

Exemplo de Uso

class MyService:
    @MicroService.action
    async def hello(self, origin, data):
        print(f"Recebido de {origin}: {data}")

    @MicroService.task
    async def heartbeat(self):
        while True:
            await asyncio.sleep(5)
            print("Estou vivo")

if __name__ == '__main__':
    service = MicroService(
        service=MyService(),
        sender_endpoint='ipc:///tmp/sender', # tcp://0.0.0.0:3000
        receiver_endpoint='ipc:///tmp/receiver' # tcp://0.0.0.0:4000
    )
    asyncio.run(service.run())

📡 Fluxo de Mensagens

  • Registro: ao iniciar, um serviço envia uma mensagem com suas ações disponíveis.

  • Broadcast: mensagens são enviadas para todos os serviços.

  • Ação direta: mensagens com prefixo action: disparam métodos marcados como @action.

  • Resposta direta: mensagens com prefixo service_name: retornam dados diretamente ao solicitante.

🧩 Arquitetura

┌──────────────┐        PUSH        ┌──────────────┐
│ MicroService │ ─────────────────▶ │   Receiver   │
└──────────────┘                    └──────────────┘
     ▲
     │
 SUB │
     ▼
┌──────────────┐
│   Sender     │
└──────────────┘

🔄 Integração com outros sistemas

  • Pode ser facilmente integrado com sensores IoT, bancos de dados, interfaces HTTP ou MQTT.

  • Ideal para arquiteturas orientadas a eventos com múltiplos serviços independentes.

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

aiofase-0.3.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

aiofase-0.3.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file aiofase-0.3.0.tar.gz.

File metadata

  • Download URL: aiofase-0.3.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.3 Linux/6.14.0-37-generic

File hashes

Hashes for aiofase-0.3.0.tar.gz
Algorithm Hash digest
SHA256 74f8d04fe99e4208cb2851e18c9c9ad93c1b3a41f644b7cb1c8103f10828400f
MD5 f191095091cd7d0163d4e52a39187bd0
BLAKE2b-256 fccfba0605a2571e4456c6b48a643dec11cb4c18fc8ef6e4da59f14e8fb024f2

See more details on using hashes here.

File details

Details for the file aiofase-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: aiofase-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.3 Linux/6.14.0-37-generic

File hashes

Hashes for aiofase-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 015df5b6ffab5cfe6124bbc88c7467167a69b768750ca0dce645769473a4ea97
MD5 b1653fa11a62156d75cf30c377f406c0
BLAKE2b-256 2d5e826846dbc20f387b5893e79e320f2fbc526e4728b57bbf40a6974fd0845a

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