Code Monkey home page Code Monkey logo

fsmstatemanagement's Introduction

FsmStateManagement

Finite state machine implementation with state management in microservices.

Redis

Docker compose yaml is uploaded for local redis implementation. docker-compose up command in the FsmStateManagement folder starts the redis.

  • Finite State Machine is implemented on server with core package. Also there are endpoint listed below that helps to trace transactions.
  • There are postman collections to test e2e.
  • Example body is below for POST operation and creates a new finite state machine.
    {
        "stateName": "s1",
        "httpMethod": "GET",
        "revertEndpoint": "/api/v1/revert",
        "data": {
            "name": "customName",
            "id": "1"
        },
        "events": [
            {
                "eventName": "event1",
                "nextStateName": "s2"
            },
            {
            	"eventName": "event3",
            	"nextStateName": "s3"
            }
        ]
    },
    {
        "stateName": "s2",
        "httpMethod": "GET",
        "revertEndpoint": "/api/v1/revert",
        "data": {
            "name": "customName",
            "id": "2"
        },
        "events": [
        	{
                "eventName": "event2",
                "nextStateName": "s1"
            }	
        ]
    },
    {
        "stateName": "s3",
        "httpMethod": "GET",
        "revertEndpoint": "/api/v1/revert",
        "data": {
            "name": "customName",
            "id": "3"
        },
        "events" : [
            {
            	"eventName": "event4",
            	"nextStateName": "s1"
            }
        ]
    }
]
  • State has fields with revertEndpoint,httpMethod,data to be called by FSM if a state fails.
  • Also there are stateName, and events. Fsm implementation enables recursive states by design.
  • For Example: state1 -> event1 -> state2 -> event2 -> state1.

Endpoints

You can see in the postman scripts as well.

Features

  • Fsm's states are stored in memory and redis according to transaction identifier.
  • Fsm's states can be idle and 5 minutes idle means to remove FSM from in memory.
  • Automatically idle FSM can be restored.
  • Revert logic : microservice is notified by rest request according to given state's data,httpMethod,revertEndpoint.
  • Each rest request to microservices are stored in database and retries 3 times for fail cases. There is no loss in rest request data.
  • If you switch auto.ddl create-drop to update, each transaction is persisted and retry logic also persisted as well. For further modification you can use any other database.

For Other Implementations

  • Rabbitmq implementation will be added.
  • Extra api will be added for FSM
  • Conductor Netflix(Workflow Management)

SEE ALSO

https://github.com/grkn/FsmStateManagementClient

fsmstatemanagement's People

Contributors

grkn avatar memojja 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.