Skip to content
Draft
3 changes: 3 additions & 0 deletions temporal/api/command/v1/message.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import "temporal/api/enums/v1/command_type.proto";
import "temporal/api/common/v1/message.proto";
import "temporal/api/failure/v1/message.proto";
import "temporal/api/taskqueue/v1/message.proto";
import "temporal/api/session/v1/message.proto";
import "temporal/api/workflow/v1/message.proto";
import "temporal/api/sdk/v1/user_metadata.proto";
import "temporal/api/sdk/v1/event_group_marker.proto";
Expand Down Expand Up @@ -68,6 +69,8 @@ message ScheduleActivityTaskCommandAttributes {
// Priority metadata. If this message is not present, or any fields are not
// present, they inherit the values from the workflow.
temporal.api.common.v1.Priority priority = 14;

temporal.api.session.v1.ActivitySessionOptions session_options = 15;
}

message RequestCancelActivityTaskCommandAttributes {
Expand Down
4 changes: 4 additions & 0 deletions temporal/api/history/v1/message.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import "temporal/api/common/v1/message.proto";
import "temporal/api/deployment/v1/message.proto";
import "temporal/api/failure/v1/message.proto";
import "temporal/api/nexus/v1/message.proto";
import "temporal/api/session/v1/message.proto";
import "temporal/api/taskqueue/v1/message.proto";
import "temporal/api/update/v1/message.proto";
import "temporal/api/workflow/v1/message.proto";
Expand Down Expand Up @@ -465,6 +466,9 @@ message ActivityTaskScheduledEventAttributes {
// Priority metadata. If this message is not present, or any fields are not
// present, they inherit the values from the workflow.
temporal.api.common.v1.Priority priority = 14;
// Preserves the scheduling command's session routing options so activity state
// can be reconstructed from history.
temporal.api.session.v1.ActivitySessionOptions session_options = 15;
}

message ActivityTaskStartedEventAttributes {
Expand Down
57 changes: 57 additions & 0 deletions temporal/api/session/v1/message.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
syntax = "proto3";

package temporal.api.session.v1;

option go_package = "go.temporal.io/api/session/v1;session";
option java_package = "io.temporal.api.session.v1";
option java_multiple_files = true;
option java_outer_classname = "MessageProto";
option ruby_package = "Temporalio::Api::Session::V1";
option csharp_namespace = "Temporalio.Api.Session.V1";

import "google/protobuf/empty.proto";

// EXPERIMENTAL. Subject to redesign or removal.
// Sent on workflow and activity polls. Presence means this worker can serve
// sessions. Currently, the only supported Session type is Workflow Session
// (aka Workflow-as-Session). A Workflow Session can receive both workflow
// tasks and activity tasks of an execution.
message WorkerSessionOptions {
// Admission control, if unset the worker accepts an arbitrary number of
// sessions (bounded by session slots in the future)
oneof admission {
// If specified, the worker only polls for work belonging to its session.
SingleSessionOptions single_session = 1;
}
}

// EXPERIMENTAL. Subject to redesign or removal.
// Serve exactly one session for the worker's lifetime, including across
// process restarts with the same stable_identity. The server binds the worker
// to the first session that needs a worker, and dispatches no other work here,
// even after that session completes.
message SingleSessionOptions {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thomas: says that maybe we should think about what this is called if we wanna ActivitySessionOptions

  • another thing that he says is that we may not require to think about introducing this right now given that this is experimental

// Identity the binding is stored under. Required; must be non-empty.
// Reuse it across restarts of the same session, not across concurrently
// running workers. If multiple workers poll with the same stable_identity
// concurrently, the server treats them as pollers of a single worker and
// process affinity is lost.
//
// Note: this effectively acts as a configurable sticky queue.
// Note: we are currently unsure how this will evolve. May be deprecated as
// the session model develops.
string stable_identity = 1;
}

// EXPERIMENTAL. Subject to redesign or removal.
// Resolved activity placement. Unset = normal task-queue routing.
message ActivitySessionOptions {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i envision these options to be sent on the command attributes when we are going to schedule an activity task -- if that is the case, i wonder if we should have something defined or thought of for the stable identity piece (single session isolation) given that we seem to have thought this in the poll request structures

if not, then i wonder if we do even need the single session options defined in the general WorkerSessionOptions

oneof placement {
// Run in the workflow's current session (on its sticky queue).
// Currently requires the activity's task queue to be the workflow's,
// and the workflow's worker to serve sessions.
google.protobuf.Empty workflow_session = 1;

// Future: references to other types of sessions.
}
}
7 changes: 7 additions & 0 deletions temporal/api/workflowservice/v1/request_response.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import "temporal/api/replication/v1/message.proto";
import "temporal/api/rules/v1/message.proto";
import "temporal/api/sdk/v1/worker_config.proto";
import "temporal/api/schedule/v1/message.proto";
import "temporal/api/session/v1/message.proto";
import "temporal/api/taskqueue/v1/message.proto";
import "temporal/api/update/v1/message.proto";
import "temporal/api/version/v1/message.proto";
Expand Down Expand Up @@ -323,6 +324,9 @@ message PollWorkflowTaskQueueRequest {
// Removed in 1.55.0; was temporal.api.worker.v1.WorkerHeartbeat worker_heartbeat
reserved 7;
reserved "worker_heartbeat";

// EXPERIMENTAL. Subject to redesign or removal. Only applicable to sticky polls.
temporal.api.session.v1.WorkerSessionOptions session_options = 11;
}

message PollWorkflowTaskQueueResponse {
Expand Down Expand Up @@ -553,6 +557,9 @@ message PollActivityTaskQueueRequest {
// Removed in 1.55.0; was temporal.api.worker.v1.WorkerHeartbeat worker_heartbeat
reserved 7;
reserved "worker_heartbeat";

// EXPERIMENTAL. Subject to redesign or removal. Only applicable to sticky polls.
temporal.api.session.v1.WorkerSessionOptions session_options = 11;
}

message PollActivityTaskQueueResponse {
Expand Down
Loading