Skip to content

Commit 73b724c

Browse files
committed
New polling API design
1 parent 2b2ada5 commit 73b724c

File tree

2 files changed

+49
-36
lines changed

2 files changed

+49
-36
lines changed

temporal/api/workflowservice/v1/request_response.proto

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,57 +2674,59 @@ message PollActivityExecutionRequest {
26742674
string activity_id = 2;
26752675
// Activity run ID. If empty the request targets the latest run.
26762676
string run_id = 3;
2677-
// Include the info field from the response.
2678-
bool include_info = 4;
26792677
// Include the input field in the response.
2680-
bool include_input = 5;
2681-
// Include the outcome field in the response.
2682-
bool include_outcome = 6;
2683-
2684-
message StateChangeWaitOptions {
2685-
// Token from a previous PollActivityExecutionResponse used to inform the server of the
2686-
// last state seen by the caller. If present, run_id must also be present.
2687-
bytes long_poll_token = 1;
2688-
}
2689-
message CompletionWaitOptions {}
2690-
2691-
// If present, the request will be handled as a long-poll. If absent, a response will be
2692-
// returned immediately containing the current activity state.
2693-
oneof wait_policy {
2694-
// Wait for any change in activity state before responding. If long_poll_token is absent
2695-
// then the current state will be returned immediately without any wait. Otherwise the
2696-
// server will wait until activity state differs from that encoded in the token before
2697-
// returning the new state. Note that activity state may change multiple times between
2698-
// requests, therefore it is not guaranteed that a client making a sequence of long-poll
2699-
// requests will see a complete sequence of state changes.
2700-
StateChangeWaitOptions wait_any_state_change = 8;
2701-
// Wait for the activity to complete before responding.
2702-
// long_poll_token is currently ignored when waiting for completion
2703-
CompletionWaitOptions wait_completion = 9;
2704-
}
2678+
bool include_input = 4;
2679+
// Include the result/failure in the response if the activity has completed.
2680+
bool include_result = 5;
2681+
// Token from a previous PollActivityExecutionResponse. If present, long-poll until activity
2682+
// state changes from the state encoded in this token. If absent, return current state immediately.
2683+
// If present, run_id must also be present.
2684+
// Note that activity state may change multiple times between requests, therefore it is not
2685+
// guaranteed that a client making a sequence of long-poll requests will see a complete
2686+
// sequence of state changes.
2687+
bytes long_poll_token = 6;
27052688
}
27062689

27072690
message PollActivityExecutionResponse {
27082691
// The run ID of the activity, useful when run_id was not specified in the request.
27092692
string run_id = 1;
27102693

2711-
// Only set if include_info was true in the request.
2694+
// Information about the activity execution.
27122695
temporal.api.activity.v1.ActivityExecutionInfo info = 2;
27132696

27142697
// Serialized activity input, passed as arguments to the activity function.
2698+
// Only set if include_input was true in the request.
27152699
temporal.api.common.v1.Payloads input = 3;
27162700

2717-
// Only set if the activity is completed and include_outcome was true in the request.
2701+
// Only set if the activity is completed and include_result was true in the request.
27182702
oneof outcome {
27192703
// The result if the activity completed successfully.
27202704
temporal.api.common.v1.Payloads result = 4;
27212705
// The failure if the activity completed unsuccessfully.
27222706
temporal.api.failure.v1.Failure failure = 5;
27232707
}
27242708

2725-
// Token to use for a follow-on request using wait_any_state_change.
2726-
// Only set if wait_policy was wait_any_state_change and the activity is not complete.
2727-
bytes state_change_long_poll_token = 6;
2709+
// Token for follow-on long-poll requests. Absent only if the activity is complete.
2710+
bytes long_poll_token = 6;
2711+
}
2712+
2713+
message PollActivityExecutionOutcomeRequest {
2714+
string namespace = 1;
2715+
string activity_id = 2;
2716+
// Activity run ID. If empty the request targets the latest run.
2717+
string run_id = 3;
2718+
}
2719+
2720+
message PollActivityExecutionOutcomeResponse {
2721+
// The run ID of the activity, useful when run_id was not specified in the request.
2722+
string run_id = 1;
2723+
2724+
oneof outcome {
2725+
// The result if the activity completed successfully.
2726+
temporal.api.common.v1.Payloads result = 2;
2727+
// The failure if the activity completed unsuccessfully.
2728+
temporal.api.failure.v1.Failure failure = 3;
2729+
}
27282730
}
27292731

27302732

temporal/api/workflowservice/v1/service.proto

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,11 +1403,11 @@ service WorkflowService {
14031403
};
14041404
}
14051405

1406-
// PollActivityExecution returns the status and/or outcome of an activity execution.
1407-
// Supported use cases include
1406+
// PollActivityExecution returns information about an activity execution.
1407+
// Supported use cases include:
14081408
// - Get current activity info without waiting
1409-
// - Wait for next state change and return activity info
1410-
// - Wait for completion and return outcome
1409+
// - Long-poll for next state change and return new activity info
1410+
// Response can optionally include activity input or result (if the activity has completed)
14111411
rpc PollActivityExecution (PollActivityExecutionRequest) returns (PollActivityExecutionResponse) {
14121412
option (google.api.http) = {
14131413
get: "/namespaces/{namespace}/activities/{activity_id}"
@@ -1417,6 +1417,17 @@ service WorkflowService {
14171417
};
14181418
}
14191419

1420+
// PollActivityExecutionOutcome long-polls for an activity execution to complete and returns
1421+
// the outcome (result or failure).
1422+
rpc PollActivityExecutionOutcome (PollActivityExecutionOutcomeRequest) returns (PollActivityExecutionOutcomeResponse) {
1423+
option (google.api.http) = {
1424+
get: "/namespaces/{namespace}/activities/{activity_id}/outcome"
1425+
additional_bindings {
1426+
get: "/api/v1/namespaces/{namespace}/activities/{activity_id}/outcome"
1427+
}
1428+
};
1429+
}
1430+
14201431
// ListActivityExecutions is a visibility API to list activity executions in a specific namespace.
14211432
rpc ListActivityExecutions (ListActivityExecutionsRequest) returns (ListActivityExecutionsResponse) {
14221433
option (google.api.http) = {

0 commit comments

Comments
 (0)