Code Monkey home page Code Monkey logo

saga's Introduction

Saga pattern in Go

This project is just a POC and inspired by Caitie talks about Saga (video). I suggest you to watch the talk if you haven't heard about saga.

About the project

This project implements Saga for distributed transaction. In this project, I have 3 microservices. They are:

  1. Transaction - for handling transaction, eg: transfer between user
  2. User - for handling user and their balance
  3. Statement - for handling statements of the user

How it works

When a transaction happens, the transaction microservice will publish a StartSaga event to kafka. SEC (Saga Execution Coordinator) will subscribe for StartSaga event and process it. SEC will publish event(s) according to StartSaga specification. Corresponding microservices will subscribe to that particular event and do some logic. SEC will wait for the Ack (success or fail) from the corresponding microservices. If one of them is fail, SEC will do a rollback by publishing the compensate event from each published event. If everything is success, SEC will publish EndSaga event to mark the transaction has been fully processed.

About the structure

example folders contain some microservices. cmd/sec contains entrypoint for SEC.

Dependencies

  • Kafka for event sourcing
  • "github.com/Shopify/sarama" for connecting to kafka

saga's People

Contributors

hendra-huang avatar

Stargazers

Sener Alkan avatar Rokybul Rayhan Chowdhury avatar Giovanni Morlin avatar Alfen Febral avatar Agung Ap avatar tuna avatar  avatar Omar  avatar Giovanni Delgado avatar bagher sohrabi avatar Kurt DaCosta avatar Yiran Sheng avatar H avatar In Sin avatar Mauro Delazeri avatar

Watchers

James Cloos avatar

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.