Documentation
¶
Overview ¶
Package durabletaskscheduler configures Durable Task Scheduler (DTS) management clients and workers.
Index ¶
- Constants
- Variables
- func ExecuteScheduleOperationOrchestrator(ctx *task.OrchestrationContext) (any, error)
- func NewWorker(options *Options, registry *task.TaskRegistry, logger api.Logger, ...) (*durabletaskclient.TaskHubGrpcWorker, error)
- func RegisterScheduledTasks(registry *task.TaskRegistry) error
- func RegisterScheduledTasksWithDefaultVersion(registry *task.TaskRegistry, defaultVersion string) error
- func WithScheduledTasks() durabletaskclient.TaskHubGrpcWorkerOption
- type AuthenticationType
- type Client
- type Options
- type ScheduleClient
- func (c *ScheduleClient) Create(ctx context.Context, options ScheduleCreationOptions) error
- func (c *ScheduleClient) Delete(ctx context.Context) error
- func (c *ScheduleClient) Describe(ctx context.Context) (*ScheduleDescription, error)
- func (c *ScheduleClient) ID() string
- func (c *ScheduleClient) Pause(ctx context.Context) error
- func (c *ScheduleClient) Resume(ctx context.Context) error
- func (c *ScheduleClient) Update(ctx context.Context, options ScheduleUpdateOptions) error
- type ScheduleCreationOptions
- type ScheduleDescription
- type ScheduleInvalidTransitionError
- type ScheduleNotFoundError
- type ScheduleOperationError
- type ScheduleOperationRequest
- type ScheduleQuery
- type ScheduleQueryResult
- type ScheduleRetryPolicy
- type ScheduleStatus
- type ScheduleUpdateOptions
- type ScheduleValidationError
- type ScheduledTaskClient
- func (c *ScheduledTaskClient) Create(ctx context.Context, options ScheduleCreationOptions) (*ScheduleClient, error)
- func (c *ScheduledTaskClient) Get(ctx context.Context, scheduleID string) (*ScheduleDescription, error)
- func (c *ScheduledTaskClient) GetScheduleClient(scheduleID string) (*ScheduleClient, error)
- func (c *ScheduledTaskClient) List(ctx context.Context, query ScheduleQuery) (*ScheduleQueryResult, error)
Constants ¶
const ( // DefaultResourceID is the public-cloud token audience for DTS. DefaultResourceID = "https://durabletask.io" // GovernmentResourceID is the token audience for DTS in US Government and DoD regions. GovernmentResourceID = "https://durabletask.azure.us" // DefaultMaxReceiveMessageSize and DefaultMaxSendMessageSize are the default // per-message gRPC bounds. DefaultMaxReceiveMessageSize = 64 * 1024 * 1024 DefaultMaxSendMessageSize = 64 * 1024 * 1024 // DefaultKeepaliveTime and DefaultKeepaliveTimeout configure pings while a // gRPC stream is active. DefaultKeepaliveTime = 2 * time.Minute DefaultKeepaliveTimeout = 20 * time.Second )
const ( // ScheduleEntityName is the system entity name used to persist schedules. ScheduleEntityName = "Schedule" // ExecuteScheduleOperationOrchestratorName is the system orchestrator used // for schedule mutations. ExecuteScheduleOperationOrchestratorName = "ExecuteScheduleOperationOrchestrator" // ExecuteScheduledTaskOrchestratorName applies orchestration-only options // such as tags, context fields, and retries to a scheduled target. ExecuteScheduledTaskOrchestratorName = "ExecuteScheduledTaskOrchestrator" )
Variables ¶
var ( // ErrScheduleNotFound identifies attempts to access a missing schedule. ErrScheduleNotFound = errors.New("schedule not found") // ErrScheduleInvalidTransition identifies invalid schedule state changes. ErrScheduleInvalidTransition = errors.New("invalid schedule state transition") // ErrScheduleValidation identifies invalid schedule configuration. ErrScheduleValidation = errors.New("invalid schedule configuration") // ErrScheduleOperationFailed identifies a failed schedule mutation. ErrScheduleOperationFailed = errors.New("schedule operation failed") )
Functions ¶
func ExecuteScheduleOperationOrchestrator ¶
func ExecuteScheduleOperationOrchestrator(ctx *task.OrchestrationContext) (any, error)
ExecuteScheduleOperationOrchestrator invokes one schedule entity operation. It must remain unversioned because schedule clients explicitly target the unversioned system orchestrator.
func NewWorker ¶
func NewWorker( options *Options, registry *task.TaskRegistry, logger api.Logger, workerOptions ...durabletaskclient.TaskHubGrpcWorkerOption, ) (*durabletaskclient.TaskHubGrpcWorker, error)
NewWorker creates a DTS worker that owns and recreates its gRPC connections. The returned worker connects and performs its fail-fast Hello in Start or Run.
func RegisterScheduledTasks ¶
func RegisterScheduledTasks(registry *task.TaskRegistry) error
RegisterScheduledTasks registers DTS's system schedule entity and operation orchestrator. The operation orchestrator is deliberately unversioned so it remains reachable when application default versioning is enabled.
func RegisterScheduledTasksWithDefaultVersion ¶
func RegisterScheduledTasksWithDefaultVersion(registry *task.TaskRegistry, defaultVersion string) error
RegisterScheduledTasksWithDefaultVersion registers scheduled-task system handlers and applies defaultVersion to scheduled target orchestrations that do not specify ScheduleCreationOptions.OrchestrationVersion.
func WithScheduledTasks ¶
func WithScheduledTasks() durabletaskclient.TaskHubGrpcWorkerOption
WithScheduledTasks advertises the DTS scheduled-task capability. Use it with RegisterScheduledTasks; registrations are then included by auto work-item filters derived from the registry.
Types ¶
type AuthenticationType ¶
type AuthenticationType string
const ( AuthenticationNone AuthenticationType = "None" AuthenticationDefaultAzure AuthenticationType = "DefaultAzure" AuthenticationManagedIdentity AuthenticationType = "ManagedIdentity" AuthenticationWorkloadIdentity AuthenticationType = "WorkloadIdentity" AuthenticationEnvironment AuthenticationType = "Environment" AuthenticationAzureCLI AuthenticationType = "AzureCLI" AuthenticationAzurePowerShell AuthenticationType = "AzurePowerShell" AuthenticationInteractiveBrowser AuthenticationType = "InteractiveBrowser" AuthenticationTokenCredential AuthenticationType = "TokenCredential" )
type Client ¶
type Client struct {
*durabletaskclient.TaskHubGrpcClient
// contains filtered or unexported fields
}
Client owns the management connection it creates.
func NewClient ¶
NewClient creates an independently owned management connection and validates it with a deadline-bound Hello call. A nil logger uses api.DefaultLogger.
func (*Client) ScheduledTasks ¶
func (c *Client) ScheduledTasks() *ScheduledTaskClient
ScheduledTasks returns a scheduled-task client backed by c.
type Options ¶
type Options struct {
EndpointAddress string
TaskHubName string
Authentication AuthenticationType
// Credential is required by, and valid only for, AuthenticationTokenCredential.
Credential azcore.TokenCredential
// ResourceID is a token audience URI, not an Azure Resource Manager path.
// Surrounding whitespace, trailing slashes, and one existing "/.default"
// suffix (case-insensitive) are removed before appending "/.default".
// Exactly empty selects GovernmentResourceID when REGION_NAME starts with
// usgov or usdod (case-insensitive), otherwise DefaultResourceID. Constructors
// resolve this default per options instance; hand-built or reset-empty
// options resolve it when creating a client or worker. Values that normalize
// to empty are rejected. This does not configure the endpoint or authority.
ResourceID string
// AuthorityHost optionally configures the Entra authority for SDK-created
// DefaultAzure, WorkloadIdentity, Environment, and InteractiveBrowser
// credentials. Empty preserves Azure Identity defaults, including
// AZURE_AUTHORITY_HOST. Other modes reject a nonempty value: configure an
// explicit Credential or developer tool directly; managed identity uses
// the hosting environment's identity endpoint.
AuthorityHost string
// ClientID is used by ManagedIdentity, WorkloadIdentity, and
// InteractiveBrowser. Other modes ignore it, except None and TokenCredential,
// which reject it.
ClientID string
// TenantID is used by DefaultAzure, WorkloadIdentity, AzureCLI,
// AzurePowerShell, and InteractiveBrowser. Environment and ManagedIdentity
// ignore it; None and TokenCredential reject it.
TenantID string
// TokenFilePath is used only by WorkloadIdentity. Other modes ignore it,
// except None and TokenCredential, which reject it.
TokenFilePath string
// AdditionallyAllowedTenants is used by DefaultAzure, WorkloadIdentity,
// AzureCLI, AzurePowerShell, and InteractiveBrowser. Environment reads
// AZURE_ADDITIONALLY_ALLOWED_TENANTS instead and ManagedIdentity ignores it;
// None and TokenCredential reject it. Empty entries are dropped.
AdditionallyAllowedTenants []string
// AllowInsecureConnection must be true to use an http:// endpoint. Plaintext
// connections are supported only when Authentication is None.
AllowInsecureConnection bool
// WorkerID overrides the generated worker identity. It is ignored by clients.
WorkerID string
// UserAgent overrides the x-user-agent metadata value.
UserAgent string
// HelloTimeout controls fail-fast connectivity checks.
HelloTimeout time.Duration
// MaxReceiveMessageSize and MaxSendMessageSize bound individual gRPC
// messages. Zero uses the 64 MiB SDK default.
MaxReceiveMessageSize int
MaxSendMessageSize int
// KeepaliveTime controls client pings while a gRPC stream is active. Zero
// disables keepalive, in which case KeepaliveTimeout is ignored.
// KeepaliveTimeout bounds each ping acknowledgement.
KeepaliveTime time.Duration
KeepaliveTimeout time.Duration
// MaximumTimerInterval limits one physical durable timer action. Longer
// timers are split deterministically. Zero uses the three-day default.
MaximumTimerInterval time.Duration
// ChannelRecreateFailureThreshold controls how many consecutive transport
// failures cause the owned management client to create a new gRPC channel.
// A non-positive value disables recreation. NewOptions defaults to 5.
ChannelRecreateFailureThreshold int
// ChannelRecreateMinInterval limits how often the owned management client
// attempts channel recreation. NewOptions defaults to 30 seconds.
ChannelRecreateMinInterval time.Duration
// UnaryInterceptors and StreamInterceptors are applied in order to every
// gRPC channel created for clients and workers, including replacements.
UnaryInterceptors []grpc.UnaryClientInterceptor
StreamInterceptors []grpc.StreamClientInterceptor
// LargePayloads enables external payload references for clients and workers.
LargePayloads *api.LargePayloadOptions
// Versioning configures worker version acceptance and the default version
// applied by both the client and worker.
Versioning *task.VersioningOptions
// DataConverter configures application payload serialization for both clients and workers.
DataConverter api.DataConverter
// contains filtered or unexported fields
}
Options configures connections to a Durable Task Scheduler endpoint.
func NewOptions ¶
func NewOptionsFromConnectionString ¶
NewOptionsFromConnectionString parses the DTS connection-string form:
Endpoint=<url>;TaskHub=<name>;Authentication=<type>
Keys and Authentication values are case-insensitive, surrounding whitespace is trimmed, empty segments are skipped, and a repeated key uses its last value. Supported optional keys are ResourceId, AuthorityHost, ClientID, TenantID, TokenFilePath, and the comma-separated AdditionallyAllowedTenants. ResourceId follows Options.ResourceID, including rejection of whitespace-only values.
func NewOptionsWithCredential ¶
func NewOptionsWithCredential(endpointAddress, taskHubName string, credential azcore.TokenCredential) *Options
type ScheduleClient ¶
type ScheduleClient struct {
// contains filtered or unexported fields
}
ScheduleClient manages one DTS schedule.
func (*ScheduleClient) Create ¶
func (c *ScheduleClient) Create(ctx context.Context, options ScheduleCreationOptions) error
Create creates or replaces this schedule.
func (*ScheduleClient) Delete ¶
func (c *ScheduleClient) Delete(ctx context.Context) error
Delete removes this schedule without affecting orchestration runs already started.
func (*ScheduleClient) Describe ¶
func (c *ScheduleClient) Describe(ctx context.Context) (*ScheduleDescription, error)
Describe returns the current schedule description.
func (*ScheduleClient) ID ¶
func (c *ScheduleClient) ID() string
ID returns the schedule identifier managed by this handle.
func (*ScheduleClient) Pause ¶
func (c *ScheduleClient) Pause(ctx context.Context) error
Pause stops future executions without affecting runs already started.
func (*ScheduleClient) Resume ¶
func (c *ScheduleClient) Resume(ctx context.Context) error
Resume restarts future executions.
func (*ScheduleClient) Update ¶
func (c *ScheduleClient) Update(ctx context.Context, options ScheduleUpdateOptions) error
Update applies a sparse configuration update.
type ScheduleCreationOptions ¶
type ScheduleCreationOptions struct {
ScheduleID string
OrchestrationName string
Interval time.Duration
OrchestrationInput string
TypedOrchestrationInput any
OrchestrationInstanceID string
OrchestrationVersion string
StartAt time.Time
EndAt time.Time
StartImmediatelyIfLate bool
Tags map[string]string
ContextFields api.ContextFields
RetryPolicy *ScheduleRetryPolicy
}
ScheduleCreationOptions configures a recurring interval schedule.
OrchestrationInput is already serialized input. TypedOrchestrationInput is serialized by the configured DataConverter and takes precedence when non-nil. Effective orchestration instance IDs must not use the reserved entity format. Retry-backed schedules generate separate instance IDs for each attempt. Cron schedules are not supported.
func (ScheduleCreationOptions) MarshalJSON ¶
func (o ScheduleCreationOptions) MarshalJSON() ([]byte, error)
func (*ScheduleCreationOptions) UnmarshalJSON ¶
func (o *ScheduleCreationOptions) UnmarshalJSON(data []byte) error
type ScheduleDescription ¶
type ScheduleDescription struct {
ScheduleID string
OrchestrationName string
OrchestrationInput string
OrchestrationInstanceID string
OrchestrationVersion string
StartAt time.Time
EndAt time.Time
Interval time.Duration
StartImmediatelyIfLate bool
Status ScheduleStatus
ExecutionToken string
LastRunAt time.Time
NextRunAt time.Time
CreatedAt time.Time
LastModifiedAt time.Time
Tags map[string]string
ContextFields api.ContextFields
RetryPolicy *ScheduleRetryPolicy
Converter api.DataConverter `json:"-"`
}
ScheduleDescription describes a schedule's current configuration and state.
func (*ScheduleDescription) ReadInput ¶
func (d *ScheduleDescription) ReadInput(target any) error
ReadInput deserializes the scheduled orchestration input.
type ScheduleInvalidTransitionError ¶
type ScheduleInvalidTransitionError struct {
ScheduleID string
From ScheduleStatus
To ScheduleStatus
Operation string
}
ScheduleInvalidTransitionError is returned for an invalid state transition.
func (*ScheduleInvalidTransitionError) DurableTaskErrorProperties ¶
func (e *ScheduleInvalidTransitionError) DurableTaskErrorProperties() map[string]any
func (*ScheduleInvalidTransitionError) DurableTaskErrorType ¶
func (*ScheduleInvalidTransitionError) DurableTaskErrorType() api.ErrorType
func (*ScheduleInvalidTransitionError) Error ¶
func (e *ScheduleInvalidTransitionError) Error() string
func (*ScheduleInvalidTransitionError) Unwrap ¶
func (e *ScheduleInvalidTransitionError) Unwrap() error
type ScheduleNotFoundError ¶
type ScheduleNotFoundError struct{ ScheduleID string }
ScheduleNotFoundError is returned when a schedule does not exist.
func (*ScheduleNotFoundError) Error ¶
func (e *ScheduleNotFoundError) Error() string
func (*ScheduleNotFoundError) Unwrap ¶
func (e *ScheduleNotFoundError) Unwrap() error
type ScheduleOperationError ¶
type ScheduleOperationError struct {
ScheduleID string
Operation string
RuntimeStatus api.OrchestrationStatus
FailureDetails *api.FailureDetails
}
ScheduleOperationError describes a schedule mutation orchestration that did not complete successfully.
func (*ScheduleOperationError) DurableTaskErrorType ¶
func (*ScheduleOperationError) DurableTaskErrorType() api.ErrorType
func (*ScheduleOperationError) Error ¶
func (e *ScheduleOperationError) Error() string
func (*ScheduleOperationError) Unwrap ¶
func (e *ScheduleOperationError) Unwrap() error
type ScheduleOperationRequest ¶
type ScheduleOperationRequest struct {
EntityID api.EntityID `json:"EntityId"`
OperationName string `json:"OperationName"`
Input any `json:"Input,omitempty"`
}
ScheduleOperationRequest is the input consumed by ExecuteScheduleOperationOrchestrator.
type ScheduleQuery ¶
type ScheduleQuery struct {
Status *ScheduleStatus
ScheduleIDPrefix string
// CreatedFrom is an exclusive lower creation-time bound, matching .NET.
CreatedFrom time.Time
// CreatedTo is an exclusive upper creation-time bound, matching .NET.
CreatedTo time.Time
PageSize int32
ContinuationToken string
}
ScheduleQuery filters a single page of schedules. Filters are applied after DTS returns the entity page, so a page can contain fewer than PageSize items.
type ScheduleQueryResult ¶
type ScheduleQueryResult struct {
Schedules []*ScheduleDescription
ContinuationToken string
}
ScheduleQueryResult is one page of schedules.
type ScheduleRetryPolicy ¶
type ScheduleRetryPolicy struct {
MaxAttempts int
InitialRetryInterval time.Duration
BackoffCoefficient float64
MaxRetryInterval time.Duration
RetryTimeout time.Duration
}
ScheduleRetryPolicy is the serializable subset of task.RetryPolicy used when a scheduled target orchestration fails.
type ScheduleStatus ¶
type ScheduleStatus int
ScheduleStatus is the persisted status of a schedule.
const ( ScheduleStatusUninitialized ScheduleStatus = iota ScheduleStatusActive ScheduleStatusPaused )
func (ScheduleStatus) String ¶
func (s ScheduleStatus) String() string
type ScheduleUpdateOptions ¶
type ScheduleUpdateOptions struct {
OrchestrationName *string
OrchestrationInput *string
TypedOrchestrationInput any
OrchestrationInstanceID *string
OrchestrationVersion *string
StartAt *time.Time
EndAt *time.Time
Interval *time.Duration
StartImmediatelyIfLate *bool
Tags map[string]string
ContextFields api.ContextFields
RetryPolicy *ScheduleRetryPolicy
}
ScheduleUpdateOptions applies a sparse update to a schedule. Nil pointers mean the corresponding field is unchanged. Empty string values are ignored. Nil maps leave stored values unchanged; non-nil empty maps clear them.
func (ScheduleUpdateOptions) MarshalJSON ¶
func (o ScheduleUpdateOptions) MarshalJSON() ([]byte, error)
func (*ScheduleUpdateOptions) UnmarshalJSON ¶
func (o *ScheduleUpdateOptions) UnmarshalJSON(data []byte) error
type ScheduleValidationError ¶
type ScheduleValidationError struct{ Message string }
ScheduleValidationError is returned when schedule options are invalid.
func (*ScheduleValidationError) DurableTaskErrorProperties ¶
func (e *ScheduleValidationError) DurableTaskErrorProperties() map[string]any
func (*ScheduleValidationError) DurableTaskErrorType ¶
func (*ScheduleValidationError) DurableTaskErrorType() api.ErrorType
func (*ScheduleValidationError) Error ¶
func (e *ScheduleValidationError) Error() string
func (*ScheduleValidationError) Unwrap ¶
func (e *ScheduleValidationError) Unwrap() error
type ScheduledTaskClient ¶
type ScheduledTaskClient struct {
// contains filtered or unexported fields
}
ScheduledTaskClient manages all schedules in a DTS task hub.
func NewScheduledTaskClient ¶
func NewScheduledTaskClient(client *durabletaskclient.TaskHubGrpcClient) *ScheduledTaskClient
NewScheduledTaskClient creates a scheduled-task client with the default JSON data converter.
func NewScheduledTaskClientWithDataConverter ¶
func NewScheduledTaskClientWithDataConverter( client *durabletaskclient.TaskHubGrpcClient, converter api.DataConverter, ) *ScheduledTaskClient
NewScheduledTaskClientWithDataConverter creates a scheduled-task client with an explicit data converter.
func (*ScheduledTaskClient) Create ¶
func (c *ScheduledTaskClient) Create(ctx context.Context, options ScheduleCreationOptions) (*ScheduleClient, error)
Create creates or replaces a schedule and returns its handle.
func (*ScheduledTaskClient) Get ¶
func (c *ScheduledTaskClient) Get(ctx context.Context, scheduleID string) (*ScheduleDescription, error)
Get returns nil, nil if scheduleID has no schedule.
func (*ScheduledTaskClient) GetScheduleClient ¶
func (c *ScheduledTaskClient) GetScheduleClient(scheduleID string) (*ScheduleClient, error)
GetScheduleClient returns a handle for scheduleID.
func (*ScheduledTaskClient) List ¶
func (c *ScheduledTaskClient) List(ctx context.Context, query ScheduleQuery) (*ScheduleQueryResult, error)
List returns one page of schedules matching query.