Documentation
¶
Index ¶
- func GetOutTypes(fnType reflect.Type) []reflect.Type
- func GetRemainingInTypes(fnType reflect.Type) []reflect.Type
- func NewInterface(location string) workflowserviceclient.Interface
- func UpdateWorkflowFunctionContextArgument(wf interface{}, contextType reflect.Type) interface{}
- type ActivityInfo
- type ActivityOptions
- type ActivityType
- type BatchFuture
- type CadenceDataConverter
- type CadenceWorker
- func (w *CadenceWorker) RegisterActivity(a interface{})
- func (w *CadenceWorker) RegisterActivityWithOptions(runFunc interface{}, options RegisterActivityOptions)
- func (w *CadenceWorker) RegisterWorkflow(wf interface{}, funcName string)
- func (w *CadenceWorker) RegisterWorkflowWithOptions(wf interface{}, options RegisterWorkflowOptions)
- func (w *CadenceWorker) Run(_ <-chan interface{}) error
- func (w *CadenceWorker) Start() error
- func (w *CadenceWorker) Stop()
- type CadenceWorkflow
- func (w CadenceWorkflow) ExecuteActivity(ctx Context, activity interface{}, args ...interface{}) Future
- func (w CadenceWorkflow) ExecuteChildWorkflow(ctx Context, childWorkflow interface{}, args ...interface{}) ChildWorkflowFuture
- func (w CadenceWorkflow) GetActivityInfo(ctx context.Context) ActivityInfo
- func (w CadenceWorkflow) GetActivityLogger(ctx context.Context) *zap.Logger
- func (w CadenceWorkflow) GetInfo(ctx Context) IInfo
- func (w CadenceWorkflow) GetLogger(ctx Context) *zap.Logger
- func (w CadenceWorkflow) GetMetricsScope(ctx Context) interface{}
- func (w CadenceWorkflow) Go(ctx Context, f func(ctx Context))
- func (w CadenceWorkflow) IsCanceledError(ctx Context, err error) bool
- func (w CadenceWorkflow) NewBatchFuture(ctx Context, batchSize int, factories []func(ctx Context) Future) (BatchFuture, error)
- func (w CadenceWorkflow) NewCustomError(reason string, details ...interface{}) CustomError
- func (w CadenceWorkflow) NewDisconnectedContext(parent Context) (ctx Context, cancel func())
- func (w CadenceWorkflow) NewFuture(ctx Context) (Future, Settable)
- func (w CadenceWorkflow) NewSelector(ctx Context) Selector
- func (w CadenceWorkflow) Now(ctx Context) time.Time
- func (w CadenceWorkflow) SetQueryHandler(ctx Context, queryType string, handler interface{}) error
- func (w CadenceWorkflow) SideEffect(ctx Context, f func(ctx Context) interface{}) encoded.Value
- func (w CadenceWorkflow) Sleep(ctx Context, d time.Duration) (err error)
- func (w *CadenceWorkflow) WithActivityOptions(ctx Context, options ActivityOptions) Context
- func (w CadenceWorkflow) WithChildOptions(ctx Context, cwo ChildWorkflowOptions) Context
- func (w CadenceWorkflow) WithRetryPolicy(ctx Context, retryPolicy RetryPolicy) Context
- func (w *CadenceWorkflow) WithTaskList(ctx Context, name string) Context
- func (w CadenceWorkflow) WithValue(parent Context, key interface{}, val interface{}) Context
- func (w CadenceWorkflow) WithWorkflowDomain(ctx Context, name string) Context
- func (w CadenceWorkflow) WithWorkflowTaskList(ctx Context, name string) Context
- type CanceledError
- type ChildWorkflowFuture
- type ChildWorkflowOptions
- type Context
- type CustomError
- type Future
- type IChannel
- type IInfo
- type RegisterActivityOptions
- type RegisterWorkflowOptions
- type RetryPolicy
- type Selector
- type Settable
- type TemporalCanceledError
- type TemporalCustomError
- type TemporalDataConverter
- func (s TemporalDataConverter) FromPayload(payload *commonpb.Payload, to interface{}) error
- func (s TemporalDataConverter) FromPayloads(payloads *commonpb.Payloads, to ...interface{}) error
- func (s TemporalDataConverter) ToPayload(value interface{}) (*commonpb.Payload, error)
- func (s TemporalDataConverter) ToPayloads(values ...interface{}) (*commonpb.Payloads, error)
- func (s TemporalDataConverter) ToString(payload *commonpb.Payload) string
- func (s TemporalDataConverter) ToStrings(payloads *commonpb.Payloads) []string
- type TemporalWorker
- func (tw *TemporalWorker) RegisterActivity(a interface{})
- func (tw *TemporalWorker) RegisterActivityWithOptions(w interface{}, options RegisterActivityOptions)
- func (tw *TemporalWorker) RegisterWorkflow(wf interface{}, funcName string)
- func (tw *TemporalWorker) RegisterWorkflowWithOptions(wf interface{}, options RegisterWorkflowOptions)
- func (tw *TemporalWorker) Run(interruptCh <-chan interface{}) error
- func (tw *TemporalWorker) Start() error
- func (tw *TemporalWorker) Stop()
- type TemporalWorkflow
- func (w TemporalWorkflow) ExecuteActivity(ctx Context, activity interface{}, args ...interface{}) Future
- func (w TemporalWorkflow) ExecuteChildWorkflow(ctx Context, name interface{}, args ...interface{}) ChildWorkflowFuture
- func (w TemporalWorkflow) GetActivityInfo(ctx context.Context) ActivityInfo
- func (w TemporalWorkflow) GetActivityLogger(ctx context.Context) *zap.Logger
- func (w TemporalWorkflow) GetInfo(ctx Context) IInfo
- func (w TemporalWorkflow) GetLogger(ctx Context) *zap.Logger
- func (w TemporalWorkflow) GetMetricsScope(ctx Context) interface{}
- func (w TemporalWorkflow) Go(ctx Context, f func(ctx Context))
- func (w TemporalWorkflow) IsCanceledError(ctx Context, err error) bool
- func (w TemporalWorkflow) NewBatchFuture(ctx Context, batchSize int, factories []func(ctx Context) Future) (BatchFuture, error)
- func (w TemporalWorkflow) NewCustomError(reason string, details ...interface{}) CustomError
- func (w TemporalWorkflow) NewDisconnectedContext(parent Context) (ctx Context, cancel func())
- func (w TemporalWorkflow) NewFuture(ctx Context) (Future, Settable)
- func (w TemporalWorkflow) NewSelector(ctx Context) Selector
- func (w TemporalWorkflow) Now(ctx Context) time.Time
- func (w TemporalWorkflow) SetQueryHandler(ctx Context, queryType string, handler interface{}) error
- func (w TemporalWorkflow) SideEffect(ctx Context, f func(ctx Context) interface{}) encoded.Value
- func (w TemporalWorkflow) Sleep(ctx Context, d time.Duration) (err error)
- func (w *TemporalWorkflow) WithActivityOptions(ctx Context, options ActivityOptions) Context
- func (w TemporalWorkflow) WithChildOptions(ctx Context, cwo ChildWorkflowOptions) Context
- func (w TemporalWorkflow) WithRetryPolicy(ctx Context, retryPolicy RetryPolicy) Context
- func (w *TemporalWorkflow) WithTaskList(ctx Context, name string) Context
- func (w TemporalWorkflow) WithValue(parent Context, key interface{}, val interface{}) Context
- func (w TemporalWorkflow) WithWorkflowDomain(ctx Context, name string) Context
- func (w TemporalWorkflow) WithWorkflowTaskList(ctx Context, name string) Context
- type Workflow
- type WorkflowExecution
- type WorkflowType
- type ZapLoggerAdapter
- func (l *ZapLoggerAdapter) Debug(msg string, keyvals ...interface{})
- func (l *ZapLoggerAdapter) Error(msg string, keyvals ...interface{})
- func (l *ZapLoggerAdapter) Info(msg string, keyvals ...interface{})
- func (l *ZapLoggerAdapter) Warn(msg string, keyvals ...interface{})
- func (l *ZapLoggerAdapter) With(keyvals ...interface{}) log.Logger
- func (l *ZapLoggerAdapter) Zap() *zap.Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOutTypes ¶
GetOutTypes returns a slice of reflect.Type containing all output types of the provided function type.
func GetRemainingInTypes ¶
GetRemainingInTypes returns a slice of reflect.Type containing all input types except the first one.
func NewInterface ¶
func NewInterface(location string) workflowserviceclient.Interface
NewInterface creates a new Cadence workflow service client interface.
func UpdateWorkflowFunctionContextArgument ¶
UpdateWorkflowFunctionContextArgument takes a workflow function and a new context type, and returns a new function with the same signature but with the first argument replaced by the provided context type. The rest of the arguments remain unchanged. It is useful for adapting workflow functions to different context types. The original function must have at least one argument (the context). If the original function does not have a context argument, it panics.
Types ¶
type ActivityInfo ¶ added in v1.0.15
type ActivityInfo struct {
// TaskToken is an opaque binary token that uniquely identifies this activity task.
// It's used for activity completion, heartbeat reporting, and task routing within the workflow engine.
// This token should be included in all activity lifecycle operations (complete, fail, heartbeat).
TaskToken []byte
// WorkflowType contains information about the parent workflow that scheduled this activity.
// May be nil if workflow type information is not available.
// Includes both the workflow name and path (package information).
WorkflowType *WorkflowType
// WorkflowDomain specifies the domain/namespace where the parent workflow is executing.
// In Cadence: this is the domain name
// In Temporal: this is the namespace name (mapped to WorkflowDomain for consistency)
WorkflowDomain string
// WorkflowExecution contains the unique identifiers of the parent workflow instance
// that scheduled this activity. Includes both the workflow ID and run ID.
WorkflowExecution WorkflowExecution
// ActivityID is a business-level identifier for this specific activity execution.
// This can be used to identify and correlate activity executions, and is often
// used for activity deduplication and tracking purposes.
ActivityID string
// ActivityType contains information about the activity function being executed,
// including the activity name and optional path information.
ActivityType ActivityType
// TaskList specifies the task list (Cadence) or task queue (Temporal) where this activity was scheduled.
// This indicates which worker pool is responsible for executing this activity.
TaskList string
// HeartbeatTimeout specifies the maximum time allowed between activity heartbeats.
// If set to 0, no heartbeat is required for this activity.
// Activities should send heartbeats within this interval to indicate they're still alive and making progress.
HeartbeatTimeout time.Duration
// ScheduledTimestamp indicates when the activity was scheduled by the parent workflow.
// This represents the time the workflow decision was made to execute this activity.
ScheduledTimestamp time.Time
// StartedTimestamp indicates when the activity actually began executing on a worker.
// There may be a delay between ScheduledTimestamp and StartedTimestamp due to task list queuing.
StartedTimestamp time.Time
// Deadline specifies the absolute time when this activity execution will timeout.
// Activities must complete before this deadline or they will be considered failed.
Deadline time.Time
// Attempt indicates the current retry attempt number for this activity execution.
// Starts from 0 for the first attempt, and increments by 1 for each retry attempt
// when a retry policy is configured for the activity.
Attempt int32
}
ActivityInfo provides comprehensive metadata about an activity execution, unified across both Cadence and Temporal workflow engines. This structure contains all the information needed to understand the context and lifecycle of an activity execution.
type ActivityOptions ¶
type ActivityOptions struct {
// TaskList that the activity needs to be scheduled on.
// optional: The default task list with the same name as the workflow task list.
TaskList string
// ScheduleToCloseTimeout - The end to end timeout for the activity needed.
// The zero value of this uses default value.
// Optional: The default value is the sum of ScheduleToStartTimeout and StartToCloseTimeout
ScheduleToCloseTimeout time.Duration
// ScheduleToStartTimeout - The queue timeout before the activity starts executed.
// Mandatory: No default.
ScheduleToStartTimeout time.Duration
// StartToCloseTimeout - The timeout from the start of execution to end of it.
// Mandatory: No default.
StartToCloseTimeout time.Duration
// HeartbeatTimeout - The periodic timeout while the activity is in execution. This is
// the max interval the server needs to hear at-least one ping from the activity.
// Optional: Default zero, means no heart beating is needed.
HeartbeatTimeout time.Duration
// WaitForCancellation - Whether to wait for cancelled activity to be completed(
// activity can be failed, completed, cancel accepted)
// Optional: default false
WaitForCancellation bool
// ActivityID - Business level activity ID, this is not needed for most of the cases if you have
// to specify this then talk to cadence team. This is something will be done in future.
// Optional: default empty string
ActivityID string
// RetryPolicy specify how to retry activity if error happens. When RetryPolicy.ExpirationInterval is specified
// and it is larger than the activity's ScheduleToStartTimeout, then the ExpirationInterval will override activity's
// ScheduleToStartTimeout. This is to avoid retrying on ScheduleToStartTimeout error which only happen when worker
// is not picking up the task within the timeout. Retrying ScheduleToStartTimeout does not make sense as it just
// mark the task as failed and create a new task and put back in the queue waiting worker to pick again. Cadence
// server also make sure the ScheduleToStartTimeout will not be larger than the workflow's timeout.
// Same apply to ScheduleToCloseTimeout. See more details about RetryPolicy on the doc for RetryPolicy.
// Optional: default is no retry
RetryPolicy *RetryPolicy
// DisableEagerExecution - If true, eager execution will not be requested, regardless of worker settings.
// If false, eager execution may still be disabled at the worker level or
// may not be requested due to lack of available slots.
// Optional: default false
DisableEagerExecution bool
// VersioningIntent - Specifies whether this activity should run on a worker with a compatible
// build ID or not. See temporal.VersioningIntent.
// WARNING: Worker versioning is currently experimental
// Optional: default 0
VersioningIntent int
// Summary - A single-line summary for this activity that will appear in UI/CLI. This can be
// in single-line Temporal Markdown format.
// Optional: defaults to none/empty.
// NOTE: Experimental
Summary string
}
type ActivityType ¶ added in v1.0.15
type ActivityType struct {
// Name is the human-readable identifier for the activity type.
// This is the name used when scheduling activity executions and in activity registration.
// Example: "ProcessPayment", "send-email", "validate-input", etc.
Name string
// Path contains the fully qualified path or package information for the activity function.
// This provides technical details about where the activity code is located.
// In Cadence: typically includes the full package path
// In Temporal: may not always be available (often empty)
// Example: "github.com/myorg/activities.ProcessPayment"
Path string
}
ActivityType identifies an activity type with both human-readable name and technical path information. This structure provides metadata about activity functions across different workflow engines.
type BatchFuture ¶ added in v1.0.13
type BatchFuture interface {
// IsReady returns true when all wrapped futures return true from their IsReady
IsReady() bool
// Get acts like workflow.Future.Get, but it reads out all wrapped futures into the provided slice pointer.
Get(ctx Context, valuePtr interface{}) error
// GetFutures returns a slice of all the wrapped futures.
// This slice MUST NOT be modified, but the individual futures can be used normally.
GetFutures() []Future
}
type CadenceDataConverter ¶
CadenceDataConverter is a Cadence encoded.DataConverter that supports Starlark types, such as starlark.String, starlark.Int and others. Enables passing Starlark values between Cadence workflows and activities.
type CadenceWorker ¶
CadenceWorker implements Worker interface
func (*CadenceWorker) RegisterActivity ¶
func (w *CadenceWorker) RegisterActivity(a interface{})
RegisterActivity registers an activity with the Cadence worker.
func (*CadenceWorker) RegisterActivityWithOptions ¶
func (w *CadenceWorker) RegisterActivityWithOptions(runFunc interface{}, options RegisterActivityOptions)
RegisterActivityWithOptions registers an activity with the Cadence worker using options.
func (*CadenceWorker) RegisterWorkflow ¶
func (w *CadenceWorker) RegisterWorkflow(wf interface{}, funcName string)
RegisterWorkflow registers a workflow with the Cadence worker.
func (*CadenceWorker) RegisterWorkflowWithOptions ¶
func (w *CadenceWorker) RegisterWorkflowWithOptions(wf interface{}, options RegisterWorkflowOptions)
RegisterWorkflowWithOptions registers a workflow with the Cadence worker using options.
func (*CadenceWorker) Run ¶
func (w *CadenceWorker) Run(_ <-chan interface{}) error
Run runs the Cadence worker.
func (*CadenceWorker) Start ¶
func (w *CadenceWorker) Start() error
Start starts the Cadence worker.
type CadenceWorkflow ¶
type CadenceWorkflow struct{}
CadenceWorkflow implements Workflow interface for Cadence.
func (CadenceWorkflow) ExecuteActivity ¶
func (w CadenceWorkflow) ExecuteActivity(ctx Context, activity interface{}, args ...interface{}) Future
ExecuteActivity executes an activity in the Cadence workflow.
func (CadenceWorkflow) ExecuteChildWorkflow ¶
func (w CadenceWorkflow) ExecuteChildWorkflow(ctx Context, childWorkflow interface{}, args ...interface{}) ChildWorkflowFuture
ExecuteChildWorkflow executes a child workflow in the Cadence workflow.
func (CadenceWorkflow) GetActivityInfo ¶ added in v1.0.15
func (w CadenceWorkflow) GetActivityInfo(ctx context.Context) ActivityInfo
GetActivityInfo retrieves comprehensive information about the currently executing Cadence activity. This method is implemented as part of the Workflow interface to provide unified access to activity metadata across different workflow engines (Cadence and Temporal).
Parameters:
- ctx: The activity context from which to extract information. Must be a valid Cadence activity context.
Returns:
- ActivityInfo: A unified structure containing activity execution details including:
- TaskToken: Opaque token that identifies the activity task for completion/heartbeat operations
- WorkflowDomain: The Cadence domain where the parent workflow is executing
- WorkflowExecution: ID and RunID of the parent workflow that scheduled this activity
- ActivityID: Business-level identifier for this specific activity execution
- ActivityType: Name and path information about the activity function being executed
- TaskList: The task list this activity was scheduled on
- HeartbeatTimeout: Maximum interval between heartbeats (0 means no heartbeat required)
- ScheduledTimestamp: When the activity was scheduled by the workflow
- StartedTimestamp: When the activity actually started executing
- Deadline: Absolute deadline for activity completion
- Attempt: Current retry attempt number (starts from 0, increments on retries)
- WorkflowType: Information about the parent workflow type (optional, may be nil)
This method converts Cadence-specific activity information into a unified format that can be used consistently across both Cadence and Temporal implementations, enabling portable activity code.
Example usage within an activity:
func MyActivity(ctx context.Context, input string) (string, error) {
workflow := CadenceWorkflow{}
info := workflow.GetActivityInfo(ctx)
logger.Info("Activity executing",
"activityID", info.ActivityID,
"attempt", info.Attempt,
"workflowID", info.WorkflowExecution.ID)
// ... activity logic
}
func (CadenceWorkflow) GetActivityLogger ¶
func (w CadenceWorkflow) GetActivityLogger(ctx context.Context) *zap.Logger
GetActivityLogger is implemented in the Workflow interface to return the logger for the Cadence activity.
func (CadenceWorkflow) GetInfo ¶
func (w CadenceWorkflow) GetInfo(ctx Context) IInfo
GetActivityInfo returns the activity info for the Cadence workflow.
func (CadenceWorkflow) GetLogger ¶
func (w CadenceWorkflow) GetLogger(ctx Context) *zap.Logger
GetLogger is implemented in the Workflow interface to return the logger for the Cadence workflow.
func (CadenceWorkflow) GetMetricsScope ¶
func (w CadenceWorkflow) GetMetricsScope(ctx Context) interface{}
GetMetricsScope returns the metrics scope for the Cadence workflow.
func (CadenceWorkflow) Go ¶
func (w CadenceWorkflow) Go(ctx Context, f func(ctx Context))
Go executes a function in the Cadence workflow context.
func (CadenceWorkflow) IsCanceledError ¶
func (w CadenceWorkflow) IsCanceledError(ctx Context, err error) bool
IsCanceledError checks if the error is a CanceledError.
func (CadenceWorkflow) NewBatchFuture ¶ added in v1.0.13
func (w CadenceWorkflow) NewBatchFuture(ctx Context, batchSize int, factories []func(ctx Context) Future) (BatchFuture, error)
NewBatchFuture creates a new batch future for the Cadence workflow.
func (CadenceWorkflow) NewCustomError ¶
func (w CadenceWorkflow) NewCustomError(reason string, details ...interface{}) CustomError
NewCustomError creates a new custom error for the Cadence workflow.
func (CadenceWorkflow) NewDisconnectedContext ¶
func (w CadenceWorkflow) NewDisconnectedContext(parent Context) (ctx Context, cancel func())
NewDisconnectedContext creates a new disconnected context for the Cadence workflow.
func (CadenceWorkflow) NewFuture ¶
func (w CadenceWorkflow) NewFuture(ctx Context) (Future, Settable)
NewFuture creates a new future for the Cadence workflow.
func (CadenceWorkflow) NewSelector ¶ added in v1.0.11
func (w CadenceWorkflow) NewSelector(ctx Context) Selector
NewSelector creates a new selector for deterministic workflow operations.
func (CadenceWorkflow) Now ¶
func (w CadenceWorkflow) Now(ctx Context) time.Time
Now returns the current time in the Cadence workflow context.
func (CadenceWorkflow) SetQueryHandler ¶
func (w CadenceWorkflow) SetQueryHandler(ctx Context, queryType string, handler interface{}) error
SetQueryHandler sets a query handler for the Cadence workflow.
func (CadenceWorkflow) SideEffect ¶
func (w CadenceWorkflow) SideEffect(ctx Context, f func(ctx Context) interface{}) encoded.Value
SideEffect executes a side effect in the Cadence workflow context.
func (CadenceWorkflow) Sleep ¶
func (w CadenceWorkflow) Sleep(ctx Context, d time.Duration) (err error)
Sleep pauses the Cadence workflow for a specified duration.
func (*CadenceWorkflow) WithActivityOptions ¶
func (w *CadenceWorkflow) WithActivityOptions(ctx Context, options ActivityOptions) Context
WithActivityOptions sets the activity options for the Cadence workflow context.
func (CadenceWorkflow) WithChildOptions ¶
func (w CadenceWorkflow) WithChildOptions(ctx Context, cwo ChildWorkflowOptions) Context
WithChildOptions sets the child workflow options for the Cadence workflow context.
func (CadenceWorkflow) WithRetryPolicy ¶
func (w CadenceWorkflow) WithRetryPolicy(ctx Context, retryPolicy RetryPolicy) Context
WithRetryPolicy sets the retry policy for the Cadence workflow context.
func (*CadenceWorkflow) WithTaskList ¶
func (w *CadenceWorkflow) WithTaskList(ctx Context, name string) Context
WithTaskList sets the task list for the Cadence workflow context.
func (CadenceWorkflow) WithValue ¶
func (w CadenceWorkflow) WithValue(parent Context, key interface{}, val interface{}) Context
WithValue sets a value in the Cadence workflow context.
func (CadenceWorkflow) WithWorkflowDomain ¶
func (w CadenceWorkflow) WithWorkflowDomain(ctx Context, name string) Context
WithWorkflowDomain sets the workflow domain for the Cadence workflow context.
func (CadenceWorkflow) WithWorkflowTaskList ¶
func (w CadenceWorkflow) WithWorkflowTaskList(ctx Context, name string) Context
WithWorkflowTaskList sets the workflow task list for the Cadence workflow context.
type CanceledError ¶
type ChildWorkflowFuture ¶
type ChildWorkflowFuture interface {
Future
// GetChildWorkflowExecution returns a future that will be ready when child workflow execution started. You can
// get the WorkflowExecution of the child workflow from the future. Then you can use Workflow ID and RunID of
// child workflow to cancel or send signal to child workflow.
// childWorkflowFuture := workflow.ExecuteChildWorkflow(ctx, child, ...)
// var childWE WorkflowExecution
// if err := childWorkflowFuture.GetChildWorkflowExecution().Get(ctx, &childWE); err == nil {
// // child workflow started, you can use childWE to get the WorkflowID and RunID of child workflow
// }
GetChildWorkflowExecution() Future
// SignalWorkflowByID sends a signal to the child workflow. This call will block until child workflow is started.
SignalChildWorkflow(ctx Context, signalName string, data interface{}) Future
}
type ChildWorkflowOptions ¶
type ChildWorkflowOptions struct {
// Domain of the child workflow.
// Optional: the current workflow (parent)'s domain will be used if this is not provided.
Domain string
// WorkflowID of the child workflow to be scheduled.
// Optional: an auto generated workflowID will be used if this is not provided.
WorkflowID string
// TaskList that the child workflow needs to be scheduled on.
// Optional: the parent workflow task list will be used if this is not provided.
TaskList string
// ExecutionStartToCloseTimeout - The end to end timeout for the child workflow execution.
// Mandatory: no default
ExecutionStartToCloseTimeout time.Duration
// TaskStartToCloseTimeout - The decision task timeout for the child workflow.
// Optional: default is 10s if this is not provided (or if 0 is provided).
TaskStartToCloseTimeout time.Duration
// WaitForCancellation - Whether to wait for cancelled child workflow to be ended (child workflow can be ended
// as: completed/failed/timedout/terminated/canceled)
// Optional: default false
WaitForCancellation bool
// WorkflowIDReusePolicy - Whether server allow reuse of workflow ID, can be useful
// for dedup logic if set to WorkflowIdReusePolicyRejectDuplicate
// Here the value we use Cadence constant, and we map to Temporal equivalent based on the table below.
// Cadence Constant Value Meaning Temporal Equivalent Value
//----------------------------------------------------------------------------------------------------
//WorkflowIDReusePolicyAllowDuplicateFailedOnly 0 Allow reuse if last run was terminated/cancelled/timeouted/failed WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY 2
//WorkflowIDReusePolicyAllowDuplicate 1 Allow reuse as long as workflow is not running WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE 1
//WorkflowIDReusePolicyRejectDuplicate 2 Never allow reuse WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE 3
//WorkflowIDReusePolicyTerminateIfRunning 3 Terminate if running, then start new WORKFLOW_ID_REUSE_POLICY_TERMINATE_IF_RUNNING
//----------------------------------------------------------------------------------------------------
WorkflowIDReusePolicy int
// RetryPolicy specify how to retry child workflow if error happens.
// Optional: default is no retry
RetryPolicy *RetryPolicy
// CronSchedule - Optional cron schedule for workflow. If a cron schedule is specified, the workflow will run
// as a cron based on the schedule. The scheduling will be based on UTC time. Schedule for next run only happen
// after the current run is completed/failed/timeout. If a RetryPolicy is also supplied, and the workflow failed
// or timeout, the workflow will be retried based on the retry policy. While the workflow is retrying, it won't
// schedule its next run. If next schedule is due while workflow is running (or retrying), then it will skip that
// schedule. Cron workflow will not stop until it is terminated or cancelled (by returning cadence.CanceledError).
// The cron spec is as following:
// ┌───────────── minute (0 - 59)
// │ ┌───────────── hour (0 - 23)
// │ │ ┌───────────── day of the month (1 - 31)
// │ │ │ ┌───────────── month (1 - 12)
// │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)
// │ │ │ │ │
// │ │ │ │ │
// * * * * *
CronSchedule string
// Memo - Optional non-indexed info that will be shown in list workflow.
Memo map[string]interface{}
// SearchAttributes - Optional indexed info that can be used in query of List/Scan/Count workflow APIs (only
// supported when Cadence server is using ElasticSearch). The key and value type must be registered on Cadence server side.
// Use GetSearchAttributes API to get valid key and corresponding value type.
SearchAttributes map[string]interface{}
// ParentClosePolicy - Optional policy to decide what to do for the child.
// Default is Terminate (if onboarded to this feature)
ParentClosePolicy int
}
type Context ¶
type Context interface {
Value(key interface{}) interface{}
}
Context defines the methods that a workflow.Context should implement.
type CustomError ¶
type IChannel ¶
type IChannel interface {
Receive(ctx Context, valuePtr interface{}) (ok bool)
ReceiveAsync(valuePtr interface{}) (ok bool)
ReceiveAsyncWithMoreFlag(valuePtr interface{}) (ok bool, more bool)
Send(ctx Context, v interface{})
SendAsync(v interface{}) (ok bool)
Close()
}
Package internal provides the interface for the Cadence worker and workflow IChannel is an interface that defines the methods for sending and receiving
type RegisterActivityOptions ¶
type RegisterActivityOptions struct {
// When an activity is a function the name is an actual activity type name.
// When an activity is part of a structure then each member of the structure becomes an activity with
// this Name as a prefix + activity function name.
Name string
// Activity type name is equal to function name instead of fully qualified
// name including function package (and struct type if used).
// This option has no effect when explicit Name is provided.
EnableShortName bool
DisableAlreadyRegisteredCheck bool
// Automatically send heartbeats for this activity at an interval that is less than the HeartbeatTimeout.
// This option has no effect if the activity is executed with a HeartbeatTimeout of 0.
// Default: false
EnableAutoHeartbeat bool
// This is for temporal activity RegisterOptions
// When registering a struct with activities, skip functions that are not valid activities. If false,
// registration panics.
SkipInvalidStructFunctions bool
}
type RegisterWorkflowOptions ¶
type RegisterWorkflowOptions struct {
Name string
// Workflow type name is equal to function name instead of fully qualified name including function package.
// This option has no effect when explicit Name is provided.
EnableShortName bool
DisableAlreadyRegisteredCheck bool
// This is for temporal RegisterOptions
// Optional: Provides a Versioning Behavior to workflows of this type. It is required
// when WorkerOptions does not specify [DeploymentOptions.DefaultVersioningBehavior],
// [DeploymentOptions.DeploymentSeriesName] is set, and [UseBuildIDForVersioning] is true.
// NOTE: Experimental
VersioningBehavior int
}
type RetryPolicy ¶
type RetryPolicy struct {
// Backoff interval for the first retry. If coefficient is 1.0 then it is used for all retries.
// Required, no default value.
InitialInterval time.Duration
// Coefficient used to calculate the next retry backoff interval.
// The next retry interval is previous interval multiplied by this coefficient.
// Must be 1 or larger. Default is 2.0.
BackoffCoefficient float64
// Maximum backoff interval between retries. Exponential backoff leads to interval increase.
// This value is the cap of the interval. Default is 100x of initial interval.
MaximumInterval time.Duration
// Maximum time to retry. Either ExpirationInterval or MaximumAttempts is required.
// When exceeded the retries stop even if maximum retries is not reached yet.
ExpirationInterval time.Duration
// Maximum number of attempts. When exceeded the retries stop even if not expired yet.
// If not set or set to 0, it means unlimited, and rely on ExpirationInterval to stop.
// Either MaximumAttempts or ExpirationInterval is required.
MaximumAttempts int32
// Non-Retriable errors. This is optional. Cadence server will stop retry if error reason matches this list.
// Error reason for custom error is specified when your activity/workflow return cadence.NewCustomError(reason).
// Error reason for panic error is "cadenceInternal:Panic".
// Error reason for any other error is "cadenceInternal:Generic".
// Error reason for timeouts is: "cadenceInternal:Timeout TIMEOUT_TYPE". TIMEOUT_TYPE could be START_TO_CLOSE or HEARTBEAT.
// Note, cancellation is not a failure, so it won't be retried.
NonRetriableErrorReasons []string
}
type Selector ¶ added in v1.0.11
Selector provides a deterministic alternative to Go's select statement in workflows. It allows waiting on multiple futures in a deterministic way.
type TemporalCanceledError ¶
type TemporalCanceledError struct {
temporal.CanceledError
}
func (TemporalCanceledError) Details ¶
func (e TemporalCanceledError) Details(d ...interface{}) error
Details extracts strong typed detail data of this error.
func (TemporalCanceledError) Error ¶
func (e TemporalCanceledError) Error() string
Error from error interface
func (TemporalCanceledError) HasDetails ¶
func (e TemporalCanceledError) HasDetails() bool
HasDetails return if this error has strong typed detail data.
type TemporalCustomError ¶
type TemporalCustomError struct {
temporal.ApplicationError
}
func (TemporalCustomError) Details ¶
func (e TemporalCustomError) Details(d ...interface{}) error
Details extracts strong typed detail data of this custom error. If there is no details, it will return ErrNoData.
func (TemporalCustomError) Error ¶
func (e TemporalCustomError) Error() string
func (TemporalCustomError) HasDetails ¶
func (e TemporalCustomError) HasDetails() bool
HasDetails return if this error has strong typed detail data.
func (TemporalCustomError) Reason ¶
func (e TemporalCustomError) Reason() string
Reason gets the reason of this custom error
type TemporalDataConverter ¶
TemporalDataConverter is a Temporal TemporalDataConverter that supports Starlark types. Enables passing Starlark values between Temporal workflows and activities.
func (TemporalDataConverter) FromPayload ¶
func (s TemporalDataConverter) FromPayload(payload *commonpb.Payload, to interface{}) error
FromPayload converts a single Temporal Payload back to a Go value
func (TemporalDataConverter) FromPayloads ¶
func (s TemporalDataConverter) FromPayloads(payloads *commonpb.Payloads, to ...interface{}) error
FromPayloads converts Temporal Payloads back into Go types
func (TemporalDataConverter) ToPayload ¶
func (s TemporalDataConverter) ToPayload(value interface{}) (*commonpb.Payload, error)
ToPayload converts a single Go value to a Temporal Payload
func (TemporalDataConverter) ToPayloads ¶
func (s TemporalDataConverter) ToPayloads(values ...interface{}) (*commonpb.Payloads, error)
ToPayloads converts input values to Temporal's Payloads format
type TemporalWorker ¶
TemporalWorker is a wrapper around the Temporal SDK worker interface.
func (*TemporalWorker) RegisterActivity ¶
func (tw *TemporalWorker) RegisterActivity(a interface{})
RegisterActivity registers an activity with the Temporal worker.
func (*TemporalWorker) RegisterActivityWithOptions ¶
func (tw *TemporalWorker) RegisterActivityWithOptions(w interface{}, options RegisterActivityOptions)
RegisterActivityWithOptions registers an activity with the Temporal worker using options.
func (*TemporalWorker) RegisterWorkflow ¶
func (tw *TemporalWorker) RegisterWorkflow(wf interface{}, funcName string)
RegisterWorkflow registers a workflow with the Temporal worker.
func (*TemporalWorker) RegisterWorkflowWithOptions ¶
func (tw *TemporalWorker) RegisterWorkflowWithOptions(wf interface{}, options RegisterWorkflowOptions)
RegisterWorkflowWithOptions registers a workflow with the Temporal worker using options.
func (*TemporalWorker) Run ¶
func (tw *TemporalWorker) Run(interruptCh <-chan interface{}) error
Run runs the Temporal worker and blocks until it is interrupted.
func (*TemporalWorker) Start ¶
func (tw *TemporalWorker) Start() error
Start starts the Temporal worker.
type TemporalWorkflow ¶
type TemporalWorkflow struct{}
TemporalWorkflow is a wrapper around the Temporal SDK workflow interface.
func (TemporalWorkflow) ExecuteActivity ¶
func (w TemporalWorkflow) ExecuteActivity(ctx Context, activity interface{}, args ...interface{}) Future
func (TemporalWorkflow) ExecuteChildWorkflow ¶
func (w TemporalWorkflow) ExecuteChildWorkflow(ctx Context, name interface{}, args ...interface{}) ChildWorkflowFuture
func (TemporalWorkflow) GetActivityInfo ¶ added in v1.0.15
func (w TemporalWorkflow) GetActivityInfo(ctx context.Context) ActivityInfo
GetActivityInfo retrieves comprehensive information about the currently executing Temporal activity. This method is implemented as part of the Workflow interface to provide unified access to activity metadata across different workflow engines (Cadence and Temporal).
Parameters:
- ctx: The activity context from which to extract information. Must be a valid Temporal activity context.
Returns:
- ActivityInfo: A unified structure containing activity execution details including:
- TaskToken: Opaque token that identifies the activity task for completion/heartbeat operations
- WorkflowDomain: The Temporal namespace where the parent workflow is executing (mapped from WorkflowNamespace)
- WorkflowExecution: ID and RunID of the parent workflow that scheduled this activity
- ActivityID: Business-level identifier for this specific activity execution
- ActivityType: Name information about the activity function being executed (Temporal doesn't provide Path)
- TaskList: The task queue this activity was scheduled on (mapped from TaskQueue)
- HeartbeatTimeout: Maximum interval between heartbeats (0 means no heartbeat required)
- ScheduledTimestamp: When the activity was scheduled by the workflow (mapped from ScheduledTime)
- StartedTimestamp: When the activity actually started executing (mapped from StartedTime)
- Deadline: Absolute deadline for activity completion
- Attempt: Current retry attempt number (starts from 0, increments on retries)
- WorkflowType: Information about the parent workflow type (optional, may be nil, no Path in Temporal)
This method converts Temporal-specific activity information into a unified format that can be used consistently across both Cadence and Temporal implementations, enabling portable activity code. Note that some fields are adapted to match the unified interface:
- WorkflowNamespace -> WorkflowDomain
- TaskQueue -> TaskList
- ScheduledTime -> ScheduledTimestamp
- StartedTime -> StartedTimestamp
- ActivityType.Path is not available in Temporal
Example usage within an activity:
func MyActivity(ctx context.Context, input string) (string, error) {
workflow := TemporalWorkflow{}
info := workflow.GetActivityInfo(ctx)
logger.Info("Activity executing",
"activityID", info.ActivityID,
"attempt", info.Attempt,
"workflowID", info.WorkflowExecution.ID,
"namespace", info.WorkflowDomain)
// ... activity logic
}
func (TemporalWorkflow) GetActivityLogger ¶
func (w TemporalWorkflow) GetActivityLogger(ctx context.Context) *zap.Logger
func (TemporalWorkflow) GetInfo ¶
func (w TemporalWorkflow) GetInfo(ctx Context) IInfo
func (TemporalWorkflow) GetMetricsScope ¶
func (w TemporalWorkflow) GetMetricsScope(ctx Context) interface{}
func (TemporalWorkflow) Go ¶
func (w TemporalWorkflow) Go(ctx Context, f func(ctx Context))
func (TemporalWorkflow) IsCanceledError ¶
func (w TemporalWorkflow) IsCanceledError(ctx Context, err error) bool
IsCanceledError checks if the error is a CanceledError.
func (TemporalWorkflow) NewBatchFuture ¶ added in v1.0.13
func (w TemporalWorkflow) NewBatchFuture(ctx Context, batchSize int, factories []func(ctx Context) Future) (BatchFuture, error)
NewBatchFuture creates a new batch future for the Cadence workflow.
func (TemporalWorkflow) NewCustomError ¶
func (w TemporalWorkflow) NewCustomError(reason string, details ...interface{}) CustomError
func (TemporalWorkflow) NewDisconnectedContext ¶
func (w TemporalWorkflow) NewDisconnectedContext(parent Context) (ctx Context, cancel func())
func (TemporalWorkflow) NewFuture ¶
func (w TemporalWorkflow) NewFuture(ctx Context) (Future, Settable)
func (TemporalWorkflow) NewSelector ¶ added in v1.0.11
func (w TemporalWorkflow) NewSelector(ctx Context) Selector
NewSelector creates a new selector for deterministic workflow operations.
func (TemporalWorkflow) SetQueryHandler ¶
func (w TemporalWorkflow) SetQueryHandler(ctx Context, queryType string, handler interface{}) error
func (TemporalWorkflow) SideEffect ¶
func (w TemporalWorkflow) SideEffect(ctx Context, f func(ctx Context) interface{}) encoded.Value
func (TemporalWorkflow) Sleep ¶
func (w TemporalWorkflow) Sleep(ctx Context, d time.Duration) (err error)
func (*TemporalWorkflow) WithActivityOptions ¶
func (w *TemporalWorkflow) WithActivityOptions(ctx Context, options ActivityOptions) Context
func (TemporalWorkflow) WithChildOptions ¶
func (w TemporalWorkflow) WithChildOptions(ctx Context, cwo ChildWorkflowOptions) Context
WithChildOptions sets the child workflow options for the workflow execution.
func (TemporalWorkflow) WithRetryPolicy ¶
func (w TemporalWorkflow) WithRetryPolicy(ctx Context, retryPolicy RetryPolicy) Context
WithRetryPolicy sets the retry policy for the workflow execution.
func (*TemporalWorkflow) WithTaskList ¶
func (w *TemporalWorkflow) WithTaskList(ctx Context, name string) Context
func (TemporalWorkflow) WithValue ¶
func (w TemporalWorkflow) WithValue(parent Context, key interface{}, val interface{}) Context
func (TemporalWorkflow) WithWorkflowDomain ¶
func (w TemporalWorkflow) WithWorkflowDomain(ctx Context, name string) Context
func (TemporalWorkflow) WithWorkflowTaskList ¶
func (w TemporalWorkflow) WithWorkflowTaskList(ctx Context, name string) Context
type Workflow ¶
type Workflow interface {
GetLogger(ctx Context) *zap.Logger
GetActivityLogger(ctx context.Context) *zap.Logger
GetActivityInfo(ctx context.Context) ActivityInfo
WithValue(parent Context, key interface{}, val interface{}) Context
NewDisconnectedContext(parent Context) (ctx Context, cancel func())
GetMetricsScope(ctx Context) interface{}
ExecuteActivity(ctx Context, activity interface{}, args ...interface{}) Future
WithTaskList(ctx Context, name string) Context
GetInfo(ctx Context) IInfo
WithActivityOptions(ctx Context, options ActivityOptions) Context
WithChildOptions(ctx Context, cwo ChildWorkflowOptions) Context
SetQueryHandler(ctx Context, queryType string, handler interface{}) error
WithWorkflowDomain(ctx Context, name string) Context
WithWorkflowTaskList(ctx Context, name string) Context
ExecuteChildWorkflow(ctx Context, childWorkflow interface{}, args ...interface{}) ChildWorkflowFuture
NewCustomError(reason string, details ...interface{}) CustomError
NewFuture(ctx Context) (Future, Settable)
NewBatchFuture(ctx Context, batchSize int, factories []func(ctx Context) Future) (BatchFuture, error)
Go(ctx Context, f func(ctx Context))
SideEffect(ctx Context, f func(ctx Context) interface{}) encoded.Value
Now(ctx Context) time.Time
Sleep(ctx Context, d time.Duration) (err error)
IsCanceledError(ctx Context, err error) bool
WithRetryPolicy(ctx Context, retryPolicy RetryPolicy) Context
NewSelector(ctx Context) Selector
}
type WorkflowExecution ¶ added in v1.0.15
WorkflowExecution Details.
type WorkflowType ¶ added in v1.0.15
type WorkflowType struct {
// Name is the human-readable identifier for the workflow type.
// This is the name used when starting workflow executions and in workflow registration.
// Example: "ProcessOrderWorkflow", "user-onboarding", etc.
Name string
// Path contains the fully qualified path or package information for the workflow function.
// This provides technical details about where the workflow code is located.
// In Cadence: typically includes the full package path
// In Temporal: may not always be available (depends on implementation)
// Example: "github.com/myorg/workflows.ProcessOrderWorkflow"
Path string
}
WorkflowType identifies a workflow type with both human-readable name and technical path information. This structure provides metadata about workflow functions across different workflow engines.
type ZapLoggerAdapter ¶
type ZapLoggerAdapter struct {
// contains filtered or unexported fields
}
func NewZapLoggerAdapter ¶
func NewZapLoggerAdapter(z *zap.Logger) *ZapLoggerAdapter
func (*ZapLoggerAdapter) Debug ¶
func (l *ZapLoggerAdapter) Debug(msg string, keyvals ...interface{})
Implement go.temporal.io/sdk/log.Logger
func (*ZapLoggerAdapter) Error ¶
func (l *ZapLoggerAdapter) Error(msg string, keyvals ...interface{})
func (*ZapLoggerAdapter) Info ¶
func (l *ZapLoggerAdapter) Info(msg string, keyvals ...interface{})
func (*ZapLoggerAdapter) Warn ¶
func (l *ZapLoggerAdapter) Warn(msg string, keyvals ...interface{})
func (*ZapLoggerAdapter) With ¶
func (l *ZapLoggerAdapter) With(keyvals ...interface{}) log.Logger
func (*ZapLoggerAdapter) Zap ¶
func (l *ZapLoggerAdapter) Zap() *zap.Logger
Expose the underlying *zap.Logger