Skip to main content

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.

Release files for pytram-saga 0.2.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytram-saga 0.2.11
File Size Uploaded
pytram_saga-0.2.11.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytram-saga 0.2.11
File Interpreter ABI Platform
pytram_saga-0.2.11-py3-none-any.whl Python 3 none any Details

Total release size: 19.7 kB

Release files / pytram_saga-0.2.11.tar.gz

Download URL pytram_saga-0.2.11.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5d163eed8011b47dafe107c6ea8faf52c451610a1f10df987e4e7224c27ccf31
BLAKE2b-256 checksum
How to use checksums
b2e646e076721b3961e9f700a99c6ee5ba2e8795f8cc5fc8b1281b8826f18120
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / pytram_saga-0.2.11-py3-none-any.whl

Download URL pytram_saga-0.2.11-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
481433991a77c0096f741c824cc3a953942107bb0fd84c8feb72bed5df317116
BLAKE2b-256 checksum
How to use checksums
6b228fe280057106dde3982a80f0fcef37b6236e04d1a7f59f7d9f90812e55e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.2.11 This release

2 release files

0.2.9

2 release 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