Skip to main content

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
  1. Getting Started
  2. License

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

  1. Initialize your Automata (we use app.py)
from automata import Automata

my_machine = Automata(
  name="myMachine"
)
  1. 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...
  1. 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)
  1. Run the machine
my_machine.run('localhost', 8000)

License

Apache License 2.0

Project details


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)

Uploaded Source

Built Distribution

automata_ws-0.1.0-py3-none-any.whl (6.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page