-
Notifications
You must be signed in to change notification settings - Fork 255
Closed
temporalio/api-go
#216Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
When creating a common.Payload
and marshaling it into an Any
type, the visitor is not able to visit this scenario, due to a missing case *common.Payload
in visitPayloads()
.
This scenario is not used in our API today, but something we may want to support in the future.
Describe the solution you'd like
Implement this base case so we can visit this scenario.
Additional context
Here is a basic test I wrote to validate this new feature
func TestVisitPayloads_AnyPayload(t *testing.T) {
msg, err := anypb.New(inputPayload())
require.NoError(t, err)
root := &protocol.Message{Body: msg}
var anyCount int
err = VisitPayloads(context.Background(), root, VisitPayloadsOptions{
Visitor: func(ctx *VisitPayloadsContext, p []*common.Payload) ([]*common.Payload, error) {
anyCount++
// Only mutate if the payloads has "test"
if len(p) == 1 && string(p[0].Data) == "test" {
return []*common.Payload{{Data: []byte("new-val")}}, nil
}
return p, nil
},
})
require.NoError(t, err)
require.Equal(t, 1, anyCount)
update1, err := root.Body.UnmarshalNew()
require.NoError(t, err)
require.Equal(t, "new-val", string(update1.(*common.Payload).Data))
}
also see temporalio/api-go#202 (comment) for more context
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request