Skip to content

Commit f9b24e3

Browse files
authored
DX-2192: add workflow endpoint detection feature and bump version to 0.1.4 (#36)
* feat: add workflow endpoint detection feature and bump version to 0.1.4 * fix: fmt * feat: add failure callback feature set headers to workflow requests
1 parent 43360f0 commit f9b24e3

File tree

7 files changed

+39
-7
lines changed

7 files changed

+39
-7
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "upstash-workflow"
3-
version = "0.1.3"
3+
version = "0.1.4"
44
description = "Python SDK for Upstash Workflow"
55
license = "MIT"
66
authors = ["Upstash <[email protected]>"]

tests/asyncio/test_context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ async def execute() -> None:
6666
"Upstash-Workflow-RunId": "wfr-id",
6767
"Upstash-Workflow-Url": "https://www.my-website.com/api",
6868
"Upstash-Feature-Set": "WF_NoDelete,InitialBody",
69+
"Upstash-Failure-Callback-Feature-Set": "LazyFetch,InitialBody",
70+
"Upstash-Callback-Failure-Callback-Feature-Set": "LazyFetch,InitialBody",
6971
"Upstash-Failure-Callback-Forward-Upstash-Workflow-Is-Failure": "true",
7072
"Upstash-Failure-Callback-Forward-Upstash-Workflow-Failure-Callback": "true",
7173
"Upstash-Failure-Callback-Workflow-Runid": "wfr-id",

tests/test_context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def execute() -> None:
6565
"Upstash-Workflow-RunId": "wfr-id",
6666
"Upstash-Workflow-Url": "https://www.my-website.com/api",
6767
"Upstash-Feature-Set": "WF_NoDelete,InitialBody",
68+
"Upstash-Failure-Callback-Feature-Set": "LazyFetch,InitialBody",
69+
"Upstash-Callback-Failure-Callback-Feature-Set": "LazyFetch,InitialBody",
6870
"Upstash-Failure-Callback-Forward-Upstash-Workflow-Is-Failure": "true",
6971
"Upstash-Failure-Callback-Forward-Upstash-Workflow-Failure-Callback": "true",
7072
"Upstash-Failure-Callback-Workflow-Runid": "wfr-id",

upstash_workflow/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.1.3"
1+
__version__ = "0.1.4"
22

33
from upstash_workflow.context.context import WorkflowContext
44
from upstash_workflow.serve.serve import serve

upstash_workflow/asyncio/serve/options.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
from typing import Callable, Dict, Optional, cast, TypeVar, Any, Generic, Awaitable
55
from qstash import AsyncQStash, Receiver
66
from upstash_workflow.workflow_types import _Response
7-
from upstash_workflow.constants import DEFAULT_RETRIES
7+
from upstash_workflow.constants import (
8+
DEFAULT_RETRIES,
9+
WORKFLOW_PROTOCOL_VERSION_HEADER,
10+
WORKFLOW_PROTOCOL_VERSION,
11+
)
812
from upstash_workflow.types import (
913
_FinishCondition,
1014
)
@@ -74,11 +78,19 @@ def _on_step_finish(
7478
"workflowRunId": workflow_run_id,
7579
},
7680
status=400,
81+
headers={
82+
WORKFLOW_PROTOCOL_VERSION_HEADER: WORKFLOW_PROTOCOL_VERSION
83+
},
7784
),
7885
)
7986

8087
return cast(
81-
TResponse, _Response(body={"workflowRunId": workflow_run_id}, status=200)
88+
TResponse,
89+
_Response(
90+
body={"workflowRunId": workflow_run_id},
91+
status=200,
92+
headers={WORKFLOW_PROTOCOL_VERSION_HEADER: WORKFLOW_PROTOCOL_VERSION},
93+
),
8294
)
8395

8496
def _initial_payload_parser(initial_request: str) -> TInitialPayload:

upstash_workflow/serve/options.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
)
1717
from qstash import QStash, Receiver
1818
from upstash_workflow.workflow_types import _Response, _SyncRequest, _AsyncRequest
19-
from upstash_workflow.constants import DEFAULT_RETRIES
19+
from upstash_workflow.constants import (
20+
DEFAULT_RETRIES,
21+
WORKFLOW_PROTOCOL_VERSION_HEADER,
22+
WORKFLOW_PROTOCOL_VERSION,
23+
)
2024
from upstash_workflow.types import (
2125
_FinishCondition,
2226
)
@@ -99,11 +103,19 @@ def _on_step_finish(
99103
"workflowRunId": workflow_run_id,
100104
},
101105
status=400,
106+
headers={
107+
WORKFLOW_PROTOCOL_VERSION_HEADER: WORKFLOW_PROTOCOL_VERSION
108+
},
102109
),
103110
)
104111

105112
return cast(
106-
TResponse, _Response(body={"workflowRunId": workflow_run_id}, status=200)
113+
TResponse,
114+
_Response(
115+
body={"workflowRunId": workflow_run_id},
116+
status=200,
117+
headers={WORKFLOW_PROTOCOL_VERSION_HEADER: WORKFLOW_PROTOCOL_VERSION},
118+
),
107119
)
108120

109121
def _initial_payload_parser(initial_request: str) -> TInitialPayload:

upstash_workflow/workflow_requests.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def _get_headers(
278278
WORKFLOW_INIT_HEADER: init_header_value,
279279
WORKFLOW_ID_HEADER: workflow_run_id,
280280
WORKFLOW_URL_HEADER: workflow_url,
281-
WORKFLOW_FEATURE_HEADER: "LazyFetch,InitialBody",
281+
WORKFLOW_FEATURE_HEADER: "LazyFetch,InitialBody,WF_DetectTrigger",
282282
}
283283

284284
if not (step and step.call_url):
@@ -300,6 +300,7 @@ def _get_headers(
300300
base_headers["Upstash-Failure-Callback-Workflow-Init"] = "false"
301301
base_headers["Upstash-Failure-Callback-Workflow-Url"] = workflow_url
302302
base_headers["Upstash-Failure-Callback-Workflow-Calltype"] = "failureCall"
303+
base_headers["Upstash-Failure-Callback-Feature-Set"] = "LazyFetch,InitialBody"
303304
if step and step.call_url:
304305
base_headers[
305306
f"Upstash-Callback-Failure-Callback-Forward-{WORKFLOW_FAILURE_HEADER}"
@@ -317,6 +318,9 @@ def _get_headers(
317318
base_headers["Upstash-Callback-Failure-Callback-Workflow-Calltype"] = (
318319
"failureCall"
319320
)
321+
base_headers["Upstash-Callback-Failure-Callback-Feature-Set"] = (
322+
"LazyFetch,InitialBody"
323+
)
320324

321325
if _should_set_retries(retries):
322326
base_headers["Upstash-Failure-Callback-Retries"] = str(retries)

0 commit comments

Comments
 (0)