Automata is a lightweight framework that allows users to define a state based websocket connection manager.
Project description
Automata
Automata is a state based websocket manager that allows you to define your states, events, and event handlers. It provides a unified methodology and doctrine for defining and improving the clarity of websocket communication.
Table of Contents
Getting Started
This is a simple example of how you to set up your Automata instance and run your application.
Prerequisites
python version 3.11^
Installation and Setup
- Initialize your Automata (we use app.py)
from automata import Automata
my_machine = Automata(
name="myMachine"
)
- Create your states and any events (in any directory you want)
from automata import State
red_light = State('red_light')
@red_light.event('change_to_green')
async def handler(automata, data):
#Do something here...
run_some_func()
await transition('green_light') #Will change the state of our machine and will report this to the client
green_light = State('green_light')
@green_light.event('change_to_yellow')
async def handler(automata, data):
await transition('yellow')
#And so on and so on...
- Register states in your machine (back in the file you defined the machine)
my_machine.register_state(red_light) #The first state that is registered will be the initial state for new sessions
my_machine.register_state(green_light)
- Run the machine
my_machine.run('localhost', 8000)
License
Apache License 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
automata-ws-0.1.0.tar.gz
(7.3 kB
view hashes)
Built Distribution
Close
Hashes for automata_ws-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b22f50920858cc332a106609d843b3755b67450c0acb9fbcb9eaebf2d83890d |
|
MD5 | 69279aa1c334991f6b993a3f6d3fa10f |
|
BLAKE2b-256 | 8a9df520494633644b484a0ed4092dfa437469f550f068810faa06982e662a07 |