Lightweight state management engine for posix compliant systems
Project description
Myosin
Modified: 2022-03
Lightweight state management engine.
About
State-driven software architectures are useful for allowing multiple modules to be able to communicate using the same base syntax. The syntax for communication of data is implemented through the state models which represent the the states of different components of the software.
Quickstart
Install myosin
from pip
python3 -m pip install myosin
Start by defining a model by creating a class that implements StateModel
from myosin import _PKey
from myosin import StateModel
class User(StateModel):
def __init__(self, _id: _PKey, name: str, email: str) -> None:
super().__init__(_id)
self.name = name
self.email = email
@property
def name(self) -> str:
return self.__name
@name.setter
def name(self, name: str) -> None:
self.__name = name
@property
def email(self) -> str:
return self.__email
@email.setter
def email(self, email: str) -> None:
self.__email = email
def serialize(self) -> Dict[str, Any]:
return {
'id': self.id,
'name': self.name,
'email': self.email
}
def deserialize(self, **kwargs) -> None:
for k, v in kwargs.items():
setattr(self, k, v)
In the application init load the default state model into the engine:
from myosin import _PKey
usr = User(
_id=1,
name="chris",
email="chris@email.com"
)
with State() as state:
# register the model into the state engine
state.load(usr)
In a consumer module you can access the global User
model through a checked out copy:
with State() as state:
# checkout a copy of the user state model
user = state.checkout(User)
# read properties from the user state model
logging.info("Username: %s", user.name)
In a producer module you can commit to the global User
model:
with State() as state:
# checkout a copy of the user state model
user = state.checkout(User)
# modify user state model copy
user.name = "cS"
# commit the modified copy
state.commit(user)
Documentation
Documentation coming soon
Contributions
Contributions are welcome. Please see the issue log and project kanban if you are unsure how to help.
License
This project is licensed under the terms of the MIT License
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
Built Distribution
File details
Details for the file myosin-0.0.6.tar.gz
.
File metadata
- Download URL: myosin-0.0.6.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f9a65b1fb804dd176d27fd922c229ab8925b17cd3542a11123969ec4481a564 |
|
MD5 | 8f9bcb5fffea02f043eaa2f9e2589c86 |
|
BLAKE2b-256 | 518a1488fe3aede938aaeb9c957e5bad099dd3f832dc75bbd4c01000d99b761b |
File details
Details for the file myosin-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: myosin-0.0.6-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebfc345115c5ca73d4cd3515ea6db8305c659875ed748fdf7ecc660eac802b77 |
|
MD5 | e28dcede8127e7433ccd6989a6b53f5c |
|
BLAKE2b-256 | 9a527d995bc76028e846cd364c5e0009bf550b4be0bc061654f3431db4319e8e |