Skip to content

Commit c1bd48b

Browse files
TD-P006: durable_workflow.sync.Client.start_workflow missing priority/fairness parameters (#47)
1 parent 5e19643 commit c1bd48b

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

src/durable_workflow/sync.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ def start_workflow(
238238
duplicate_policy: str | None = None,
239239
memo: dict[str, Any] | None = None,
240240
search_attributes: dict[str, Any] | None = None,
241+
priority: int | None = None,
242+
fairness_key: str | None = None,
243+
fairness_weight: int | None = None,
241244
) -> SyncWorkflowHandle:
242245
handle = _run(
243246
self._async.start_workflow(
@@ -250,6 +253,9 @@ def start_workflow(
250253
duplicate_policy=duplicate_policy,
251254
memo=memo,
252255
search_attributes=search_attributes,
256+
priority=priority,
257+
fairness_key=fairness_key,
258+
fairness_weight=fairness_weight,
253259
)
254260
)
255261
return SyncWorkflowHandle(handle)

tests/test_sync.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,57 @@ def test_start_returns_sync_handle(self) -> None:
5151
assert handle.workflow_id == "wf-1"
5252
assert handle.run_id == "run-1"
5353

54+
def test_priority_and_fairness_are_forwarded_on_start(self) -> None:
55+
client = Client("http://localhost:8080")
56+
resp = _mock_response(
57+
201,
58+
{
59+
"workflow_id": "wf-prio",
60+
"run_id": "run-prio",
61+
"workflow_type": "greeter",
62+
},
63+
)
64+
with patch.object(
65+
client._async._http, "request", new_callable=AsyncMock, return_value=resp
66+
) as mock:
67+
client.start_workflow(
68+
workflow_type="greeter",
69+
task_queue="shared",
70+
workflow_id="wf-prio",
71+
priority=1,
72+
fairness_key="tenant-a",
73+
fairness_weight=3,
74+
)
75+
76+
body = mock.call_args.kwargs.get("json") or mock.call_args[1].get("json")
77+
assert body["priority"] == 1
78+
assert body["fairness_key"] == "tenant-a"
79+
assert body["fairness_weight"] == 3
80+
81+
def test_priority_and_fairness_are_omitted_when_unset(self) -> None:
82+
client = Client("http://localhost:8080")
83+
resp = _mock_response(
84+
201,
85+
{
86+
"workflow_id": "wf-nopri",
87+
"run_id": "run-nopri",
88+
"workflow_type": "greeter",
89+
},
90+
)
91+
with patch.object(
92+
client._async._http, "request", new_callable=AsyncMock, return_value=resp
93+
) as mock:
94+
client.start_workflow(
95+
workflow_type="greeter",
96+
task_queue="shared",
97+
workflow_id="wf-nopri",
98+
)
99+
100+
body = mock.call_args.kwargs.get("json") or mock.call_args[1].get("json")
101+
assert "priority" not in body
102+
assert "fairness_key" not in body
103+
assert "fairness_weight" not in body
104+
54105

55106
class TestSyncClientDescribe:
56107
def test_describe(self) -> None:

0 commit comments

Comments
 (0)