Giter Club home page Giter Club logo

conductor-examples-python-cab-saga's Introduction

conductor-examples-python-cab-saga

Cab Booking Distributed Python Service

Installation

Install Docker

https://docs.docker.com/engine/install/

Install Python

https://www.python.org/downloads/

Install Modules

pip3 install -r requirements.txt

Setup

Setup authentication using the below link and store environment variables in a .env file.

https://github.com/conductor-sdk/conductor-python?tab=readme-ov-file#setup-sdk

App Structure

This app has 6 components:

  1. Flask server that servers the booking endpoint to trigger booking workflow
  2. Booking Service
  3. Assignment Service
  4. Payment Service
  5. Notification Service
  6. Workflow definition creation script

Create Workflow

python3 workflows.py

Run Cab Booking Server

python3 main.py

Run workers

Microservice based workers

docker compose up

Monolithic workers

python3 workers.py

Trigger Booking Creation

Booking Creation Success: Happy Path

curl --location 'http://127.0.0.1:5000/booking' \
--header 'Content-Type: application/json' \
--data '{
    "pickUpLocation": "15 Mark Chester Pl, Chicago, IL 12045",
    "dropOffLocation": "64 West 21st Street, Chicago, IL 13012",
    "riderId": 1
}'

Booking Creation Failure: Distributed Rollback

To simulate a distributed rollback in a Saga based microservice architecture, we make the payment fail for all riders with id > 2 which leads to terminate the main workflow and trigger a failure workflow.

curl --location 'http://127.0.0.1:5000/booking' \
--header 'Content-Type: application/json' \
--data '{
    "pickUpLocation": "15 Mark Chester Pl, Chicago, IL 12045",
    "dropOffLocation": "64 West 21st Street, Chicago, IL 13012",
    "riderId": 3
}'

conductor-examples-python-cab-saga's People

Contributors

coderabhigupta avatar

Watchers

 avatar  avatar

Forkers

borislav-1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.