Skip to main content

Saga orchestration framework inspired by Eventuate Tram

Project description

PyTram

PyTram é um framework Python para orquestração de Sagas assíncronas, inspirado no Eventuate Tram. Ele foi criado para facilitar a coordenação de transações distribuídas em sistemas baseados em microsserviços.


✨ Recursos

  • Orquestração de Sagas com múltiplos passos
  • Suporte a comandos e compensações
  • Adaptador para RabbitMQ (via aio-pika)
  • Repositório de Sagas em memória
  • Suporte a tolerância a falhas via pyfaulttolerance
  • Totalmente assíncrono e extensível

📦 Instalação

Você pode instalar via PyPI:

pip install pytram-saga

🚀 Exemplo de Uso

from pytram.saga.step import SagaStep
from pytram.saga.orchestrator import SagaOrchestrator
from pytram.persistence.memory import InMemorySagaRepository
from pytram.messaging.rabbitmq import RabbitMQAdapter

async def main():
    broker = RabbitMQAdapter("amqp://user:pass@host/vhost")
    await broker.connect()

    steps = [
        SagaStep(command="step1"),
        SagaStep(command="step2", compensation="compensate_step2"),
        SagaStep(command="step3")
    ]

    repo = InMemorySagaRepository()

    orchestrator = SagaOrchestrator("MySaga", steps, broker, repo)

    await orchestrator.start("saga-001", {"user_id": 42, "amount": 100.0})

📚 Estrutura da Arquitetura

+--------------------+
|  SagaOrchestrator  |
+---------+----------+
          |
          v
+--------------------+
| SagaStep Executor  |
+---------+----------+
          |
          v
+--------------------+
|  RabbitMQAdapter   | ---> Fila de Comando (via aio-pika)
+--------------------+

Repositório: InMemorySagaRepository


🙋 Contribuições

Contribuições são bem-vindas! Por favor, abra um issue ou envie um pull request.

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

pytram_saga-0.2.11.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

pytram_saga-0.2.11-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file pytram_saga-0.2.11.tar.gz.

File metadata

  • Download URL: pytram_saga-0.2.11.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pytram_saga-0.2.11.tar.gz
Algorithm Hash digest
SHA256 5d163eed8011b47dafe107c6ea8faf52c451610a1f10df987e4e7224c27ccf31
MD5 750f7fa9bbe11ff2ecb0adaadd690f93
BLAKE2b-256 b2e646e076721b3961e9f700a99c6ee5ba2e8795f8cc5fc8b1281b8826f18120

See more details on using hashes here.

File details

Details for the file pytram_saga-0.2.11-py3-none-any.whl.

File metadata

  • Download URL: pytram_saga-0.2.11-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pytram_saga-0.2.11-py3-none-any.whl
Algorithm Hash digest
SHA256 481433991a77c0096f741c824cc3a953942107bb0fd84c8feb72bed5df317116
MD5 e06b6cc522b8c973b784bb14870ab4ca
BLAKE2b-256 6b228fe280057106dde3982a80f0fcef37b6236e04d1a7f59f7d9f90812e55e7

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