Skip to main content

How to set RegisterActivityOptions in Go

Create an instance of RegisterOptions from the go.temporal.io/sdk/activity package and pass it to the RegisterActivityWithOptions call when registering the Activity Type with the Worker.

Options for registering an activity

FieldRequiredType
NameNostring
DisableAlreadyRegisteredCheckNobool
SkipInvalidStructFunctionsNobool

Name

Sets the Activity Type name.

  • Type: string
  • Default: function name
// ...
w := worker.New(temporalClient, "your_task_queue_name", worker.Options{})
registerOptions := activity.RegisterOptions{
Name: "CoolActivityTypeName",
// ...
}
w.RegisterActivityWithOptions(a.YourActivityDefinition, registerOptions)
// ...

DisableAlreadyRegisteredCheck

Disables the check to see if the Activity has already been registered.

  • Type: bool
  • Default: false
// ...
w := worker.New(temporalClient, "your_task_queue_name", worker.Options{})
registerOptions := activity.RegisterOptions{
DisableAlreadyRegisteredCheck: false,
// ...
}
w.RegisterActivityWithOptions(a.YourActivityDefinition, registerOptions)
// ...

SkipInvalidStructFunctions

When registering a struct that has Activities, skip functions that are not valid. If false, registration panics.

  • Type: bool
  • Default: false
// ...
w := worker.New(temporalClient, "your_task_queue_name", worker.Options{})
registerOptions := activity.RegisterOptions{
SkipInvalidStructFunctions: false,
// ...
}
w.RegisterActivityWithOptions(a.YourActivityDefinition, registerOptions)
// ...

Get notified of updates