Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stevenferrer/phonestates

A demo of using stateless, an implementation of state machine in Go which uses an external storage
https://github.com/stevenferrer/phonestates

fsm state-machine stateless

Last synced: 23 days ago
JSON representation

A demo of using stateless, an implementation of state machine in Go which uses an external storage

Awesome Lists containing this project

README

        

# Phone states

![phone states](./phonestates.png)

This project demonstrates the use of [stateless](https://github.com/qmuntal/stateless), an implementation of state machines in Go.

This is a modified version of the original [example](https://github.com/qmuntal/stateless/blob/master/example_test.go) which uses an external storage for storing the states.

```go
type LogRepository struct {
...
phoneLogs map[PhoneID][]Log
}
```

This is a very simple in-memory store. But in reality, this external storage can be a real database (e.g. Postgres, MariaDB, etc.)

## Running

To run the example just run the command below:
` $ go build -v -o phonestates && ./phonestates `