1
1
"""The WorkflowEngine execution logic.
2
2
"""
3
3
4
- from dataclasses import dataclass
5
- from typing import Optional
6
-
7
- from informaticsmatters .protobuf .datamanager .pod_message_pb2 import PodMessage
4
+ from google .protobuf .message import Message
8
5
9
6
from .workflow_abc import DatabaseAdapter , InstanceLauncher
10
7
11
8
12
- @dataclass
13
- class HandlePodMessageResult :
14
- """WorkflowEngine handle message result."""
15
-
16
- error : int
17
- error_msg : Optional [str ]
18
-
19
-
20
- _SUCCESS_MESSAGE_RESULT : HandlePodMessageResult = HandlePodMessageResult (
21
- error = 0 , error_msg = None
22
- )
23
-
24
-
25
9
class WorkflowEngine :
26
10
"""The workflow engine. An event-driven engine that manages the execution
27
11
of workflow instances. The engine is responsible for launching instances or
@@ -38,18 +22,16 @@ def __init__(
38
22
self ._instance_launcher = instance_launcher
39
23
self ._db_adapter = db_adapter
40
24
41
- def handle_pod_message (
42
- self ,
43
- pod_msg : PodMessage ,
44
- ) -> HandlePodMessageResult :
45
- """Given a PodMessage, we use it to identify the Pod (Instance) exit code,
25
+ def handle_message (self , msg : Message ) -> None :
26
+ """Given a Pod Message, we use it to identify the Pod (Instance) exit code,
46
27
workflow and step and decide what to do next.
47
28
48
29
Only pod messages relating to workflow instances will be delivered to this method.
49
30
The Pod message has an 'instance' property that provides the UUID of
50
31
the instance that was run. This can be used to correlate the instance with the
51
32
running workflow step.
52
- """
53
- assert pod_msg
54
33
55
- return _SUCCESS_MESSAGE_RESULT
34
+ Additionally we will encounter WorkflowMessages that signal the need to
35
+ start and stop workflows.
36
+ """
37
+ assert msg
0 commit comments