Skip to content

Commit b56b701

Browse files
committed
sdks: add idempotency_key to trigger workflow requests
1 parent 3173613 commit b56b701

13 files changed

Lines changed: 117 additions & 65 deletions

File tree

sdks/python/hatchet_sdk/contracts/v1/workflows_pb2.py

Lines changed: 44 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/python/hatchet_sdk/contracts/v1/workflows_pb2.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class ReplayTasksResponse(_message.Message):
107107
def __init__(self, replayed_tasks: _Optional[_Iterable[str]] = ...) -> None: ...
108108

109109
class TriggerWorkflowRunRequest(_message.Message):
110-
__slots__ = ("workflow_name", "input", "additional_metadata", "priority", "desired_worker_labels")
110+
__slots__ = ("workflow_name", "input", "additional_metadata", "priority", "desired_worker_labels", "idempotency_key")
111111
class DesiredWorkerLabelsEntry(_message.Message):
112112
__slots__ = ("key", "value")
113113
KEY_FIELD_NUMBER: _ClassVar[int]
@@ -120,12 +120,14 @@ class TriggerWorkflowRunRequest(_message.Message):
120120
ADDITIONAL_METADATA_FIELD_NUMBER: _ClassVar[int]
121121
PRIORITY_FIELD_NUMBER: _ClassVar[int]
122122
DESIRED_WORKER_LABELS_FIELD_NUMBER: _ClassVar[int]
123+
IDEMPOTENCY_KEY_FIELD_NUMBER: _ClassVar[int]
123124
workflow_name: str
124125
input: bytes
125126
additional_metadata: bytes
126127
priority: int
127128
desired_worker_labels: _containers.MessageMap[str, _trigger_pb2.DesiredWorkerLabels]
128-
def __init__(self, workflow_name: _Optional[str] = ..., input: _Optional[bytes] = ..., additional_metadata: _Optional[bytes] = ..., priority: _Optional[int] = ..., desired_worker_labels: _Optional[_Mapping[str, _trigger_pb2.DesiredWorkerLabels]] = ...) -> None: ...
129+
idempotency_key: str
130+
def __init__(self, workflow_name: _Optional[str] = ..., input: _Optional[bytes] = ..., additional_metadata: _Optional[bytes] = ..., priority: _Optional[int] = ..., desired_worker_labels: _Optional[_Mapping[str, _trigger_pb2.DesiredWorkerLabels]] = ..., idempotency_key: _Optional[str] = ...) -> None: ...
129131

130132
class TriggerWorkflowRunResponse(_message.Message):
131133
__slots__ = ("external_id",)

sdks/typescript/generate-protoc.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
15
# Directory to write generated code to (.js and .d.ts files)
26

37
OUT_DIR="./src/protoc"
@@ -8,12 +12,22 @@ else
812
IN_DIR="../../api-contracts"
913
fi
1014

11-
# Generate code
12-
./node_modules/.bin/grpc_tools_node_protoc \
15+
# Generate code.
16+
# Prefer system `protoc` (available in Nix environments) over `grpc-tools`' bundled protoc.
17+
PROTOC_BIN="${PROTOC_BIN:-}"
18+
if [ -z "$PROTOC_BIN" ]; then
19+
if command -v protoc >/dev/null 2>&1; then
20+
PROTOC_BIN="protoc"
21+
else
22+
PROTOC_BIN="./node_modules/.bin/grpc_tools_node_protoc"
23+
fi
24+
fi
25+
26+
"$PROTOC_BIN" \
1327
--plugin=protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto \
14-
--ts_proto_out=$OUT_DIR \
28+
--ts_proto_out="$OUT_DIR" \
1529
--ts_proto_opt=outputServices=nice-grpc,outputServices=generic-definitions,useExactTypes=false \
16-
--proto_path=$IN_DIR \
17-
$IN_DIR/**/*.proto
30+
--proto_path="$IN_DIR" \
31+
$(find "$IN_DIR" -type f -name '*.proto' -print)
1832

1933
pnpm lint:fix

sdks/typescript/src/clients/admin/admin-client.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export type WorkflowRun<T = object> = {
7777
parentStepRunId?: string | undefined;
7878
childIndex?: number | undefined;
7979
childKey?: string | undefined;
80+
idempotencyKey?: string | undefined;
8081
additionalMetadata?: Record<string, string> | undefined;
8182
};
8283
};
@@ -196,6 +197,7 @@ export class AdminClient {
196197
parentStepRunId?: string | undefined;
197198
childIndex?: number | undefined;
198199
childKey?: string | undefined;
200+
idempotencyKey?: string | undefined;
199201
additionalMetadata?: Record<string, string> | undefined;
200202
}
201203
) {
@@ -228,6 +230,7 @@ export class AdminClient {
228230
parentStepRunId?: string | undefined;
229231
childIndex?: number | undefined;
230232
childKey?: string | undefined;
233+
idempotencyKey?: string | undefined;
231234
additionalMetadata?: Record<string, string> | undefined;
232235
desiredWorkerId?: string | undefined;
233236
priority?: Priority;
@@ -291,6 +294,7 @@ export class AdminClient {
291294
parentStepRunId?: string | undefined;
292295
childIndex?: number | undefined;
293296
childKey?: string | undefined;
297+
idempotencyKey?: string | undefined;
294298
additionalMetadata?: Record<string, string> | undefined;
295299
desiredWorkerId?: string | undefined;
296300
priority?: Priority;

sdks/typescript/src/protoc/dispatcher/dispatcher.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/typescript/src/protoc/events/events.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/typescript/src/protoc/google/protobuf/timestamp.ts

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/typescript/src/protoc/v1/dispatcher.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/typescript/src/protoc/v1/shared/condition.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/typescript/src/protoc/v1/workflows.ts

Lines changed: 24 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)