Hello.
I’ve started to work with Temporal recently and maybe there are better ways to achieve my goals, but what makes my life really complex is the lack of type checking when I’m calling workflows and activities.
Especially, when they have a lot of parameters, it is very easy to make a mistake and pass them in the wrong order or just forget some parameters.
So what I’m doing now, for every workflow/activity I have, I create additional function prefixed with Args
. for example:
func MyActivityArgs(param1 string, param2 bool) []interface{} {
return []interface{}{param1, param2}
}
func MyActivity(ctx context.Context, param1 string, param2 bool) error {
// do something
return nil
}
This way it is much easier to use this activity - I’m getting type checks for free:
err := workflow.
ExecuteLocalActivity(ctx, activities.MyActivity,activities.MyActivityArgs("hello", true)...).
Get(ctx, nil)
Everything becomes much easier with such an approach, but one problem remains - ...
part to deconstruct the slice. It is easy to forget about it that will lead to bugs.
So what I was thinking about, maybe it is possible to add special type to Go SDK, e.g. sdk.Args
that is just an alias of []interface{}
. However, if a value of this type is passed as the first argument to workflow or activity, it should be recognized as a full list of parameters that need to be passed to workflow/activity.
This way it is possible to omit ...
part without any bugs.