Documentation
¶
Overview ¶
Package activity contains functions and types used to implement Cadence activities.
Index ¶
- Variables
- func GetLogger(ctx context.Context) *zap.Logger
- func GetMetricsScope(ctx context.Context) tally.Scope
- func RecordHeartbeat(ctx context.Context, details ...interface{})
- func Register(activityFunc interface{})
- func RegisterWithOptions(activityFunc interface{}, opts RegisterOptions)
- type Info
- type RegisterOptions
- type Type
Constants ¶
This section is empty.
Variables ¶
var ErrResultPending = internal.ErrActivityResultPending
ErrResultPending is returned from activity's implementation to indicate the activity is not completed when activity method returns. Activity needs to be completed by Client.CompleteActivity() separately. For example, if an activity require human interaction (like approve an expense report), the activity could return ErrResultPending which indicate the activity is not done yet. Then, when the waited human action happened, it needs to trigger something that could report the activity completed event to cadence server via Client.CompleteActivity() API.
Functions ¶
func GetMetricsScope ¶
GetMetricsScope returns a metrics scope that can be used in activity
func RecordHeartbeat ¶
RecordHeartbeat sends heartbeat for the currently executing activity If the activity is either cancelled (or) workflow/activity doesn't exist then we would cancel the context with error context.Canceled.
TODO: we don't have a way to distinguish between the two cases when context is cancelled because context doesn't support overriding value of ctx.Error. TODO: Implement automatic heartbeating with cancellation through ctx.
details - the details that you provided here can be seen in the workflow when it receives TimeoutError, you can check error TimeOutType()/Details().
func Register ¶
func Register(activityFunc interface{})
Register - calls RegisterWithOptions with default registration options.
func RegisterWithOptions ¶
func RegisterWithOptions(activityFunc interface{}, opts RegisterOptions)
RegisterWithOptions registers the activity function with options The user can use options to provide an external name for the activity or leave it empty if no external name is required. This can be used as
client.Register(barActivity, RegisterOptions{}) client.Register(barActivity, RegisterOptions{Name: "barExternal"})
An activity takes a context and input and returns a (result, error) or just error. Examples:
func sampleActivity(ctx context.Context, input []byte) (result []byte, err error) func sampleActivity(ctx context.Context, arg1 int, arg2 string) (result *customerStruct, err error) func sampleActivity(ctx context.Context) (err error) func sampleActivity() (result string, err error) func sampleActivity(arg1 bool) (result int, err error) func sampleActivity(arg1 bool) (err error)
Serialization of all primitive types, structures is supported ... except channels, functions, variadic, unsafe pointer. If function implementation returns activity.ErrResultPending then activity is not completed from the calling workflow point of view. See documentation of activity.ErrResultPending for more info. This method calls panic if activityFunc doesn't comply with the expected format.
Types ¶
type Info ¶
type Info = internal.ActivityInfo
Info contains information about a currently executing activity.
type RegisterOptions ¶
type RegisterOptions = internal.RegisterActivityOptions
RegisterOptions consists of options for registering an activity