Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ourway/marmoolak
Yet another finite state machine with memory and callbacks
https://github.com/ourway/marmoolak
finite-state-machine fsm fsm-library
Last synced: 3 months ago
JSON representation
Yet another finite state machine with memory and callbacks
- Host: GitHub
- URL: https://github.com/ourway/marmoolak
- Owner: ourway
- License: mit
- Created: 2015-10-12T05:25:33.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-24T23:41:13.000Z (over 9 years ago)
- Last Synced: 2024-11-08T17:52:06.837Z (3 months ago)
- Topics: finite-state-machine, fsm, fsm-library
- Language: Python
- Homepage:
- Size: 297 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
marmoolak
=========.. figure:: https://raw.githubusercontent.com/ourway/marmoolak/master/logo.png
:alt: alt logo.. image:: https://badge.fury.io/py/marmoolak.svg
:target: https://badge.fury.io/py/marmoolak.. image:: https://img.shields.io/pypi/dm/marmoolak.svg
:target: https://pypi.python.org/pypi/marmoolak.. image:: https://api.travis-ci.org/ourway/marmoolak.svg
:target: https://travis-ci.org/ourway/marmoolak.. image:: https://codecov.io/github/ourway/marmoolak/coverage.svg?branch=master
:target: https://codecov.io/github/ourway/marmoolak?branch=masterinstall
-------::
pip install marmoolak
Usage
-----::
import marmoolak
marmoolak.REDIS_HOST = '192.168.99.100'
marmoolak.REDIS_PORT = 6379
machine = marmoolak.Machinedef onpanic(e):
print('panic! ' + e.msg)
def oncalm(e):
print('thanks to ' + e.msg + ' done by ' + e.args[0])
def ongreen(e):
print('green')
def onyellow(e):
print('yellow')
def onred(e):
print('red')fsm = machine('myname', 'version1' , {'initial': 'green',
'events': [
{'name': 'warn', 'src': 'green', 'dst': 'yellow'},
{'name': 'panic', 'src': 'yellow', 'dst': 'red'},
{'name': 'panic', 'src': 'green', 'dst': 'red'},
{'name': 'calm', 'src': 'red', 'dst': 'yellow'},
{'name': 'clear', 'src': 'yellow', 'dst': 'green'}],
'callbacks': {
'onpanic': onpanic,
'oncalm': oncalm,
'ongreen': ongreen,
'onyellow': onyellow,
'onred': onred }})fsm.panic(msg='killer bees', url="http://appido.ir/appido/api/getBooks.json")
fsm.calm('bob', msg='sedatives in the honey pots')credits
-------I used fysom and redis for achiving this functionality. So most of the
credit goes to redis and fysom developers.Contact me
----------Feel free to drop me a mail at [email protected]