diff --git a/openapi/openapiv2.json b/openapi/openapiv2.json index bf8692b66..669fc0a29 100644 --- a/openapi/openapiv2.json +++ b/openapi/openapiv2.json @@ -9041,13 +9041,9 @@ } }, "definitions": { - "CallbackInfoTrigger": { + "CallbackInfoActivityClosed": { "type": "object", - "properties": { - "workflowClosed": { - "$ref": "#/definitions/CallbackInfoWorkflowClosed" - } - } + "description": "Trigger for when the activity is closed." }, "CallbackInfoWorkflowClosed": { "type": "object", @@ -9156,6 +9152,21 @@ }, "description": "Target a worker polling on a Nexus task queue in a specific namespace." }, + "LinkActivity": { + "type": "object", + "properties": { + "namespace": { + "type": "string" + }, + "activityId": { + "type": "string" + }, + "runId": { + "type": "string" + } + }, + "description": "A link to an activity." + }, "LinkBatchJob": { "type": "object", "properties": { @@ -10437,6 +10448,22 @@ "priority": { "$ref": "#/definitions/v1Priority", "description": "Priority metadata." + }, + "completionCallbacks": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1Callback" + }, + "description": "Callbacks to be called by the server when this activity reaches a terminal state.\nCallback addresses must be whitelisted in the server's dynamic configuration." + }, + "links": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/apiCommonV1Link" + }, + "description": "Links to be associated with the activity. Callbacks may also have associated links;\nlinks already included with a callback should not be duplicated here." } } }, @@ -11084,6 +11111,113 @@ }, "description": "Used to validate the compute config without attaching it to a Worker Deployment Version." }, + "apiActivityV1CallbackInfo": { + "type": "object", + "properties": { + "callback": { + "$ref": "#/definitions/v1Callback", + "description": "Information on how this callback should be invoked (e.g. its URL and type)." + }, + "trigger": { + "$ref": "#/definitions/apiActivityV1CallbackInfoTrigger", + "description": "Trigger for this callback." + }, + "registrationTime": { + "type": "string", + "format": "date-time", + "description": "The time when the callback was registered." + }, + "state": { + "$ref": "#/definitions/v1CallbackState", + "description": "The current state of the callback." + }, + "attempt": { + "type": "integer", + "format": "int32", + "description": "The number of attempts made to deliver the callback.\nThis number represents a minimum bound since the attempt is incremented after the callback request completes." + }, + "lastAttemptCompleteTime": { + "type": "string", + "format": "date-time", + "description": "The time when the last attempt completed." + }, + "lastAttemptFailure": { + "$ref": "#/definitions/v1Failure", + "description": "The last attempt's failure, if any." + }, + "nextAttemptScheduleTime": { + "type": "string", + "format": "date-time", + "description": "The time when the next attempt is scheduled." + }, + "blockedReason": { + "type": "string", + "description": "If the state is BLOCKED, blocked reason provides additional information." + } + }, + "description": "CallbackInfo contains the state of an attached activity callback." + }, + "apiActivityV1CallbackInfoTrigger": { + "type": "object", + "properties": { + "activityClosed": { + "$ref": "#/definitions/CallbackInfoActivityClosed" + } + } + }, + "apiWorkflowV1CallbackInfo": { + "type": "object", + "properties": { + "callback": { + "$ref": "#/definitions/v1Callback", + "description": "Information on how this callback should be invoked (e.g. its URL and type)." + }, + "trigger": { + "$ref": "#/definitions/apiWorkflowV1CallbackInfoTrigger", + "description": "Trigger for this callback." + }, + "registrationTime": { + "type": "string", + "format": "date-time", + "description": "The time when the callback was registered." + }, + "state": { + "$ref": "#/definitions/v1CallbackState" + }, + "attempt": { + "type": "integer", + "format": "int32", + "description": "The number of attempts made to deliver the callback.\nThis number represents a minimum bound since the attempt is incremented after the callback request completes." + }, + "lastAttemptCompleteTime": { + "type": "string", + "format": "date-time", + "description": "The time when the last attempt completed." + }, + "lastAttemptFailure": { + "$ref": "#/definitions/v1Failure", + "description": "The last attempt's failure, if any." + }, + "nextAttemptScheduleTime": { + "type": "string", + "format": "date-time", + "description": "The time when the next attempt is scheduled." + }, + "blockedReason": { + "type": "string", + "description": "If the state is BLOCKED, blocked reason provides additional information." + } + }, + "description": "CallbackInfo contains the state of an attached workflow callback." + }, + "apiWorkflowV1CallbackInfoTrigger": { + "type": "object", + "properties": { + "workflowClosed": { + "$ref": "#/definitions/CallbackInfoWorkflowClosed" + } + } + }, "protobufAny": { "type": "object", "properties": { @@ -11249,6 +11383,14 @@ "canceledReason": { "type": "string", "description": "Set if activity cancelation was requested." + }, + "links": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/v1Link" + }, + "description": "Links to related entities, such as the entity that started this activity." } }, "description": "Information about a standalone activity." @@ -12092,51 +12234,6 @@ }, "description": "Callback to attach to various events in the system, e.g. workflow run completion." }, - "v1CallbackInfo": { - "type": "object", - "properties": { - "callback": { - "$ref": "#/definitions/v1Callback", - "description": "Information on how this callback should be invoked (e.g. its URL and type)." - }, - "trigger": { - "$ref": "#/definitions/CallbackInfoTrigger", - "description": "Trigger for this callback." - }, - "registrationTime": { - "type": "string", - "format": "date-time", - "description": "The time when the callback was registered." - }, - "state": { - "$ref": "#/definitions/v1CallbackState" - }, - "attempt": { - "type": "integer", - "format": "int32", - "description": "The number of attempts made to deliver the callback.\nThis number represents a minimum bound since the attempt is incremented after the callback request completes." - }, - "lastAttemptCompleteTime": { - "type": "string", - "format": "date-time", - "description": "The time when the last attempt completed." - }, - "lastAttemptFailure": { - "$ref": "#/definitions/v1Failure", - "description": "The last attempt's failure, if any." - }, - "nextAttemptScheduleTime": { - "type": "string", - "format": "date-time", - "description": "The time when the next attempt is scheduled." - }, - "blockedReason": { - "type": "string", - "description": "If the state is BLOCKED, blocked reason provides additional information." - } - }, - "description": "CallbackInfo contains the state of an attached workflow callback." - }, "v1CallbackState": { "type": "string", "enum": [ @@ -12865,6 +12962,14 @@ "type": "string", "format": "byte", "description": "Token for follow-on long-poll requests. Absent only if the activity is complete." + }, + "callbacks": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/definitions/apiActivityV1CallbackInfo" + }, + "description": "Callbacks attached to this activity execution and their current state." } } }, @@ -13102,7 +13207,7 @@ "type": "array", "items": { "type": "object", - "$ref": "#/definitions/v1CallbackInfo" + "$ref": "#/definitions/apiWorkflowV1CallbackInfo" } }, "pendingNexusOperations": { @@ -13684,7 +13789,7 @@ "type": "object", "$ref": "#/definitions/v1Link" }, - "description": "Links associated with the event." + "description": "Links to related entities, such as the entity that started this event's workflow." }, "principal": { "$ref": "#/definitions/v1Principal", @@ -13952,6 +14057,9 @@ }, "batchJob": { "$ref": "#/definitions/LinkBatchJob" + }, + "activity": { + "$ref": "#/definitions/LinkActivity" } }, "description": "Link can be associated with history events. It might contain information about an external entity\nrelated to the history event. For example, workflow A makes a Nexus call that starts workflow B:\nin this case, a history event in workflow A could contain a Link to the workflow started event in\nworkflow B, and vice-versa." @@ -16442,6 +16550,10 @@ "started": { "type": "boolean", "description": "If true, a new activity was started." + }, + "link": { + "$ref": "#/definitions/v1Link", + "description": "Link to the started activity." } } }, diff --git a/openapi/openapiv3.yaml b/openapi/openapiv3.yaml index c4ee8a0b6..b658789ca 100644 --- a/openapi/openapiv3.yaml +++ b/openapi/openapiv3.yaml @@ -8236,6 +8236,11 @@ components: canceledReason: type: string description: Set if activity cancelation was requested. + links: + type: array + items: + $ref: '#/components/schemas/Link' + description: Links to related entities, such as the entity that started this activity. description: Information about a standalone activity. ActivityExecutionListInfo: type: object @@ -9084,6 +9089,7 @@ components: - CALLBACK_STATE_SUCCEEDED - CALLBACK_STATE_BLOCKED type: string + description: The current state of the callback. format: enum attempt: type: integer @@ -9106,7 +9112,7 @@ components: blockedReason: type: string description: If the state is BLOCKED, blocked reason provides additional information. - description: CallbackInfo contains the state of an attached workflow callback. + description: CallbackInfo contains the state of an attached activity callback. CallbackInfo_Trigger: type: object properties: @@ -9912,6 +9918,11 @@ components: type: string description: Token for follow-on long-poll requests. Absent only if the activity is complete. format: bytes + callbacks: + type: array + items: + $ref: '#/components/schemas/CallbackInfo' + description: Callbacks attached to this activity execution and their current state. DescribeBatchOperationResponse: type: object properties: @@ -10730,7 +10741,7 @@ components: type: array items: $ref: '#/components/schemas/Link' - description: Links associated with the event. + description: Links to related entities, such as the entity that started this event's workflow. principal: allOf: - $ref: '#/components/schemas/Principal' @@ -10934,11 +10945,23 @@ components: $ref: '#/components/schemas/Link_WorkflowEvent' batchJob: $ref: '#/components/schemas/Link_BatchJob' + activity: + $ref: '#/components/schemas/Link_Activity' description: |- Link can be associated with history events. It might contain information about an external entity related to the history event. For example, workflow A makes a Nexus call that starts workflow B: in this case, a history event in workflow A could contain a Link to the workflow started event in workflow B, and vice-versa. + Link_Activity: + type: object + properties: + namespace: + type: string + activityId: + type: string + runId: + type: string + description: A link to an activity. Link_BatchJob: type: object properties: @@ -14299,6 +14322,20 @@ components: allOf: - $ref: '#/components/schemas/Priority' description: Priority metadata. + completionCallbacks: + type: array + items: + $ref: '#/components/schemas/Callback' + description: |- + Callbacks to be called by the server when this activity reaches a terminal state. + Callback addresses must be whitelisted in the server's dynamic configuration. + links: + type: array + items: + $ref: '#/components/schemas/Link' + description: |- + Links to be associated with the activity. Callbacks may also have associated links; + links already included with a callback should not be duplicated here. StartActivityExecutionResponse: type: object properties: @@ -14308,6 +14345,10 @@ components: started: type: boolean description: If true, a new activity was started. + link: + allOf: + - $ref: '#/components/schemas/Link' + description: Link to the started activity. StartBatchOperationRequest: type: object properties: diff --git a/temporal/api/activity/v1/message.proto b/temporal/api/activity/v1/message.proto index 37eeae33c..05881da31 100644 --- a/temporal/api/activity/v1/message.proto +++ b/temporal/api/activity/v1/message.proto @@ -15,6 +15,7 @@ import "google/protobuf/timestamp.proto"; import "temporal/api/common/v1/message.proto"; import "temporal/api/deployment/v1/message.proto"; import "temporal/api/enums/v1/activity.proto"; +import "temporal/api/enums/v1/common.proto"; import "temporal/api/enums/v1/workflow.proto"; import "temporal/api/failure/v1/message.proto"; import "temporal/api/taskqueue/v1/message.proto"; @@ -161,6 +162,9 @@ message ActivityExecutionInfo { // Set if activity cancelation was requested. string canceled_reason = 32; + + // Links to related entities, such as the entity that started this activity. + repeated temporal.api.common.v1.Link links = 33; } // Limited activity information returned in the list response. @@ -195,3 +199,38 @@ message ActivityExecutionListInfo { // This field is only populated if the activity is closed. google.protobuf.Duration execution_duration = 11; } + +// CallbackInfo contains the state of an attached activity callback. +message CallbackInfo { + // Trigger for when the activity is closed. + message ActivityClosed {} + + message Trigger { + oneof variant { + ActivityClosed activity_closed = 1; + } + } + + // Information on how this callback should be invoked (e.g. its URL and type). + temporal.api.common.v1.Callback callback = 1; + // Trigger for this callback. + Trigger trigger = 2; + // The time when the callback was registered. + google.protobuf.Timestamp registration_time = 3; + + // The current state of the callback. + temporal.api.enums.v1.CallbackState state = 4; + // The number of attempts made to deliver the callback. + // This number represents a minimum bound since the attempt is incremented after the callback request completes. + int32 attempt = 5; + + // The time when the last attempt completed. + google.protobuf.Timestamp last_attempt_complete_time = 6; + // The last attempt's failure, if any. + temporal.api.failure.v1.Failure last_attempt_failure = 7; + // The time when the next attempt is scheduled. + google.protobuf.Timestamp next_attempt_schedule_time = 8; + + // If the state is BLOCKED, blocked reason provides additional information. + string blocked_reason = 9; +} diff --git a/temporal/api/common/v1/message.proto b/temporal/api/common/v1/message.proto index 88c3a834e..419f08f68 100644 --- a/temporal/api/common/v1/message.proto +++ b/temporal/api/common/v1/message.proto @@ -240,9 +240,17 @@ message Link { string job_id = 1; } + // A link to an activity. + message Activity { + string namespace = 1; + string activity_id = 2; + string run_id = 3; + } + oneof variant { WorkflowEvent workflow_event = 1; BatchJob batch_job = 2; + Activity activity = 3; } } diff --git a/temporal/api/history/v1/message.proto b/temporal/api/history/v1/message.proto index cf866fcdd..2ffd893b1 100644 --- a/temporal/api/history/v1/message.proto +++ b/temporal/api/history/v1/message.proto @@ -1152,7 +1152,7 @@ message HistoryEvent { // * timer_started_event_attributes - summary represents an identifier for the timer for use by // user interfaces. temporal.api.sdk.v1.UserMetadata user_metadata = 301; - // Links associated with the event. + // Links to related entities, such as the entity that started this event's workflow. repeated temporal.api.common.v1.Link links = 302; // Server-computed authenticated caller identity associated with this event. temporal.api.common.v1.Principal principal = 303; diff --git a/temporal/api/workflowservice/v1/request_response.proto b/temporal/api/workflowservice/v1/request_response.proto index 0924c1aff..8580b7179 100644 --- a/temporal/api/workflowservice/v1/request_response.proto +++ b/temporal/api/workflowservice/v1/request_response.proto @@ -2931,6 +2931,12 @@ message StartActivityExecutionRequest { temporal.api.sdk.v1.UserMetadata user_metadata = 17; // Priority metadata. temporal.api.common.v1.Priority priority = 18; + // Callbacks to be called by the server when this activity reaches a terminal state. + // Callback addresses must be whitelisted in the server's dynamic configuration. + repeated temporal.api.common.v1.Callback completion_callbacks = 19; + // Links to be associated with the activity. Callbacks may also have associated links; + // links already included with a callback should not be duplicated here. + repeated temporal.api.common.v1.Link links = 20; } message StartActivityExecutionResponse { @@ -2938,6 +2944,8 @@ message StartActivityExecutionResponse { string run_id = 1; // If true, a new activity was started. bool started = 2; + // Link to the started activity. + temporal.api.common.v1.Link link = 3; } message DescribeActivityExecutionRequest { @@ -2974,6 +2982,9 @@ message DescribeActivityExecutionResponse { // Token for follow-on long-poll requests. Absent only if the activity is complete. bytes long_poll_token = 5; + + // Callbacks attached to this activity execution and their current state. + repeated temporal.api.activity.v1.CallbackInfo callbacks = 6; } message PollActivityExecutionRequest {