diff --git a/openapi/openapiv2.json b/openapi/openapiv2.json index dfe59394e..6ab0afa2f 100644 --- a/openapi/openapiv2.json +++ b/openapi/openapiv2.json @@ -8125,6 +8125,10 @@ "type": "object", "$ref": "#/definitions/v1WorkerHeartbeat" } + }, + "leaseDuration": { + "type": "string", + "description": "Duration for which the worker lease should be valid. During this time, the server considers the worker to be active.\nThe worker is expected to send periodic heartbeats to renew its lease before it expires.\n\nServer will calculate the actual expiration time based on when it receives this request.\nIf not specified or zero, the server will use a default lease duration of 1 minute.\n\nThere are 3 states for a worker: Active, Inactive, and CleanedUp.\nLifecycle transitions:\n- Active->Active: Each time the server receives a heartbeat from the worker, it will renew the lease and keep the worker in the active state.\n\n- Active->Inactive: When the lease expires, the server will consider the worker to be inactive, and reschedule activities that were known to be running as of that time.\n\n- Inactive->Active: If the server receives subsequent heartbeat from this worker, then it will transition it back to the active state.\n\n- Inactive->CleanedUp: If the worker remains inactive for a prolonged period, the server will cleanup the worker state. This is a terminal state.\n If the server receives subsequent heartbeat from this worker, then it will always return an non-retryable FailedPrecondition error.\n The worker will need to shutdown and re-register using a different WorkerInstanceKey to become active again." } } }, diff --git a/openapi/openapiv3.yaml b/openapi/openapiv3.yaml index 7c91c447f..d490939db 100644 --- a/openapi/openapiv3.yaml +++ b/openapi/openapiv3.yaml @@ -10355,6 +10355,27 @@ components: type: array items: $ref: '#/components/schemas/WorkerHeartbeat' + leaseDuration: + pattern: ^-?(?:0|[1-9][0-9]{0,11})(?:\.[0-9]{1,9})?s$ + type: string + description: |- + Duration for which the worker lease should be valid. During this time, the server considers the worker to be active. + The worker is expected to send periodic heartbeats to renew its lease before it expires. + + Server will calculate the actual expiration time based on when it receives this request. + If not specified or zero, the server will use a default lease duration of 1 minute. + + There are 3 states for a worker: Active, Inactive, and CleanedUp. + Lifecycle transitions: + - Active->Active: Each time the server receives a heartbeat from the worker, it will renew the lease and keep the worker in the active state. + + - Active->Inactive: When the lease expires, the server will consider the worker to be inactive, and reschedule activities that were known to be running as of that time. + + - Inactive->Active: If the server receives subsequent heartbeat from this worker, then it will transition it back to the active state. + + - Inactive->CleanedUp: If the worker remains inactive for a prolonged period, the server will cleanup the worker state. This is a terminal state. + If the server receives subsequent heartbeat from this worker, then it will always return an non-retryable FailedPrecondition error. + The worker will need to shutdown and re-register using a different WorkerInstanceKey to become active again. RecordWorkerHeartbeatResponse: type: object properties: {} diff --git a/temporal/api/workflowservice/v1/request_response.proto b/temporal/api/workflowservice/v1/request_response.proto index bd9282998..ddbb3cbba 100644 --- a/temporal/api/workflowservice/v1/request_response.proto +++ b/temporal/api/workflowservice/v1/request_response.proto @@ -2467,6 +2467,25 @@ message RecordWorkerHeartbeatRequest { string identity = 2; repeated temporal.api.worker.v1.WorkerHeartbeat worker_heartbeat = 3; + + // Duration for which the worker lease should be valid. During this time, the server considers the worker to be active. + // The worker is expected to send periodic heartbeats to renew its lease before it expires. + // + // Server will calculate the actual expiration time based on when it receives this request. + // If not specified or zero, the server will use a default lease duration of 1 minute. + // + // There are 3 states for a worker: Active, Inactive, and CleanedUp. + // Lifecycle transitions: + // - Active->Active: Each time the server receives a heartbeat from the worker, it will renew the lease and keep the worker in the active state. + // + // - Active->Inactive: When the lease expires, the server will consider the worker to be inactive, and reschedule activities that were known to be running as of that time. + // + // - Inactive->Active: If the server receives subsequent heartbeat from this worker, then it will transition it back to the active state. + // + // - Inactive->CleanedUp: If the worker remains inactive for a prolonged period, the server will cleanup the worker state. This is a terminal state. + // If the server receives subsequent heartbeat from this worker, then it will always return an non-retryable FailedPrecondition error. + // The worker will need to shutdown and re-register using a different WorkerInstanceKey to become active again. + google.protobuf.Duration lease_duration = 4; } message RecordWorkerHeartbeatResponse {