Support for interface params encoding and decoding

type CustomInterface  interface {
	Func1() []string
	Func2() int
}

type interfaceSatisfied struct{
}

func ( s *interfaceSatisfied)Func1() []string{
}

func ( s *interfaceSatisfied)Func1() Func2() int{
}

//workflow 
func Workflow1(ctx workflow.Context, ci CustomInterface) error {
if err := workflow.ExecuteActivity(actx, new(Helper).Activity1, ci).Get(ctx, &templates)
}

wfClient.ExecuteWorkflow(ctx, wfopts, Workflow1,ci) 

this execution gives no error and the worker is not picking up the task

the corresponding activity is :

type Helper struct {
}

func (s *Helper)Activity1((ctx Ctx,  ci CustomInterface) error{
}

observation: custom interfaces as a parameter are not supported directly in temporal for both workflow and activity.

for workflow it is not giving any error and appears like the worker no picking up the task, for activity, it is giving some conversion error

so is there any easy way to support this in temporal or do we need to use some encoder ( like gob) to convert data to bytes to pass around . ?

Any leads will be helpful,
Thanks in advance,
Junaid

By default Temporal SDKs use JSON as a serialization format. It doesn’t really support polymorphic serialization out of the box. I think Go gob encoder doesn’t support it as well. Your options are either do not use interface types as activity arguments or write your custom PayloadConverter that supports them.

1 Like

My colleague develop this solution for the case you mention

1 Like