Skip to content

Commit

Permalink
Add ShutdownWorker internal API (#443)
Browse files Browse the repository at this point in the history
* Add ShutdownWorker internal API. 

This API will allow workers to signal shutdown/restart, which Matching can use to unload the shutdown worker's sticky task queue. This will effectively remove the latency incurred from tasks being pushed to a sticky worker after that worker has already been shutdown.
  • Loading branch information
lina-temporal authored Aug 28, 2024
1 parent d761393 commit 4a1ab98
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions openapi/openapiv2.json
Original file line number Diff line number Diff line change
Expand Up @@ -10091,6 +10091,9 @@
],
"default": "SEVERITY_UNSPECIFIED"
},
"v1ShutdownWorkerResponse": {
"type": "object"
},
"v1SignalExternalWorkflowExecutionCommandAttributes": {
"type": "object",
"properties": {
Expand Down
10 changes: 10 additions & 0 deletions temporal/api/workflowservice/v1/request_response.proto
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,16 @@ message ResetStickyTaskQueueRequest {
message ResetStickyTaskQueueResponse {
}

message ShutdownWorkerRequest {
string namespace = 1;
string sticky_task_queue = 2;
string identity = 3;
string reason = 4;
}

message ShutdownWorkerResponse {
}

message QueryWorkflowRequest {
string namespace = 1;
temporal.api.common.v1.WorkflowExecution execution = 2;
Expand Down
20 changes: 20 additions & 0 deletions temporal/api/workflowservice/v1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,31 @@ service WorkflowService {
// 1. StickyTaskQueue
// 2. StickyScheduleToStartTimeout
//
// When possible, ShutdownWorker should be preferred over
// ResetStickyTaskQueue (particularly when a worker is shutting down or
// cycling).
//
// (-- api-linter: core::0127::http-annotation=disabled
// aip.dev/not-precedent: We do not expose worker API to HTTP. --)
rpc ResetStickyTaskQueue (ResetStickyTaskQueueRequest) returns (ResetStickyTaskQueueResponse) {
}

// ShutdownWorker is used to indicate that the given sticky task
// queue is no longer being polled by its worker. Following the completion of
// ShutdownWorker, newly-added workflow tasks will instead be placed
// in the normal task queue, eligible for any worker to pick up.
//
// ShutdownWorker should be called by workers while shutting down,
// after they've shut down their pollers. If another sticky poll
// request is issued, the sticky task queue will be revived.
//
// As of Temporal Server v1.25.0, ShutdownWorker hasn't yet been implemented.
//
// (-- api-linter: core::0127::http-annotation=disabled
// aip.dev/not-precedent: We do not expose worker API to HTTP. --)
rpc ShutdownWorker (ShutdownWorkerRequest) returns (ShutdownWorkerResponse) {
}

// QueryWorkflow requests a query be executed for a specified workflow execution.
rpc QueryWorkflow (QueryWorkflowRequest) returns (QueryWorkflowResponse) {
option (google.api.http) = {
Expand Down

0 comments on commit 4a1ab98

Please sign in to comment.