GithubHelp home page GithubHelp logo

rolandtritsch / elixir-fsm Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 657 KB

Implementing a simple finite state machine

CSS 23.52% JavaScript 20.00% Elixir 51.60% HTML 2.70% Shell 1.48% SCSS 0.70%

elixir-fsm's Introduction

Implementing a simple finite state machine

This repo implements a simple finite state machine.

The state machine models a simple job worker system.

STD

How to build this?

  • create database directory with mkdir data and update docker-compose.yml accordingly
  • start the database with docker-compose up -d
  • install dependencies with mix deps.get
  • create and migrate your database with mix ecto.setup
    • reset it with mix ecto.reset
    • prefix mix with MIX_ENV=test to create/reset the test database
  • install Node.js dependencies with npm install inside the assets directory
  • start Phoenix endpoint with mix phx.server

How to use it?

  • run state_machine_id=$(curl http://localhost:4000/create)
  • run curl http://localhost:4000/update/${state_machine_id}?transition=start
  • run curl http://localhost:4000/update/${state_machine_id}?transition=run
  • run curl http://localhost:4000/retrieve/${state_machine_id}
  • run curl http://localhost:4000/update/${state_machine_id}?transition=done
  • run curl http://localhost:4000/delete/${state_machine_id}
    • note: this should fail because after the done transition the state machine has ceased to exist

You can also run these commands with ./scripts/run.sh.

How to switch between implementations?

  • the repo features the following (tagged) implementations ...
    • 0.1.0-gen_statem - using gen_statem
    • 0.2.0-fsmx - using ecto/fsmx
    • 0.3.0-ecto_fsm - using ecto_fsm
  • you can select one of these by checking out the tag and then build/run it as described above
    • note: after checking out the tag/switching the implementation you need to reset the database(s) with MIX_ENV=test mix ecto.reset and MIX_ENV=dev mix ecto.reset

elixir-fsm's People

Contributors

dependabot[bot] avatar

Watchers

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