protoc-gen-go-temporal icon indicating copy to clipboard operation
protoc-gen-go-temporal copied to clipboard

Add WithDataConverter helper to relevant options

Open cludden opened this issue 2 years ago • 0 comments

          I see u create PR, however i continue mind and detect case:
  • use custom DataConverter for workflow

For ctx have func WithDataConverter() and this func not set filds in ChildWorkflowOptions - this struct not have field for it

Question: can we assume that DataConverter - option, and implement method WithDataConverter fot exlude using ctx func at all ?

example:

ctx = ctx.WithDataConverter(ctx, converter)
opts = examplev1.NewExampleV1WorkflowOptions().WithChildOptions(options)
examplev1.NewExampleV1(ctx, &examplev1.ExampleV1Request{}, opts)

->

if we assume that DataConverter - option:

opts = examplev1.NewExampleV1WorkflowOptions().WithChildOptions(options).WithDataConverter(conveter)
examplev1.NewExampleV1(ctx, &examplev1.ExampleV1Request{}, opts)

// in generated code:
type ExampleV1ChildOptions struct {
	opts                     *workflow.ChildWorkflowOptions
	// ...
	dataConverter            *converter.DataConverter
}

func ExampleV1Child(ctx workflow.Context, req *ExampleV1Request, options ...*ExampleV1ChildOptions) (*ExampleV1ChildRun, error) {
	opts := &workflow.ChildWorkflowOptions{}
	if len(options) > 0 && options[0].opts != nil {
		opts = options[0].opts
	}
	if opts.TaskQueue == "" {
		opts.TaskQueue = XnsTaskQueue
	}
	// ...
	ctx = workflow.WithChildOptions(ctx, *opts)
	if c := options[0].dataConverter; c != nil {
		ctx = workflow.WithDataConverter(ctx, *c)
	} 
        // ...
}

Originally posted by @SeJIya in https://github.com/cludden/protoc-gen-go-temporal/issues/58#issuecomment-2070154636

cludden avatar Apr 24 '24 01:04 cludden