Skip to content

Commit 959f812

Browse files
authored
add workflow engine interface (#25)
What changed? WorkflowEngine is a stateful entity that process decision tasks and returns new decisions. It's just a fancy name of Decider in java SDK.
1 parent c31793f commit 959f812

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

cadence/workflow/workflow_engine.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from dataclasses import dataclass
2+
from typing import Callable
3+
4+
from cadence.api.v1.decision_pb2 import Decision
5+
from cadence.client import Client
6+
from cadence.data_converter import DataConverter
7+
from cadence.api.v1.service_worker_pb2 import PollForDecisionTaskResponse
8+
9+
@dataclass
10+
class WorkflowContext:
11+
domain: str
12+
workflow_id: str
13+
run_id: str
14+
client: Client
15+
workflow_func: Callable
16+
data_converter: DataConverter
17+
18+
@dataclass
19+
class DecisionResult:
20+
decisions: list[Decision]
21+
22+
class WorkflowEngine:
23+
def __init__(self, context: WorkflowContext):
24+
self._context = context
25+
26+
# TODO: Implement this
27+
def process_decision(self, decision_task: PollForDecisionTaskResponse) -> DecisionResult:
28+
return DecisionResult(decisions=[])

0 commit comments

Comments
 (0)