Skip to main content

A gRPC-based Saga Orchestration System for distributed transactions

Project description

🧩 grpc-orchestrator

grpc-orchestrator is a lightweight, gRPC-based Saga orchestration system for coordinating distributed transactions across microservices. It helps ensure data consistency by executing a series of steps with compensating rollbacks in case of failures.


🚀 Key Features

  • Saga Pattern Implementation: Coordinates multi-step transactions with compensation support for failures.
  • gRPC-Native Architecture: Fast and type-safe communication using Protocol Buffers and gRPC.
  • Flexible Step Definition: Each step supports service, method, timeout, and optional compensation logic.
  • Asynchronous Orchestration: Steps execute in order, compensation runs in reverse on failure.
  • In-Memory Storage: Ideal for prototyping and testing. Easily swappable for custom persistent backends.
  • Execution Logging: Tracks timestamps, success/failure, payloads, and error messages per step.

📦 Components

1. Protobuf APIs

Defines the orchestrator and participant interfaces:

service SagaOrchestratorService {
  rpc StartSagaTransaction (StartSagaRequest) returns (StartSagaResponse);
  rpc GetSagaStatusTransaction (GetSagaStatusRequest) returns (GetSagaStatusResponse);
}

service SagaParticipant {
  rpc Execute (SagaParticipantRequest) returns (SagaParticipantResponse);
  rpc Compensate (SagaParticipantRequest) returns (SagaParticipantResponse);
}

###pip install grpc_orchestrator

```python

from grpc_orchestrator.core.client.client import GrpcOrchestratorClient

client = GrpcOrchestratorClient(orchestrator_host="localhost")
steps = [
    {
        "port": 50052,
        "rpc_method": "CleateOrder",
        "compensation_method": "RollbackOrder",
        "timeout_seconds": 5,
    },
    {
        "port": 50052,
        "rpc_method": "CheckoutOrder",
        "compensation_method": "CheckoutOrder",
        "timeout_seconds": 5,
    },
]
client.start_transaction(transaction_id="1234",steps=steps,payload={
    "id": "1",
    "name":"item1"
})

status = client.get_transaction_status(transaction_id="order_123")
print(status)

![Saga Flow Diagram](grpc_orchestrator/images/flow.png)

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

grpc_orchestrator-0.0.6.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

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

grpc_orchestrator-0.0.6-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file grpc_orchestrator-0.0.6.tar.gz.

File metadata

  • Download URL: grpc_orchestrator-0.0.6.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for grpc_orchestrator-0.0.6.tar.gz
Algorithm Hash digest
SHA256 6131ee52a493a972d90f258604d21885f7746d68bb485f6ba611885ffe0b5160
MD5 fdab32bd604b33dbd32c8932d0d0b651
BLAKE2b-256 18cbb4747ceaff971135a47c3fc77f9ad6b129857e40564c4a710e479dd3d3b9

See more details on using hashes here.

File details

Details for the file grpc_orchestrator-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for grpc_orchestrator-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3cb97a20494290fa9e4d4951696b1b4a440aab542c6bde0add2fcb46e915b327
MD5 45dea47ee4a754ed3a1383bc6e66dfcc
BLAKE2b-256 7d7245b1f1dac72f375031ef194d4eb2e45e96753ee05702494c8b1adfab9d23

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