You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ideally, the SetCommand and LogEntry in the sample code should be represented as shown below.
classSetCommand(AbstractLogEntry):
""" Represent simple key-value command. Use pickle to serialize the data. """def__init__(self, key: str, value: str) ->None:
self.key=keyself.value=value@overridedefencode(self) ->bytes:
returnpickle.dumps(self.__dict__)
@override@classmethoddefdecode(cls, packed: bytes) ->"SetCommand":
unpacked=pickle.loads(packed)
returncls(unpacked["key"], unpacked["value"])
classHashStore(AbstractStateMachine):
""" A simple key-value store that stores data in memory. Use pickle to serialize the data. """def__init__(self):
self._store=dict()
self._loop=asyncio.get_running_loop()
defget(self, key: str) ->Optional[str]:
returnself._store.get(key)
defas_dict(self) ->dict:
returnself._store@overrideasyncdefapply(self, msg: bytes) ->bytes:
message=SetCommand.decode(msg)
self._store[message.key] =message.valuereturnmsg@overrideasyncdefsnapshot(self) ->bytes:
returnpickle.dumps(self._store)
@overrideasyncdefrestore(self, snapshot: bytes) ->None:
self._store=pickle.loads(snapshot)
However, for now, these two types are only temporarily defined in the .pyi file and are not actually included in the whl, resulting in an import error.
from raftify import AbstractLogEntry, AbstractStateMachine
ImportError: cannot import name 'AbstractLogEntry' from 'raftify' (/opt/homebrew/lib/python3.12/site-packages/raftify/__init__.py)
The text was updated successfully, but these errors were encountered:
jopemachine
changed the title
Establish actual relationships of the Python binding LogEntry, StateMachine
Establish actual relationships of the Python binding's LogEntry, StateMachine types
Apr 29, 2024
jopemachine
changed the title
Establish actual relationships of the Python binding's LogEntry, StateMachine types
Establish actual relationship of the Python binding's LogEntry, StateMachine types
Apr 29, 2024
Ideally, the
SetCommand
andLogEntry
in the sample code should be represented as shown below.However, for now, these two types are only temporarily defined in the
.pyi
file and are not actually included in the whl, resulting in an import error.The text was updated successfully, but these errors were encountered: