Creating a sketch of the Mealy machine system
3 unresolved threads
3 unresolved threads
Messing around making a prototype of the capability execution state machine system.
Edited by Daniel Lyons
Merge request reports
Activity
27 """ 28 An action to take upon performing a transition. We expect to see several implementations 29 of this interface: 30 31 - SendNotification(template, additional_args) that sends a notification with 32 the event and additional arguments 33 34 - StartWorkflow(workflow_name, additional_args) that starts a workflow with the 35 provided name, the event and additional arguments 36 """ 37 @abc.abstractmethod 38 def execute(self): 39 pass 40 41 42 class Pattern(abc.ABC): 129 this event, that we would therefore need to act on. 130 131 :param event: the event to check 132 :return: a list of matching capability executions 133 """ 134 return self.session.query(""" 135 SELECT * 136 FROM transitions t 137 JOIN machines m ON t.machine_id = m.id 138 JOIN capabilities c ON c.machine_id = m.id 139 JOIN capability_requests cr on cr.capability_name = c.name 140 JOIN capability_executions ce on cr.capability_request_id = ce.capability_request_id 141 WHERE %(event)s @? t.pattern AND ce.state = t.from_state 142 """, {"event": json.dumps(event)}) 143 144 def build_tables(self): 8 import json 9 10 11 class State(abc.ABC): 12 """ 13 A state that a machine could reside in. 14 """ 15 @abc.abstractmethod 16 def matches(self, other: "State") -> bool: 17 """ 18 This is most likely implemented by doing a string-equality test. 19 20 :param other: the other state to compare to 21 :return: true if we and the other state match 22 """ 23 pass added 8 commits
-
1b0905b5...2202b9c2 - 7 commits from branch
main
- 0398cfdb - Creating a sketch of the Mealy machine system
-
1b0905b5...2202b9c2 - 7 commits from branch
added 2 commits
Please register or sign in to reply