Skip to main content

Activity

Activities are defined as Protobuf RPCs annotated with the temporal.v1.activity method option. See the Activities guide for more usage details.

info

Activity definitions can omit an input and/or out parameter by specifying the native google.protobuf.Empty message type in its place. This requires an additional google/protobuf/empty.proto protobuf import.

example.proto
syntax="proto3";

package example.v1;

import "temporal/v1/temporal.proto";

service Example {
// Hello returns a friendly greeting
rpc Hello(HelloInput) returns (HelloOutput) {
option (temporal.v1.activity) = {
start_to_close_timeout: { seconds: 60 }
};
}
}

Options

heartbeat_timeout

google.protobuf.Duration

The maximum time allowed between Activity Heartbeats. See docs for more details.

service Example {
rpc Hello(HelloInput) returns (HelloOutput) {
option (temporal.v1.activity) = {
heartbeat_timeout: { seconds: 300 } // 5m
};
}
}

name

string

Fully qualified Activity type name. Defaults to protobuf method full name (e.g. example.v1.Example.Hello)

service Example {
rpc Hello(HelloInput) returns (HelloOutput) {
option (temporal.v1.activity) = {
name: "Hello"
};
}
}

retry_policy

temporal.v1.RetryPolicy

Optional retry policy for activity.

service Example {
rpc Hello(HelloInput) returns (HelloOutput) {
option (temporal.v1.activity) = {
retry_policy: {
max_attempts: 10
initial_interval: { seconds: 5 }
max_interval: { seconds: 60 }
backoff_coefficient: 2.0
non_retryable_error_types: ["SomeError", "SomeOtherError"]
}
};
}
}

schedule_to_close_timeout

google.protobuf.Duration

The maximum time allowed for the overall Activity Execution. At least one of schedule_to_close_timeout, schedule_to_start_timeout, or start_to_close_timeout is required. See docs for more details.

service Example {
rpc Hello(HelloInput) returns (HelloOutput) {
option (temporal.v1.activity) = {
schedule_to_close_timeout: { seconds: 10 }
};
}
}

schedule_to_start_timeout

google.protobuf.Duration

The maximum time allowed from when an Activity Task is scheduled to when a Worker starts the Activity Task. At least one of schedule_to_close_timeout, schedule_to_start_timeout, or start_to_close_timeout is required. See docs for more details.

service Example {
rpc Hello(HelloInput) returns (HelloOutput) {
option (temporal.v1.activity) = {
schedule_to_start_timeout: { seconds: 10 }
};
}
}

start_to_close_timeout

google.protobuf.Duration

The maximum time allowed for a single Activity Task Execution. At least one of schedule_to_close_timeout, schedule_to_start_timeout, or start_to_close_timeout is required. See docs for more details.

service Example {
rpc Hello(HelloInput) returns (HelloOutput) {
option (temporal.v1.activity) = {
start_to_close_timeout: { seconds: 10 }
};
}
}

wait_for_cancellation

bool

Whether to wait for canceled activity to be completed (activity can be failed, completed, cancel accepted). If true the Activity Execution will finish executing should there be a Cancellation request. Defaults to false.

service Example {
rpc Hello(HelloInput) returns (HelloOutput) {
option (temporal.v1.activity) = {
wait_for_cancellation: false
};
}
}

task_queue

string

Overrides the default task queue for a particular activity type. Defaults to Service's task_queue if specified.

service Example {
rpc Hello(HelloInput) returns (HelloOutput) {
option (temporal.v1.activity) = {
task_queue: "example-v2"
};
}
}