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
Field | Required | Type |
---|---|---|
Name | No | string |
DisableAlreadyRegisteredCheck | No | bool |
SkipInvalidStructFunctions | No | bool |
Name
To customize the Activity Type, set the Name
parameter with RegisterOptions
when registering your Activity with a Worker.
- Type:
string
- Default: function name
// ...
w := worker.New(temporalClient, "your_task_queue_name", worker.Options{})
registerOptions := activity.RegisterOptions{
Name: "YourActivityName",
// ...
}
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)
// ...