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
- Variables
- func ContextWithFields(ctx context.Context, fields ContextFields) context.Context
- func IsLargePayloadReference(value string) bool
- func NormalizeInstanceQueryPageSize(pageSize int) (int, error)
- func SerializeData(converter DataConverter, value any) (string, error)
- func ValidateTimeRange(from, to time.Time) error
- func WithActivityContextInfo(ctx context.Context, info ActivityContextInfo) context.Context
- func WithEntityContextInfo(ctx context.Context, info EntityContextInfo) context.Context
- func WithOrchestrationContextInfo(ctx context.Context, info OrchestrationContextInfo) context.Context
- func WrapInvalidArgument(err error) error
- type ActivityContextInfo
- type CleanEntityStorageOptions
- type CleanEntityStorageResult
- type ContextFields
- type DataConverter
- type DurableTaskErrorPropertiesProvider
- type DurableTaskErrorTypeProvider
- type DurableTaskFailureDetailsProvider
- type DurableTaskStackTraceProvider
- type EntityContextInfo
- type EntityID
- type EntityMetadata
- type EntityQuery
- type EntityQueryResults
- type ErrorPropertiesProvider
- type ErrorPropertiesProviderFunc
- type ErrorType
- type FailureDetails
- func (d *FailureDetails) IsCausedBy(errorTypes ...ErrorType) bool
- func (d *FailureDetails) MarshalJSON() ([]byte, error)
- func (d *FailureDetails) Matches(target error) bool
- func (d *FailureDetails) NonRetriable() bool
- func (d *FailureDetails) String() string
- func (d *FailureDetails) UnmarshalJSON(data []byte) error
- type FetchOrchestrationMetadataOptions
- type GetEntityOptions
- type HistoryEntityEvent
- type HistoryEvent
- type HistoryEventHandler
- type HistoryEventType
- type HistoryExecutionCompletedEvent
- type HistoryExecutionRewoundEvent
- type HistoryExecutionStartedEvent
- type HistoryExecutionTerminatedEvent
- type HistoryExternalEvent
- type HistoryParentInstanceInfo
- type HistoryPayloadEvent
- type HistoryQuery
- type HistoryStateEvent
- type HistorySubOrchestrationInstanceCreatedEvent
- type HistoryTaskFailureEvent
- type HistoryTaskResultEvent
- type HistoryTaskScheduledEvent
- type HistoryTimerEvent
- type HistoryTimerFiredEvent
- type HistoryTraceContext
- type InclusiveLargePayloadThreshold
- type InstanceID
- type InstanceIDQuery
- type InstanceIDQueryResult
- type JSONDataConverter
- type LargePayloadDefaults
- type LargePayloadOptions
- type LargePayloadOptionsValidator
- type LargePayloadResolver
- type LargePayloadStore
- type LargePayloadTokenStore
- type LargePayloadTokenValidator
- type Logger
- type NewOrchestrationOptions
- func WithContextFields(fields ContextFields) NewOrchestrationOptions
- func WithInput(input any) NewOrchestrationOptions
- func WithInstanceID(id InstanceID) NewOrchestrationOptions
- func WithOrchestrationIDReusePolicy(policy *OrchestrationIDReusePolicy) NewOrchestrationOptions
- func WithRawInput(rawInput string) NewOrchestrationOptions
- func WithStartTime(startTime time.Time) NewOrchestrationOptions
- func WithTags(tags map[string]string) NewOrchestrationOptions
- func WithVersion(version string) NewOrchestrationOptions
- type NonRetriable
- type OrchestrationContextInfo
- type OrchestrationHistory
- type OrchestrationIDReusePolicy
- type OrchestrationMetadata
- func (o *OrchestrationMetadata) IsComplete() bool
- func (o *OrchestrationMetadata) IsRunning() bool
- func (m *OrchestrationMetadata) MarshalJSON() ([]byte, error)
- func (m *OrchestrationMetadata) ReadCustomStatus(target any) error
- func (m *OrchestrationMetadata) ReadInput(target any) error
- func (m *OrchestrationMetadata) ReadOutput(target any) error
- func (m *OrchestrationMetadata) UnmarshalJSON(data []byte) error
- type OrchestrationQuery
- type OrchestrationQueryResult
- type OrchestrationStatus
- type PurgeInstanceFilter
- type PurgeInstancesRequest
- type PurgeInstancesResult
- type PurgeOptions
- type RaiseEventOptions
- type RestartOptions
- type RewindOptions
- type SignalEntityOptions
- type TerminateOptions
Constants ¶
const ( DefaultHistoryMaxEvents = 100_000 MaxHistoryMaxEvents = 1_000_000 DefaultHistoryMaxBytes = 64 * 1024 * 1024 MaxHistoryMaxBytes = 1024 * 1024 * 1024 )
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:" )
const ( DefaultInstanceQueryPageSize = 100 MaxInstanceQueryPageSize = 1000 MaxRemoteTagFilterScanPages = 100 MaxInstanceBatchSize = 500 DefaultPurgePollInterval = 100 * time.Millisecond )
const MaxFailureDetailsDepth = 32
MaxFailureDetailsDepth bounds failure chains in JSON and protobuf payloads.
const ReservedContextFieldPrefix = "__durabletask.context."
ReservedContextFieldPrefix is reserved for Durable Task runtime identity tags.
Variables ¶
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") )
var ( ErrInvalidArgument = errors.New("invalid argument") ErrTaskNotRegistered = errors.New("task is not registered") ErrVersionMismatch = errors.New("task version is incompatible with this worker") )
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") )
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("") )
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.
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 ¶
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 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 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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
EntityID uniquely identifies an entity by its name and key.
func EntityIDFromString ¶
EntityIDFromString parses an entity instance ID string in the format "@<name>@<key>".
func NewEntityID ¶
NewEntityID creates a new EntityID with the specified name and key.
func (EntityID) MarshalJSON ¶
MarshalJSON serializes entity IDs using the cross-SDK compact instance ID format.
func (*EntityID) UnmarshalJSON ¶
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 ¶
ErrorPropertiesProvider enriches failures without requiring application errors to implement an interface.
type ErrorPropertiesProviderFunc ¶
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 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 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 HistoryTimerFiredEvent ¶
type HistoryTraceContext ¶
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
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 OrchestrationStatus ¶ added in v0.3.2
type OrchestrationStatus = protos.OrchestrationStatus
const ( RUNTIME_STATUS_RUNNING OrchestrationStatus = protos.OrchestrationStatus_ORCHESTRATION_STATUS_RUNNING RUNTIME_STATUS_COMPLETED OrchestrationStatus = protos.OrchestrationStatus_ORCHESTRATION_STATUS_COMPLETED RUNTIME_STATUS_CONTINUED_AS_NEW OrchestrationStatus = protos.OrchestrationStatus_ORCHESTRATION_STATUS_CONTINUED_AS_NEW RUNTIME_STATUS_FAILED OrchestrationStatus = protos.OrchestrationStatus_ORCHESTRATION_STATUS_FAILED RUNTIME_STATUS_CANCELED OrchestrationStatus = protos.OrchestrationStatus_ORCHESTRATION_STATUS_CANCELED RUNTIME_STATUS_TERMINATED OrchestrationStatus = protos.OrchestrationStatus_ORCHESTRATION_STATUS_TERMINATED RUNTIME_STATUS_PENDING OrchestrationStatus = protos.OrchestrationStatus_ORCHESTRATION_STATUS_PENDING RUNTIME_STATUS_SUSPENDED OrchestrationStatus = protos.OrchestrationStatus_ORCHESTRATION_STATUS_SUSPENDED )
type PurgeInstanceFilter ¶
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 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.