api

package
v1.0.0-beta2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 16 Imported by: 16

Documentation

Overview

Package api defines the public models, options, errors, and extension contracts shared by Durable Task Scheduler clients, workers, and task code.

Index

Constants

View Source
const (
	DefaultHistoryMaxEvents = 100_000
	MaxHistoryMaxEvents     = 1_000_000
	DefaultHistoryMaxBytes  = 64 * 1024 * 1024
	MaxHistoryMaxBytes      = 1024 * 1024 * 1024
)
View Source
const (
	DefaultLargePayloadThresholdBytes     = 64 * 1024
	DefaultLargePayloadMaxBytes           = 64 * 1024 * 1024
	DefaultAzureBlobPayloadThresholdBytes = 256 * 1024
	DefaultAzureBlobPayloadMaxBytes       = 10 * 1024 * 1024
	DurableTaskPayloadReferencePrefix     = "durabletask-payload:v1:"
	AzureBlobPayloadReferencePrefixV1     = "blob:v1:"
	AzureBlobPayloadReferencePrefixV2     = "blob:v2:"
)
View Source
const (
	DefaultInstanceQueryPageSize = 100
	MaxInstanceQueryPageSize     = 1000
	MaxRemoteTagFilterScanPages  = 100
	MaxInstanceBatchSize         = 500
	DefaultPurgePollInterval     = 100 * time.Millisecond
)
View Source
const MaxFailureDetailsDepth = 32

MaxFailureDetailsDepth bounds failure chains in JSON and protobuf payloads.

View Source
const ReservedContextFieldPrefix = "__durabletask.context."

ReservedContextFieldPrefix is reserved for Durable Task runtime identity tags.

Variables

View Source
var (
	// ErrEntityStateNotIncluded indicates that entity state was excluded from a metadata response.
	ErrEntityStateNotIncluded = errors.New("entity state was not included")
	// ErrEntityHasNoState indicates that an entity metadata response contains no application state.
	ErrEntityHasNoState = errors.New("entity has no state")
)
View Source
var (
	ErrInvalidArgument   = errors.New("invalid argument")
	ErrTaskNotRegistered = errors.New("task is not registered")
	ErrVersionMismatch   = errors.New("task version is incompatible with this worker")
)
View Source
var (
	ErrLargePayloadTooLarge  = errors.New("large payload exceeds the configured size limit")
	ErrLargePayloadReference = errors.New("invalid large payload reference")
	ErrLargePayloadIntegrity = errors.New("large payload integrity check failed")
)
View Source
var (
	ErrInstanceNotFound  = errors.New("no such instance exists")
	ErrNotCompleted      = errors.New("orchestration has not yet completed")
	ErrDuplicateInstance = errors.New("orchestration instance already exists")
	ErrInvalidState      = errors.New("orchestration is not in a valid state for this operation")

	EmptyInstanceID = InstanceID("")
)
View Source
var ErrFeatureNotSupported = errors.New("feature is not supported")

ErrFeatureNotSupported identifies a limitation in the SDK or service. The surrounding error describes which operation or history shape is unsupported.

View Source
var ErrHistoryLimitExceeded = errors.New("orchestration history exceeds the configured event limit")

Functions

func ContextWithFields

func ContextWithFields(ctx context.Context, fields ContextFields) context.Context

ContextWithFields merges fields with any fields already in ctx, with fields taking precedence on conflicts. The stored map is a defensive copy.

func IsLargePayloadReference

func IsLargePayloadReference(value string) bool

IsLargePayloadReference reports whether value uses a reserved Durable Task large-payload reference prefix. Recognized values must be validated and resolved rather than treated as application data.

func NormalizeInstanceQueryPageSize

func NormalizeInstanceQueryPageSize(pageSize int) (int, error)

func SerializeData

func SerializeData(converter DataConverter, value any) (string, error)

SerializeData serializes a typed payload and rejects an empty encoding, which cannot be distinguished from an absent payload across all protocol surfaces.

func ValidateTimeRange

func ValidateTimeRange(from, to time.Time) error

func WithActivityContextInfo

func WithActivityContextInfo(ctx context.Context, info ActivityContextInfo) context.Context

WithActivityContextInfo returns a context containing activity identity.

func WithEntityContextInfo

func WithEntityContextInfo(ctx context.Context, info EntityContextInfo) context.Context

WithEntityContextInfo returns a context containing entity operation identity.

func WithOrchestrationContextInfo

func WithOrchestrationContextInfo(ctx context.Context, info OrchestrationContextInfo) context.Context

WithOrchestrationContextInfo returns a context containing orchestration identity.

func WrapInvalidArgument

func WrapInvalidArgument(err error) error

WrapInvalidArgument classifies an argument validation error without losing its cause.

Types

type ActivityContextInfo

type ActivityContextInfo struct {
	InstanceID InstanceID
	Name       string
	Version    string
	TaskID     int32
}

ActivityContextInfo identifies the activity associated with a task context.

func ActivityContextInfoFromContext

func ActivityContextInfoFromContext(ctx context.Context) (ActivityContextInfo, bool)

ActivityContextInfoFromContext returns activity identity from ctx.

type CleanEntityStorageOptions

type CleanEntityStorageOptions struct {
	// ContinuationToken for resuming a previous cleanup operation.
	ContinuationToken string
	// PreserveEmptyEntities disables removal of entities with no state and no locks.
	PreserveEmptyEntities bool
	// PreserveOrphanedLocks disables release of locks held by non-running orchestrations.
	PreserveOrphanedLocks bool
	// SinglePage returns after one backend cleanup request.
	SinglePage bool
}

CleanEntityStorageOptions controls entity storage cleanup. The zero value removes empty entities, releases orphaned locks, and continues to completion.

type CleanEntityStorageResult

type CleanEntityStorageResult struct {
	// EmptyEntitiesRemoved is the number of empty entities removed.
	EmptyEntitiesRemoved int32
	// OrphanedLocksReleased is the number of orphaned locks released.
	OrphanedLocksReleased int32
	// ContinuationToken for resuming cleanup. Empty if complete.
	ContinuationToken string
}

CleanEntityStorageResult contains the results of a cleanup operation.

type ContextFields

type ContextFields map[string]string

ContextFields are immutable caller-supplied values propagated into task contexts.

func ContextFieldsFromContext

func ContextFieldsFromContext(ctx context.Context) ContextFields

ContextFieldsFromContext returns a defensive copy of caller-supplied fields.

type DataConverter

type DataConverter interface {
	Serialize(value any) (string, error)
	Deserialize(payload string, target any) error
}

DataConverter serializes application payloads into the text fields used by the Durable Task protocol. Implementations must return valid UTF-8, be deterministic, and be safe for concurrent use. Because converter identity is not stored in the protocol, replacements must remain able to decode payloads written by earlier deployments.

func DefaultDataConverter

func DefaultDataConverter() DataConverter

DefaultDataConverter returns the converter used when none is configured.

func NormalizeDataConverter

func NormalizeDataConverter(converter DataConverter) DataConverter

NormalizeDataConverter returns the default JSON converter for nil inputs.

type DurableTaskErrorPropertiesProvider

type DurableTaskErrorPropertiesProvider interface {
	DurableTaskErrorProperties() map[string]any
}

DurableTaskErrorPropertiesProvider supplies additional serializable failure properties.

type DurableTaskErrorTypeProvider

type DurableTaskErrorTypeProvider interface {
	DurableTaskErrorType() ErrorType
}

DurableTaskErrorTypeProvider supplies a stable cross-language error type.

type DurableTaskFailureDetailsProvider

type DurableTaskFailureDetailsProvider interface {
	DurableTaskFailureDetails() *FailureDetails
}

DurableTaskFailureDetailsProvider supplies failure details already received from durable history.

type DurableTaskStackTraceProvider

type DurableTaskStackTraceProvider interface {
	DurableTaskStackTrace() string
}

DurableTaskStackTraceProvider supplies a stack trace for a failure.

type EntityContextInfo

type EntityContextInfo struct {
	EntityID  EntityID
	Operation string
	RequestID string
	IsSignal  bool
}

EntityContextInfo identifies the entity operation associated with a task context.

func EntityContextInfoFromContext

func EntityContextInfoFromContext(ctx context.Context) (EntityContextInfo, bool)

EntityContextInfoFromContext returns entity operation identity from ctx.

type EntityID

type EntityID struct {
	Name string
	Key  string
}

EntityID uniquely identifies an entity by its name and key.

func EntityIDFromString

func EntityIDFromString(s string) (EntityID, error)

EntityIDFromString parses an entity instance ID string in the format "@<name>@<key>".

func NewEntityID

func NewEntityID(name string, key string) EntityID

NewEntityID creates a new EntityID with the specified name and key.

func (EntityID) MarshalJSON

func (e EntityID) MarshalJSON() ([]byte, error)

MarshalJSON serializes entity IDs using the cross-SDK compact instance ID format.

func (EntityID) String

func (e EntityID) String() string

String returns the entity instance ID in the format "@<name>@<key>".

func (*EntityID) UnmarshalJSON

func (e *EntityID) UnmarshalJSON(data []byte) error

UnmarshalJSON parses an entity ID from the cross-SDK compact instance ID format.

type EntityMetadata

type EntityMetadata struct {
	InstanceID       EntityID
	LastModifiedTime time.Time
	BacklogQueueSize int32
	LockedBy         string
	StateIncluded    bool
	HasState         bool
	SerializedState  string
	Converter        DataConverter `json:"-"`
}

EntityMetadata contains metadata about an entity instance.

func (*EntityMetadata) ReadState

func (m *EntityMetadata) ReadState(target any) error

ReadState deserializes entity state with the metadata converter.

type EntityQuery

type EntityQuery struct {
	// InstanceIDStartsWith filters entities whose instance ID starts with this prefix.
	InstanceIDStartsWith string
	// LastModifiedFrom filters entities modified on or after this time.
	LastModifiedFrom time.Time
	// LastModifiedTo filters entities modified before this time.
	LastModifiedTo time.Time
	// ExcludeState omits entity state from the results. State is included by default.
	ExcludeState bool
	// IncludeTransient whether to include transient (stateless) entities.
	IncludeTransient bool
	// PageSize limits the number of entities returned per page.
	PageSize int32
	// ContinuationToken for fetching the next page of results.
	ContinuationToken string
}

EntityQuery defines filter criteria for querying entities.

type EntityQueryResults

type EntityQueryResults struct {
	Entities          []*EntityMetadata
	ContinuationToken string
}

EntityQueryResults contains the results of an entity query.

type ErrorPropertiesProvider

type ErrorPropertiesProvider interface {
	ErrorProperties(error) map[string]any
}

ErrorPropertiesProvider enriches failures without requiring application errors to implement an interface.

type ErrorPropertiesProviderFunc

type ErrorPropertiesProviderFunc func(error) map[string]any

ErrorPropertiesProviderFunc adapts a function into an ErrorPropertiesProvider.

func (ErrorPropertiesProviderFunc) ErrorProperties

func (provider ErrorPropertiesProviderFunc) ErrorProperties(err error) map[string]any

type ErrorType

type ErrorType string

ErrorType is a stable cross-language durable failure identifier.

const (
	ErrorTypeActivityTaskNotFound         ErrorType = "ActivityTaskNotFound"
	ErrorTypeEntityTaskNotFound           ErrorType = "EntityTaskNotFound"
	ErrorTypeOrchestratorTaskNotFound     ErrorType = "OrchestratorTaskNotFound"
	ErrorTypeTaskFailed                   ErrorType = "TaskFailedException"
	ErrorTypeEntityOperationFailed        ErrorType = "EntityOperationFailedException"
	ErrorTypeVersionMismatch              ErrorType = "VersionMismatch"
	ErrorTypeVersionError                 ErrorType = "VersionError"
	ErrorTypeHistoryLimitExceeded         ErrorType = "HistoryLimitExceeded"
	ErrorTypeOrchestratorResponseTooLarge ErrorType = "OrchestratorResponseTooLarge"
	ErrorTypeActivityPanic                ErrorType = "TaskActivityPanic"
	ErrorTypeEntityOperationPanic         ErrorType = "EntityOperationPanic"
	ErrorTypeOrchestratorPanic            ErrorType = "OrchestratorPanic"
)

type FailureDetails

type FailureDetails struct {
	ErrorType      ErrorType       `json:"type"`
	ErrorMessage   string          `json:"message"`
	StackTrace     string          `json:"stackTrace,omitempty"`
	InnerFailure   *FailureDetails `json:"innerFailure,omitempty"`
	IsNonRetriable bool            `json:"isNonRetriable,omitempty"`
	Properties     map[string]any  `json:"properties,omitempty"`
}

FailureDetails describes a durable failure that can cross process and language boundaries.

func (*FailureDetails) IsCausedBy

func (d *FailureDetails) IsCausedBy(errorTypes ...ErrorType) bool

IsCausedBy reports whether this failure chain contains one of the supplied wire error types.

func (*FailureDetails) MarshalJSON

func (d *FailureDetails) MarshalJSON() ([]byte, error)

func (*FailureDetails) Matches

func (d *FailureDetails) Matches(target error) bool

Matches reports whether this failure chain belongs to a stable Go error category.

func (*FailureDetails) NonRetriable

func (d *FailureDetails) NonRetriable() bool

NonRetriable reports whether this failure frame must not be retried.

func (*FailureDetails) String

func (d *FailureDetails) String() string

func (*FailureDetails) UnmarshalJSON

func (d *FailureDetails) UnmarshalJSON(data []byte) error

type FetchOrchestrationMetadataOptions added in v0.1.1

type FetchOrchestrationMetadataOptions func(*protos.GetInstanceRequest)

FetchOrchestrationMetadataOptions configures orchestration metadata retrieval.

func WithFetchPayloads added in v0.1.1

func WithFetchPayloads(fetchPayloads bool) FetchOrchestrationMetadataOptions

WithFetchPayloads configures whether to load orchestration inputs, outputs, and custom status values, which could be large.

type GetEntityOptions

type GetEntityOptions struct {
	ExcludeState bool
}

GetEntityOptions controls an entity metadata request. The zero value includes state.

type HistoryEntityEvent

type HistoryEntityEvent struct {
	RequestID         string          `json:"requestId,omitempty"`
	Operation         string          `json:"operation,omitempty"`
	TargetInstanceID  string          `json:"targetInstanceId,omitempty"`
	ParentInstanceID  string          `json:"parentInstanceId,omitempty"`
	ParentExecutionID string          `json:"parentExecutionId,omitempty"`
	ScheduledAt       time.Time       `json:"scheduledAt,omitempty"`
	CriticalSectionID string          `json:"criticalSectionId,omitempty"`
	LockSet           []string        `json:"lockSet,omitempty"`
	Position          int32           `json:"position,omitempty"`
	SerializedInput   string          `json:"serializedInput,omitempty"`
	SerializedOutput  string          `json:"serializedOutput,omitempty"`
	FailureDetails    *FailureDetails `json:"failureDetails,omitempty"`
}

type HistoryEvent

type HistoryEvent struct {
	Type      HistoryEventType `json:"type"`
	EventID   int32            `json:"eventId"`
	Timestamp time.Time        `json:"timestamp"`
	// UnknownType identifies a wire event type that this SDK does not yet
	// understand. It is diagnostic and populated only for HistoryEventUnknown.
	UnknownType string `json:"unknownType,omitempty"`

	ExecutionStarted                  *HistoryExecutionStartedEvent                `json:"executionStarted,omitempty"`
	ExecutionCompleted                *HistoryExecutionCompletedEvent              `json:"executionCompleted,omitempty"`
	ExecutionTerminated               *HistoryExecutionTerminatedEvent             `json:"executionTerminated,omitempty"`
	TaskScheduled                     *HistoryTaskScheduledEvent                   `json:"taskScheduled,omitempty"`
	TaskCompleted                     *HistoryTaskResultEvent                      `json:"taskCompleted,omitempty"`
	TaskFailed                        *HistoryTaskFailureEvent                     `json:"taskFailed,omitempty"`
	SubOrchestrationInstanceCreated   *HistorySubOrchestrationInstanceCreatedEvent `json:"subOrchestrationInstanceCreated,omitempty"`
	SubOrchestrationInstanceCompleted *HistoryTaskResultEvent                      `json:"subOrchestrationInstanceCompleted,omitempty"`
	SubOrchestrationInstanceFailed    *HistoryTaskFailureEvent                     `json:"subOrchestrationInstanceFailed,omitempty"`
	TimerCreated                      *HistoryTimerEvent                           `json:"timerCreated,omitempty"`
	TimerFired                        *HistoryTimerFiredEvent                      `json:"timerFired,omitempty"`
	EventSent                         *HistoryExternalEvent                        `json:"eventSent,omitempty"`
	EventRaised                       *HistoryExternalEvent                        `json:"eventRaised,omitempty"`
	Generic                           *HistoryPayloadEvent                         `json:"generic,omitempty"`
	HistoryState                      *HistoryStateEvent                           `json:"historyState,omitempty"`
	ContinueAsNew                     *HistoryPayloadEvent                         `json:"continueAsNew,omitempty"`
	ExecutionSuspended                *HistoryPayloadEvent                         `json:"executionSuspended,omitempty"`
	ExecutionResumed                  *HistoryPayloadEvent                         `json:"executionResumed,omitempty"`
	Entity                            *HistoryEntityEvent                          `json:"entity,omitempty"`
	ExecutionRewound                  *HistoryExecutionRewoundEvent                `json:"executionRewound,omitempty"`

	Converter DataConverter `json:"-"`
}

HistoryEvent is one API-owned durable history record. Exactly one detail field is populated for event types that carry details.

func (*HistoryEvent) ReadData

func (e *HistoryEvent) ReadData(target any) error

ReadData deserializes a generic event payload.

func (*HistoryEvent) ReadInput

func (e *HistoryEvent) ReadInput(target any) error

ReadInput deserializes the input-like payload carried by this event. Events without an input payload leave target unchanged and return nil.

func (*HistoryEvent) ReadResult

func (e *HistoryEvent) ReadResult(target any) error

ReadResult deserializes the result/output payload carried by this event. Events without a result payload leave target unchanged and return nil.

type HistoryEventHandler

type HistoryEventHandler func(*HistoryEvent) error

HistoryEventHandler receives events in storage/service order.

type HistoryEventType

type HistoryEventType string

HistoryEventType identifies the durable event represented by a HistoryEvent.

const (
	HistoryEventUnknown                           HistoryEventType = "Unknown"
	HistoryEventExecutionStarted                  HistoryEventType = "ExecutionStarted"
	HistoryEventExecutionCompleted                HistoryEventType = "ExecutionCompleted"
	HistoryEventExecutionTerminated               HistoryEventType = "ExecutionTerminated"
	HistoryEventTaskScheduled                     HistoryEventType = "TaskScheduled"
	HistoryEventTaskCompleted                     HistoryEventType = "TaskCompleted"
	HistoryEventTaskFailed                        HistoryEventType = "TaskFailed"
	HistoryEventSubOrchestrationInstanceCreated   HistoryEventType = "SubOrchestrationInstanceCreated"
	HistoryEventSubOrchestrationInstanceCompleted HistoryEventType = "SubOrchestrationInstanceCompleted"
	HistoryEventSubOrchestrationInstanceFailed    HistoryEventType = "SubOrchestrationInstanceFailed"
	HistoryEventTimerCreated                      HistoryEventType = "TimerCreated"
	HistoryEventTimerFired                        HistoryEventType = "TimerFired"
	HistoryEventOrchestratorStarted               HistoryEventType = "OrchestratorStarted"
	HistoryEventOrchestratorCompleted             HistoryEventType = "OrchestratorCompleted"
	HistoryEventEventSent                         HistoryEventType = "EventSent"
	HistoryEventEventRaised                       HistoryEventType = "EventRaised"
	HistoryEventGeneric                           HistoryEventType = "Generic"
	HistoryEventHistoryState                      HistoryEventType = "HistoryState"
	HistoryEventContinueAsNew                     HistoryEventType = "ContinueAsNew"
	HistoryEventExecutionSuspended                HistoryEventType = "ExecutionSuspended"
	HistoryEventExecutionResumed                  HistoryEventType = "ExecutionResumed"
	HistoryEventEntityOperationSignaled           HistoryEventType = "EntityOperationSignaled"
	HistoryEventEntityOperationCalled             HistoryEventType = "EntityOperationCalled"
	HistoryEventEntityOperationCompleted          HistoryEventType = "EntityOperationCompleted"
	HistoryEventEntityOperationFailed             HistoryEventType = "EntityOperationFailed"
	HistoryEventEntityLockRequested               HistoryEventType = "EntityLockRequested"
	HistoryEventEntityLockGranted                 HistoryEventType = "EntityLockGranted"
	HistoryEventEntityUnlockSent                  HistoryEventType = "EntityUnlockSent"
	HistoryEventExecutionRewound                  HistoryEventType = "ExecutionRewound"
)

type HistoryExecutionCompletedEvent

type HistoryExecutionCompletedEvent struct {
	RuntimeStatus    OrchestrationStatus `json:"runtimeStatus"`
	SerializedResult string              `json:"serializedResult,omitempty"`
	FailureDetails   *FailureDetails     `json:"failureDetails,omitempty"`
}

type HistoryExecutionRewoundEvent

type HistoryExecutionRewoundEvent struct {
	Reason             string                     `json:"reason,omitempty"`
	Name               string                     `json:"name,omitempty"`
	Version            string                     `json:"version,omitempty"`
	InstanceID         InstanceID                 `json:"instanceId,omitempty"`
	ParentExecutionID  string                     `json:"parentExecutionId,omitempty"`
	SerializedInput    string                     `json:"serializedInput,omitempty"`
	Parent             *HistoryParentInstanceInfo `json:"parent,omitempty"`
	ParentTraceContext *HistoryTraceContext       `json:"parentTraceContext,omitempty"`
	Tags               map[string]string          `json:"tags,omitempty"`
	ContextFields      ContextFields              `json:"contextFields,omitempty"`
}

type HistoryExecutionStartedEvent

type HistoryExecutionStartedEvent struct {
	Name                string                     `json:"name"`
	Version             string                     `json:"version,omitempty"`
	InstanceID          InstanceID                 `json:"instanceId"`
	ExecutionID         string                     `json:"executionId,omitempty"`
	SerializedInput     string                     `json:"serializedInput,omitempty"`
	ScheduledStartAt    time.Time                  `json:"scheduledStartAt,omitempty"`
	Parent              *HistoryParentInstanceInfo `json:"parent,omitempty"`
	ParentTraceContext  *HistoryTraceContext       `json:"parentTraceContext,omitempty"`
	OrchestrationSpanID string                     `json:"orchestrationSpanId,omitempty"`
	Tags                map[string]string          `json:"tags,omitempty"`
	ContextFields       ContextFields              `json:"contextFields,omitempty"`
}

type HistoryExecutionTerminatedEvent

type HistoryExecutionTerminatedEvent struct {
	SerializedInput string `json:"serializedInput,omitempty"`
	Recursive       bool   `json:"recursive"`
}

type HistoryExternalEvent

type HistoryExternalEvent struct {
	InstanceID      InstanceID `json:"instanceId,omitempty"`
	Name            string     `json:"name"`
	SerializedInput string     `json:"serializedInput,omitempty"`
}

type HistoryParentInstanceInfo

type HistoryParentInstanceInfo struct {
	Name            string     `json:"name,omitempty"`
	Version         string     `json:"version,omitempty"`
	InstanceID      InstanceID `json:"instanceId,omitempty"`
	ExecutionID     string     `json:"executionId,omitempty"`
	TaskScheduledID int32      `json:"taskScheduledId"`
}

type HistoryPayloadEvent

type HistoryPayloadEvent struct {
	SerializedInput string `json:"serializedInput,omitempty"`
}

type HistoryQuery

type HistoryQuery struct {
	// ExecutionID selects a specific execution. Empty selects the service's
	// current execution. GetOrchestrationHistory verifies a nonempty selection
	// against ExecutionStarted events and rejects missing or conflicting IDs.
	ExecutionID string
	// MaxEvents bounds the buffered GetOrchestrationHistory result. It is
	// validated but ignored by StreamOrchestrationHistory, which does not retain
	// events. Zero uses DefaultHistoryMaxEvents.
	MaxEvents int
	// MaxBytes bounds the approximate in-memory size of the buffered
	// GetOrchestrationHistory result. It is ignored by
	// StreamOrchestrationHistory. Zero uses DefaultHistoryMaxBytes.
	MaxBytes int
}

HistoryQuery configures an orchestration history read.

func NormalizeHistoryQuery

func NormalizeHistoryQuery(query HistoryQuery) (HistoryQuery, error)

NormalizeHistoryQuery validates a history query and applies defaults.

type HistoryStateEvent

type HistoryStateEvent struct {
	State *OrchestrationMetadata `json:"state,omitempty"`
}

type HistorySubOrchestrationInstanceCreatedEvent

type HistorySubOrchestrationInstanceCreatedEvent struct {
	InstanceID         InstanceID           `json:"instanceId"`
	Name               string               `json:"name"`
	Version            string               `json:"version,omitempty"`
	SerializedInput    string               `json:"serializedInput,omitempty"`
	ParentTraceContext *HistoryTraceContext `json:"parentTraceContext,omitempty"`
	Tags               map[string]string    `json:"tags,omitempty"`
	ContextFields      ContextFields        `json:"contextFields,omitempty"`
}

type HistoryTaskFailureEvent

type HistoryTaskFailureEvent struct {
	TaskScheduledID int32           `json:"taskScheduledId"`
	FailureDetails  *FailureDetails `json:"failureDetails,omitempty"`
}

type HistoryTaskResultEvent

type HistoryTaskResultEvent struct {
	TaskScheduledID  int32  `json:"taskScheduledId"`
	SerializedResult string `json:"serializedResult,omitempty"`
}

type HistoryTaskScheduledEvent

type HistoryTaskScheduledEvent struct {
	Name               string               `json:"name"`
	Version            string               `json:"version,omitempty"`
	SerializedInput    string               `json:"serializedInput,omitempty"`
	ParentTraceContext *HistoryTraceContext `json:"parentTraceContext,omitempty"`
	Tags               map[string]string    `json:"tags,omitempty"`
	ContextFields      ContextFields        `json:"contextFields,omitempty"`
}

type HistoryTimerEvent

type HistoryTimerEvent struct {
	FireAt time.Time `json:"fireAt"`
}

type HistoryTimerFiredEvent

type HistoryTimerFiredEvent struct {
	FireAt  time.Time `json:"fireAt"`
	TimerID int32     `json:"timerId"`
}

type HistoryTraceContext

type HistoryTraceContext struct {
	TraceParent string `json:"traceParent,omitempty"`
	TraceState  string `json:"traceState,omitempty"`
	SpanID      string `json:"spanId,omitempty"`
}

type InclusiveLargePayloadThreshold

type InclusiveLargePayloadThreshold interface {
	UsesInclusiveLargePayloadThreshold() bool
}

InclusiveLargePayloadThreshold identifies stores whose threshold includes payloads exactly equal to the configured threshold.

type InstanceID

type InstanceID string

InstanceID is a unique identifier for an orchestration instance.

type InstanceIDQuery

type InstanceIDQuery struct {
	RuntimeStatus     []OrchestrationStatus
	CompletedTimeFrom time.Time
	CompletedTimeTo   time.Time
	PageSize          int
	ContinuationToken string
}

InstanceIDQuery describes a bounded query that returns only instance IDs.

type InstanceIDQueryResult

type InstanceIDQueryResult struct {
	InstanceIDs       []InstanceID
	ContinuationToken string
}

type JSONDataConverter

type JSONDataConverter struct{}

JSONDataConverter preserves the SDK's standard encoding/json payload format.

func (JSONDataConverter) Deserialize

func (JSONDataConverter) Deserialize(payload string, target any) error

func (JSONDataConverter) Serialize

func (JSONDataConverter) Serialize(value any) (string, error)

type LargePayloadDefaults

type LargePayloadDefaults interface {
	LargePayloadDefaults() (thresholdBytes, maxPayloadBytes int)
}

LargePayloadDefaults supplies storage-specific defaults to use when an option is omitted. It is intentionally optional to preserve legacy defaults.

type LargePayloadOptions

type LargePayloadOptions struct {
	Store      LargePayloadStore
	Resolver   LargePayloadResolver
	TokenStore LargePayloadTokenStore
	// ThresholdBytes uses storage-specific defaults when zero.
	ThresholdBytes int
	// MaxPayloadBytes uses storage-specific defaults when zero.
	MaxPayloadBytes int
}

LargePayloadOptions configures payload externalization and hydration.

func NormalizeLargePayloadOptions

func NormalizeLargePayloadOptions(options *LargePayloadOptions) (*LargePayloadOptions, error)

NormalizeLargePayloadOptions validates options and applies generic or store-specific defaults. A nil input returns nil, nil.

type LargePayloadOptionsValidator

type LargePayloadOptionsValidator interface {
	ValidateLargePayloadOptions(thresholdBytes, maxPayloadBytes int) error
}

LargePayloadOptionsValidator performs store-specific option validation after defaults are applied.

type LargePayloadResolver

type LargePayloadResolver interface {
	Resolve(context.Context, string) ([]byte, error)
}

LargePayloadResolver resolves payload bytes from an opaque, untrusted location. Implementations must validate schemes, accounts, paths, and other allow-list constraints before reading data.

type LargePayloadStore

type LargePayloadStore interface {
	Store(context.Context, []byte) (string, error)
}

LargePayloadStore externalizes payload bytes and returns an opaque location.

type LargePayloadTokenStore

type LargePayloadTokenStore interface {
	StoreToken(context.Context, []byte) (string, error)
	ResolveToken(context.Context, string) ([]byte, error)
	IsLargePayloadToken(string) bool
}

LargePayloadTokenStore supports a native payload token format. Native token stores are useful when a backing service already has an interoperable token representation, such as Azure Blob Storage's blob:v2 URLs.

type LargePayloadTokenValidator

type LargePayloadTokenValidator interface {
	ValidateLargePayloadToken(string) error
}

LargePayloadTokenValidator validates recognized native tokens before they are preserved or resolved.

type Logger

type Logger interface {
	// Debug logs a message at level Debug.
	Debug(v ...any)
	// Debugf logs a message at level Debug.
	Debugf(format string, v ...any)
	// Info logs a message at level Info.
	Info(v ...any)
	// Infof logs a message at level Info.
	Infof(format string, v ...any)
	// Warn logs a message at level Warn.
	Warn(v ...any)
	// Warnf logs a message at level Warn.
	Warnf(format string, v ...any)
	// Error logs a message at level Error.
	Error(v ...any)
	// Errorf logs a message at level Error.
	Errorf(format string, v ...any)
}

Logger receives diagnostic messages from DTS clients and workers.

func DefaultLogger

func DefaultLogger() Logger

DefaultLogger returns the process-wide logger used when a caller does not supply one.

func NewSlogLogger

func NewSlogLogger(l *slog.Logger) Logger

NewSlogLogger creates a Logger that delegates to the provided *slog.Logger. This allows consumers to integrate durabletask logging with their existing slog-based logging infrastructure.

type NewOrchestrationOptions added in v0.1.1

type NewOrchestrationOptions func(*protos.CreateInstanceRequest, DataConverter) error

NewOrchestrationOptions configures options for starting a new orchestration.

func WithContextFields

func WithContextFields(fields ContextFields) NewOrchestrationOptions

WithContextFields configures immutable fields propagated into orchestration and activity contexts. The fields are persisted with orchestration history.

func WithInput added in v0.1.1

func WithInput(input any) NewOrchestrationOptions

WithInput configures an input for the orchestration. The specified input must be serializable.

func WithInstanceID added in v0.1.1

func WithInstanceID(id InstanceID) NewOrchestrationOptions

WithInstanceID configures an explicit orchestration instance ID. If not specified, a random UUID value will be used for the orchestration instance ID.

func WithOrchestrationIDReusePolicy

func WithOrchestrationIDReusePolicy(policy *OrchestrationIDReusePolicy) NewOrchestrationOptions

WithOrchestrationIDReusePolicy configures orchestration instance-ID reuse.

func WithRawInput added in v0.2.1

func WithRawInput(rawInput string) NewOrchestrationOptions

WithRawInput configures an input for the orchestration. The specified input must be a string.

func WithStartTime added in v0.1.1

func WithStartTime(startTime time.Time) NewOrchestrationOptions

WithStartTime configures a start time at which the orchestration should start running. Note that the actual start time could be later than the specified start time if the task hub is under load or if the app is not running at the specified start time.

func WithTags

func WithTags(tags map[string]string) NewOrchestrationOptions

WithTags configures orchestration tags that are persisted and returned by metadata queries.

func WithVersion

func WithVersion(version string) NewOrchestrationOptions

WithVersion configures the orchestration version.

type NonRetriable

type NonRetriable interface {
	error
	NonRetriable() bool
}

NonRetriable marks an error that must bypass retry handlers.

type OrchestrationContextInfo

type OrchestrationContextInfo struct {
	InstanceID       InstanceID
	Name             string
	Version          string
	ParentInstanceID InstanceID
}

OrchestrationContextInfo identifies the orchestration associated with a task context.

func OrchestrationContextInfoFromContext

func OrchestrationContextInfoFromContext(ctx context.Context) (OrchestrationContextInfo, bool)

OrchestrationContextInfoFromContext returns orchestration identity from ctx.

type OrchestrationHistory

type OrchestrationHistory struct {
	InstanceID InstanceID `json:"instanceId"`
	// ExecutionID is observed in ExecutionStarted events, never copied from the
	// query. It may be empty only for an unpinned history without such events.
	ExecutionID string          `json:"executionId,omitempty"`
	Events      []*HistoryEvent `json:"events"`
}

OrchestrationHistory is a bounded snapshot of an orchestration's durable history.

type OrchestrationIDReusePolicy

type OrchestrationIDReusePolicy struct {
	DedupeStatuses []OrchestrationStatus
}

OrchestrationIDReusePolicy controls deduplication when an orchestration with the requested instance ID already exists.

A nil DedupeStatuses slice uses the service default. An empty, non-nil slice allows every configurable status to be replaced. Otherwise, an existing instance whose status appears in DedupeStatuses causes scheduling to fail. ContinuedAsNew is not configurable because it is an execution transition rather than a stable instance status.

type OrchestrationMetadata

type OrchestrationMetadata struct {
	InstanceID             InstanceID
	Name                   string
	Version                string
	ExecutionID            string
	ParentInstanceID       InstanceID
	RuntimeStatus          protos.OrchestrationStatus
	ScheduledStartAt       time.Time
	CreatedAt              time.Time
	LastUpdatedAt          time.Time
	CompletedAt            time.Time
	SerializedInput        string
	SerializedOutput       string
	SerializedCustomStatus string
	FailureDetails         *FailureDetails
	Tags                   map[string]string
	Converter              DataConverter `json:"-"`
}

func NewOrchestrationMetadata

func NewOrchestrationMetadata(
	iid InstanceID,
	name string,
	status protos.OrchestrationStatus,
	createdAt time.Time,
	lastUpdatedAt time.Time,
	serializedInput string,
	serializedOutput string,
	serializedCustomStatus string,
	failureDetails *FailureDetails,
) *OrchestrationMetadata

func (*OrchestrationMetadata) IsComplete

func (o *OrchestrationMetadata) IsComplete() bool

func (*OrchestrationMetadata) IsRunning

func (o *OrchestrationMetadata) IsRunning() bool

func (*OrchestrationMetadata) MarshalJSON added in v0.1.1

func (m *OrchestrationMetadata) MarshalJSON() ([]byte, error)

func (*OrchestrationMetadata) ReadCustomStatus

func (m *OrchestrationMetadata) ReadCustomStatus(target any) error

ReadCustomStatus deserializes custom status with the metadata converter.

func (*OrchestrationMetadata) ReadInput

func (m *OrchestrationMetadata) ReadInput(target any) error

ReadInput deserializes the orchestration input with the metadata converter.

func (*OrchestrationMetadata) ReadOutput

func (m *OrchestrationMetadata) ReadOutput(target any) error

ReadOutput deserializes the orchestration output with the metadata converter.

func (*OrchestrationMetadata) UnmarshalJSON added in v0.1.1

func (m *OrchestrationMetadata) UnmarshalJSON(data []byte) error

type OrchestrationQuery

type OrchestrationQuery struct {
	RuntimeStatus         []OrchestrationStatus
	CreatedTimeFrom       time.Time
	CreatedTimeTo         time.Time
	TaskHubNames          []string
	PageSize              int
	ContinuationToken     string
	InstanceIDPrefix      string
	FetchInputsAndOutputs bool
	// Tags are exact-match filters. The gRPC wire contract has no tag filter, so
	// the client scans a bounded number of service pages locally and can return a
	// partial page with a continuation token to resume from.
	Tags map[string]string
}

OrchestrationQuery describes a bounded query for orchestration instances. ContinuationToken values are opaque and must only be reused with the same query.

type OrchestrationQueryResult

type OrchestrationQueryResult struct {
	Orchestrations    []*OrchestrationMetadata
	ContinuationToken string
}

type PurgeInstanceFilter

type PurgeInstanceFilter struct {
	CreatedTimeFrom time.Time
	CreatedTimeTo   time.Time
	RuntimeStatus   []OrchestrationStatus
	Timeout         time.Duration
}

type PurgeInstancesRequest

type PurgeInstancesRequest struct {
	InstanceIDs  []InstanceID
	Filter       *PurgeInstanceFilter
	Recursive    bool
	PollInterval time.Duration
}

PurgeInstancesRequest selects either a bounded list of instance IDs or a filter. Filter requests are polled until the service reports completion.

func (PurgeInstancesRequest) Validate

func (request PurgeInstancesRequest) Validate() error

type PurgeInstancesResult

type PurgeInstancesResult struct {
	DeletedInstanceCount int
	IsComplete           bool
}

type PurgeOptions added in v0.5.0

type PurgeOptions func(*protos.PurgeInstancesRequest) error

PurgeOptions is a set of options for purging an orchestration.

func WithRecursivePurge added in v0.5.0

func WithRecursivePurge(recursive bool) PurgeOptions

WithRecursivePurge configures whether to purge all sub-orchestrations created by the target orchestration.

type RaiseEventOptions added in v0.2.1

type RaiseEventOptions func(*protos.RaiseEventRequest, DataConverter) error

RaiseEventOptions is a set of options for raising an orchestration event.

func WithEventPayload added in v0.3.0

func WithEventPayload(data any) RaiseEventOptions

WithEventPayload configures an event payload. The specified payload must be serializable.

func WithRawEventData added in v0.2.1

func WithRawEventData(data string) RaiseEventOptions

WithRawEventData configures an event payload that is a raw, unprocessed string (e.g. JSON data).

type RestartOptions

type RestartOptions func(*protos.RestartInstanceRequest) error

func WithRestartNewInstanceID

func WithRestartNewInstanceID(restartWithNewInstanceID bool) RestartOptions

type RewindOptions

type RewindOptions func(*protos.RewindInstanceRequest) error

RewindOptions configures a request to rewind a failed orchestration.

func WithRewindReason

func WithRewindReason(reason string) RewindOptions

WithRewindReason records the reason for rewinding an orchestration.

type SignalEntityOptions

type SignalEntityOptions func(*protos.SignalEntityRequest, DataConverter) error

SignalEntityOptions is a functional option type for signaling an entity.

func WithRawSignalInput

func WithRawSignalInput(input string) SignalEntityOptions

WithRawSignalInput configures a raw string input for an entity signal.

func WithSignalInput

func WithSignalInput(input any) SignalEntityOptions

WithSignalInput configures the input for an entity signal.

func WithSignalScheduledTime

func WithSignalScheduledTime(t time.Time) SignalEntityOptions

WithSignalScheduledTime configures a scheduled time for the entity signal.

type TerminateOptions added in v0.3.0

type TerminateOptions func(*protos.TerminateRequest, DataConverter) error

TerminateOptions is a set of options for terminating an orchestration.

func WithOutput added in v0.3.0

func WithOutput(data any) TerminateOptions

WithOutput configures an output for the terminated orchestration. The specified output must be serializable.

func WithRawOutput added in v0.3.0

func WithRawOutput(data string) TerminateOptions

WithRawOutput configures a raw, unprocessed output (i.e. pre-serialized) for the terminated orchestration.

func WithRecursiveTerminate added in v0.5.0

func WithRecursiveTerminate(recursive bool) TerminateOptions

WithRecursiveTerminate configures whether to terminate all sub-orchestrations created by the target orchestration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL