File tree Expand file tree Collapse file tree
aikido_zen/background_process/commands Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,7 +17,24 @@ class Command(ABC):
1717 def identifier (cls ) -> str :
1818 pass
1919
20+ @classmethod
21+ @abstractmethod
22+ def returns_data (cls ) -> bool :
23+ pass
24+
2025 @classmethod
2126 @abstractmethod
2227 def run (cls , context : CommandContext , request ):
2328 pass
29+
30+ @classmethod
31+ @abstractmethod
32+ def generate (cls , * args , ** kwargs ):
33+ pass
34+
35+
36+ class Payload :
37+ def __init__ (self , command : type [Command ], request ):
38+ self .identifier = command .identifier ()
39+ self .returns_data = command .returns_data ()
40+ self .request = request
Original file line number Diff line number Diff line change 1- from .command import Command , CommandContext
1+ from .command import Command , CommandContext , Payload
22
33
44class PutEventReq :
@@ -13,6 +13,14 @@ class PutEventCommand(Command):
1313 def identifier (cls ) -> str :
1414 return "put_event"
1515
16+ @classmethod
17+ def returns_data (cls ) -> bool :
18+ return False
19+
1620 @classmethod
1721 def run (cls , context : CommandContext , request : PutEventReq ):
1822 context .queue .put (request .event )
23+
24+ @classmethod
25+ def generate (cls , event ) -> Payload :
26+ return Payload (cls , PutEventReq (event ))
You can’t perform that action at this time.
0 commit comments