diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e8f6e3d..5e757325 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### ⚠ BREAKING CHANGES ### Added +- [#77](https://github.com/cludden/protoc-gen-go-temporal/pull/77) use parent task queue for child workflows and activities ([Patch Version 77](https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue)) ### Changed diff --git a/buf.yaml b/buf.yaml index af6c9892..5e0eee30 100644 --- a/buf.yaml +++ b/buf.yaml @@ -11,6 +11,7 @@ modules: name: buf.build/cludden/protoc-gen-go-temporal - path: test/expression/proto - path: test/option/proto + - path: test/patch/proto - path: test/simple/proto - path: test/xnserr/proto deps: diff --git a/docs/docs/configuration/service.mdx b/docs/docs/configuration/service.mdx index 2e645abb..c236b66a 100644 --- a/docs/docs/configuration/service.mdx +++ b/docs/docs/configuration/service.mdx @@ -28,10 +28,10 @@ Controls how a particular [Patch](/docs/guides/patches) is implemented in genera service Example { option (temporal.v1.service) = { patches: [ - { version: PV_62, mode: PV_REMOVED }, - { version: PV_63, mode: PV_MARKER }, - { version: PV_64, mode: PV_ENABLED }, - { version: PV_65, mode: PV_DISABLED } + { version: PV_62, mode: PVM_REMOVED }, + { version: PV_63, mode: PVM_MARKER }, + { version: PV_64, mode: PVM_ENABLED }, + { version: PV_65, mode: PVM_DISABLED } ] }; } diff --git a/docs/docs/guides/clients.mdx b/docs/docs/guides/clients.mdx index 94d1b1a1..52c56b68 100644 --- a/docs/docs/guides/clients.mdx +++ b/docs/docs/guides/clients.mdx @@ -3,6 +3,151 @@ import TabItem from '@theme/TabItem'; # Clients -**Coming Soon...** +The plugin generates a typed client sdk for each protobuf service with temporal annotations. The client exposes synchronous and asynchronous methods for executing workflows, signals, queries, and updates. -## Workflow Run +## Constructors + +### NewClient + +A client can be initialized with an already configured [client.Client](https://pkg.go.dev/go.temporal.io/sdk/client#Client) instance using the `New{Service}Client` constructor function. + + + +```protobuf title="example.proto" +syntax = "proto3"; + +package example.v1; + +import "temporal/v1/temporal.proto"; + +service Example { + option (temporal.v1.service).task_queue = "example-v1"; + + rpc Hello(HelloInput) returns (HelloOutput) { + option (temporal.v1.workflow) = { + id: 'example.v1.Hello/${! subject.or("world") }' + execution_timeout: {seconds: 30} + }; + } +} + +message HelloInput { + string subject = 1; +} + +message HelloOutput { + string greeting = 1; +} +``` + + +```go title="main.go" +package main + +import ( + "fmt" + "log" + + examplev1 "path/to/gen/example/v1" + + "go.temporal.io/sdk/client" +) + +func main() { + // initialize temporal client + c, err := client.Dial(client.Options{}) + if err != nil { + log.Fatal(err) + } + defer c.Close() + + // initialize generated service client + example := examplev1.NewExampleClient(c) + + // execute synchronous workflow method + output, err := example.Hello(context.Background(), &examplev1.HelloInput{ + Subject: "World", + }) + if err != nil { + log.Fatalf("error executing %s workflow: %v", examplev1.HelloWorkflowName, err) + } + fmt.Println(output.String()) +} +``` + + + +### NewClientWithOptions + +It's also possible to initialize a client with explicit [client.Options](https://pkg.go.dev/go.temporal.io/sdk/client#Options) and an existing [client.Client](https://pkg.go.dev/go.temporal.io/sdk/client#Client) instance using the `New{Service}ClientWithOptions` constructor function. + +:::note +Options provided to this constructor will *completely* replace the existing client's options, so things like namespace must always be specified. +::: + +```go title="main.go" +package main + +import ( + "fmt" + "log" + + examplev1 "path/to/gen/example/v1" + + "go.temporal.io/sdk/client" +) + +func main() { + // initialize temporal client + c, err := client.Dial(client.Options{ + Namespace: "default" + }) + if err != nil { + log.Fatal(err) + } + defer c.Close() + + // initialize generated service client for a different namespace + example, err := examplev1.NewExampleClientWithOptions(c, client.Options{ + Namespace: "example", + }) + if err != nil { + log.Fatal(err) + } + + // execute synchronous workflow method + output, err := example.Hello(context.Background(), &examplev1.HelloInput{ + Subject: "World", + }) + if err != nil { + log.Fatalf("error executing %s workflow: %v", examplev1.HelloWorkflowName, err) + } + fmt.Println(output.String()) +} +``` + +## Workflows + +### Synchronous + +### Asynchronous + +### Workflow Run + +### Get + +### Cancel + +### Terminate + +## Queries + +## Signals + +### WithStart + +## Updates + +### Synchronous + +### Asynchronous diff --git a/docs/docs/guides/patches.mdx b/docs/docs/guides/patches.mdx index f9611dbd..6bf8f382 100644 --- a/docs/docs/guides/patches.mdx +++ b/docs/docs/guides/patches.mdx @@ -55,3 +55,13 @@ By default, patches are introduced in `PVM_ENABLED` mode, where both the patch c [protoc-gen-go-temporal#64](https://github.com/cludden/protoc-gen-go-temporal/issues/64) Wraps expression evaluation in local activities within workflow contexts (i.e. child workflow helpers). This prevents non-determinism errors when an expression contains non-deterministic statements and is evaluated in a long-running workflow that is rescheduled onto a different worker. + +### PV_77 Use Parent Task Queue + +[protoc-gen-go-temporal#77](https://github.com/cludden/protoc-gen-go-temporal/pulls/77) + +Defaults to using to the parent workflow task queue for child workflows and activities when the default task queue for the parent workflow matches the default task queue of the child workflow or activity. This allows for non-default task queue overrides to be honored by child workflows and activities. + +:::note +If child workflows and/or activities cross service boundaries, they will revert back to the previous behavior (i.e. using the configured default) unless the client is configured to use [patch.NewContextPropagator](https://pkg.go.dev/github.com/cludden/protoc-gen-go-temporal/pkg/patch#NewContextPropagator) +::: diff --git a/docs/docs/guides/signals.mdx b/docs/docs/guides/signals.mdx index e22912e2..d5f569be 100644 --- a/docs/docs/guides/signals.mdx +++ b/docs/docs/guides/signals.mdx @@ -38,7 +38,7 @@ import ( ) type FooWorkflow struct { - examplev1.FooWorkflowInput + *examplev1.FooWorkflowInput } func (w *FooWorkflow) Execute(ctx workflow.Context) (*examplev1.FooOutput, error) { diff --git a/gen/example/helloworld/v1/example_temporal.pb.go b/gen/example/helloworld/v1/example_temporal.pb.go index 2310668f..ce992384 100644 --- a/gen/example/helloworld/v1/example_temporal.pb.go +++ b/gen/example/helloworld/v1/example_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // @@ -16,6 +16,7 @@ import ( "fmt" expression "github.com/cludden/protoc-gen-go-temporal/pkg/expression" helpers "github.com/cludden/protoc-gen-go-temporal/pkg/helpers" + patch "github.com/cludden/protoc-gen-go-temporal/pkg/patch" scheme "github.com/cludden/protoc-gen-go-temporal/pkg/scheme" gohomedir "github.com/mitchellh/go-homedir" v2 "github.com/urfave/cli/v2" @@ -428,6 +429,8 @@ func buildHello(ctor func(workflow.Context, *HelloWorkflowInput) (HelloWorkflow, Channel: workflow.GetSignalChannel(ctx, GoodbyeSignalName), }, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, ExampleTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return nil, err @@ -534,7 +537,15 @@ func (o *HelloChildOptions) Build(ctx workflow.Context, req protoreflect.Message if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = ExampleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, ExampleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = ExampleTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v diff --git a/gen/example/helloworld/v1/helloworldv1xns/example_xns_temporal.pb.go b/gen/example/helloworld/v1/helloworldv1xns/example_xns_temporal.pb.go index 45fbe48d..0500ba03 100644 --- a/gen/example/helloworld/v1/helloworldv1xns/example_xns_temporal.pb.go +++ b/gen/example/helloworld/v1/helloworldv1xns/example_xns_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // diff --git a/gen/example/mutex/v1/mutex_temporal.pb.go b/gen/example/mutex/v1/mutex_temporal.pb.go index 7700f496..5a10006c 100644 --- a/gen/example/mutex/v1/mutex_temporal.pb.go +++ b/gen/example/mutex/v1/mutex_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // @@ -14,6 +14,7 @@ import ( "fmt" expression "github.com/cludden/protoc-gen-go-temporal/pkg/expression" helpers "github.com/cludden/protoc-gen-go-temporal/pkg/helpers" + patch "github.com/cludden/protoc-gen-go-temporal/pkg/patch" scheme "github.com/cludden/protoc-gen-go-temporal/pkg/scheme" gohomedir "github.com/mitchellh/go-homedir" v2 "github.com/urfave/cli/v2" @@ -746,6 +747,8 @@ func buildMutex(ctor func(workflow.Context, *MutexWorkflowInput) (MutexWorkflow, Channel: workflow.GetSignalChannel(ctx, ReleaseLockSignalName), }, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, ExampleTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return err @@ -853,7 +856,15 @@ func (o *MutexChildOptions) Build(ctx workflow.Context, req protoreflect.Message if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = ExampleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, ExampleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = ExampleTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -1027,6 +1038,8 @@ func buildSampleWorkflowWithMutex(ctor func(workflow.Context, *SampleWorkflowWit Channel: workflow.GetSignalChannel(ctx, LockAcquiredSignalName), }, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, ExampleTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return err @@ -1133,7 +1146,15 @@ func (o *SampleWorkflowWithMutexChildOptions) Build(ctx workflow.Context, req pr if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = ExampleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, ExampleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = ExampleTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -1579,7 +1600,15 @@ func (o *MutexActivityOptions) Build(ctx workflow.Context) (workflow.Context, er if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = ExampleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, ExampleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = ExampleTaskQueue + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v diff --git a/gen/example/mutex/v1/mutexv1xns/mutex_xns_temporal.pb.go b/gen/example/mutex/v1/mutexv1xns/mutex_xns_temporal.pb.go index 54ab846d..caa8a859 100644 --- a/gen/example/mutex/v1/mutexv1xns/mutex_xns_temporal.pb.go +++ b/gen/example/mutex/v1/mutexv1xns/mutex_xns_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // diff --git a/gen/example/schedule/v1/schedule_temporal.pb.go b/gen/example/schedule/v1/schedule_temporal.pb.go index a4f51c4b..e13898c5 100644 --- a/gen/example/schedule/v1/schedule_temporal.pb.go +++ b/gen/example/schedule/v1/schedule_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // @@ -15,6 +15,7 @@ import ( "errors" "fmt" helpers "github.com/cludden/protoc-gen-go-temporal/pkg/helpers" + patch "github.com/cludden/protoc-gen-go-temporal/pkg/patch" scheme "github.com/cludden/protoc-gen-go-temporal/pkg/scheme" gohomedir "github.com/mitchellh/go-homedir" v2 "github.com/urfave/cli/v2" @@ -392,6 +393,8 @@ func buildSchedule(ctor func(workflow.Context, *ScheduleWorkflowInput) (Schedule input := &ScheduleWorkflowInput{ Req: req, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, ExampleTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return nil, err @@ -473,7 +476,15 @@ func (o *ScheduleChildOptions) Build(ctx workflow.Context, req protoreflect.Mess if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = ExampleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, ExampleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = ExampleTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v diff --git a/gen/example/schedule/v1/schedulev1xns/schedule_xns_temporal.pb.go b/gen/example/schedule/v1/schedulev1xns/schedule_xns_temporal.pb.go index 46cafc44..cbf0a75f 100644 --- a/gen/example/schedule/v1/schedulev1xns/schedule_xns_temporal.pb.go +++ b/gen/example/schedule/v1/schedulev1xns/schedule_xns_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // diff --git a/gen/example/searchattributes/v1/searchattributes_temporal.pb.go b/gen/example/searchattributes/v1/searchattributes_temporal.pb.go index 5a11a58e..656ea4de 100644 --- a/gen/example/searchattributes/v1/searchattributes_temporal.pb.go +++ b/gen/example/searchattributes/v1/searchattributes_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // @@ -14,6 +14,7 @@ import ( "fmt" expression "github.com/cludden/protoc-gen-go-temporal/pkg/expression" helpers "github.com/cludden/protoc-gen-go-temporal/pkg/helpers" + patch "github.com/cludden/protoc-gen-go-temporal/pkg/patch" scheme "github.com/cludden/protoc-gen-go-temporal/pkg/scheme" gohomedir "github.com/mitchellh/go-homedir" v2 "github.com/urfave/cli/v2" @@ -418,6 +419,8 @@ func buildSearchAttributes(ctor func(workflow.Context, *SearchAttributesWorkflow input := &SearchAttributesWorkflowInput{ Req: req, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, ExampleTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return err @@ -523,7 +526,15 @@ func (o *SearchAttributesChildOptions) Build(ctx workflow.Context, req protorefl if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = ExampleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, ExampleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = ExampleTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v diff --git a/gen/example/searchattributes/v1/searchattributesv1xns/searchattributes_xns_temporal.pb.go b/gen/example/searchattributes/v1/searchattributesv1xns/searchattributes_xns_temporal.pb.go index c722f2b4..0452e0a4 100644 --- a/gen/example/searchattributes/v1/searchattributesv1xns/searchattributes_xns_temporal.pb.go +++ b/gen/example/searchattributes/v1/searchattributesv1xns/searchattributes_xns_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // diff --git a/gen/example/updatabletimer/v1/updatabletimer_temporal.pb.go b/gen/example/updatabletimer/v1/updatabletimer_temporal.pb.go index 94d75418..246b90e6 100644 --- a/gen/example/updatabletimer/v1/updatabletimer_temporal.pb.go +++ b/gen/example/updatabletimer/v1/updatabletimer_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // @@ -16,6 +16,7 @@ import ( "fmt" expression "github.com/cludden/protoc-gen-go-temporal/pkg/expression" helpers "github.com/cludden/protoc-gen-go-temporal/pkg/helpers" + patch "github.com/cludden/protoc-gen-go-temporal/pkg/patch" scheme "github.com/cludden/protoc-gen-go-temporal/pkg/scheme" gohomedir "github.com/mitchellh/go-homedir" v2 "github.com/urfave/cli/v2" @@ -452,6 +453,8 @@ func buildUpdatableTimer(ctor func(workflow.Context, *UpdatableTimerWorkflowInpu Channel: workflow.GetSignalChannel(ctx, UpdateWakeUpTimeSignalName), }, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, ExampleTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return err @@ -564,7 +567,15 @@ func (o *UpdatableTimerChildOptions) Build(ctx workflow.Context, req protoreflec if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = ExampleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, ExampleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = ExampleTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v diff --git a/gen/example/updatabletimer/v1/updatabletimerv1xns/updatabletimer_xns_temporal.pb.go b/gen/example/updatabletimer/v1/updatabletimerv1xns/updatabletimer_xns_temporal.pb.go index 2033fdc7..b009ca59 100644 --- a/gen/example/updatabletimer/v1/updatabletimerv1xns/updatabletimer_xns_temporal.pb.go +++ b/gen/example/updatabletimer/v1/updatabletimerv1xns/updatabletimer_xns_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // diff --git a/gen/example/v1/example_temporal.pb.go b/gen/example/v1/example_temporal.pb.go index 292fd537..3d2a4b7f 100644 --- a/gen/example/v1/example_temporal.pb.go +++ b/gen/example/v1/example_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // @@ -16,6 +16,7 @@ import ( "fmt" expression "github.com/cludden/protoc-gen-go-temporal/pkg/expression" helpers "github.com/cludden/protoc-gen-go-temporal/pkg/helpers" + patch "github.com/cludden/protoc-gen-go-temporal/pkg/patch" scheme "github.com/cludden/protoc-gen-go-temporal/pkg/scheme" testutil "github.com/cludden/protoc-gen-go-temporal/pkg/testutil" gohomedir "github.com/mitchellh/go-homedir" @@ -718,6 +719,8 @@ func buildCreateFoo(ctor func(workflow.Context, *CreateFooWorkflowInput) (Create Channel: workflow.GetSignalChannel(ctx, SetFooProgressSignalName), }, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, ExampleTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return nil, err @@ -841,7 +844,15 @@ func (o *CreateFooChildOptions) Build(ctx workflow.Context, req protoreflect.Mes if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = ExampleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, ExampleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = ExampleTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -1176,7 +1187,15 @@ func (o *NotifyActivityOptions) Build(ctx workflow.Context) (workflow.Context, e if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = ExampleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, ExampleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = ExampleTaskQueue + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v diff --git a/gen/example/v1/examplev1xns/example_xns_temporal.pb.go b/gen/example/v1/examplev1xns/example_xns_temporal.pb.go index 82b8da54..3e0fbe65 100644 --- a/gen/example/v1/examplev1xns/example_xns_temporal.pb.go +++ b/gen/example/v1/examplev1xns/example_xns_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // diff --git a/gen/example/xns/v1/xns_temporal.pb.go b/gen/example/xns/v1/xns_temporal.pb.go index 8a254bbd..519eb073 100644 --- a/gen/example/xns/v1/xns_temporal.pb.go +++ b/gen/example/xns/v1/xns_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // @@ -16,6 +16,7 @@ import ( "fmt" expression "github.com/cludden/protoc-gen-go-temporal/pkg/expression" helpers "github.com/cludden/protoc-gen-go-temporal/pkg/helpers" + patch "github.com/cludden/protoc-gen-go-temporal/pkg/patch" scheme "github.com/cludden/protoc-gen-go-temporal/pkg/scheme" testutil "github.com/cludden/protoc-gen-go-temporal/pkg/testutil" gohomedir "github.com/mitchellh/go-homedir" @@ -408,6 +409,8 @@ func buildProvisionFoo(ctor func(workflow.Context, *ProvisionFooWorkflowInput) ( input := &ProvisionFooWorkflowInput{ Req: req, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, XnsTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return nil, err @@ -513,7 +516,15 @@ func (o *ProvisionFooChildOptions) Build(ctx workflow.Context, req protoreflect. if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = XnsTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, XnsTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = XnsTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -1665,6 +1676,8 @@ func buildCreateFoo(ctor func(workflow.Context, *CreateFooWorkflowInput) (Create Channel: workflow.GetSignalChannel(ctx, SetFooProgressSignalName), }, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, ExampleTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return nil, err @@ -1788,7 +1801,15 @@ func (o *CreateFooChildOptions) Build(ctx workflow.Context, req protoreflect.Mes if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = ExampleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, ExampleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = ExampleTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -2123,7 +2144,15 @@ func (o *NotifyActivityOptions) Build(ctx workflow.Context) (workflow.Context, e if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = ExampleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, ExampleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = ExampleTaskQueue + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v diff --git a/gen/example/xns/v1/xnsv1xns/xns_xns_temporal.pb.go b/gen/example/xns/v1/xnsv1xns/xns_xns_temporal.pb.go index a943672c..a80e68d6 100644 --- a/gen/example/xns/v1/xnsv1xns/xns_xns_temporal.pb.go +++ b/gen/example/xns/v1/xnsv1xns/xns_xns_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // diff --git a/gen/temporal/v1/temporal.pb.go b/gen/temporal/v1/temporal.pb.go index dce212ae..168cc972 100644 --- a/gen/temporal/v1/temporal.pb.go +++ b/gen/temporal/v1/temporal.pb.go @@ -252,6 +252,9 @@ const ( // wraps expression evaluation in local activities within workflow contexts // details: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/fix-versions#fix_version_64_expression_evaluation_local_activity Patch_PV_64 Patch_Version = 1 + // uses parent workflow task queue for child workflows, instead of service default + // details: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/fix-versions#fix_version_77_use_parent_task_queue + Patch_PV_77 Patch_Version = 2 ) // Enum value maps for Patch_Version. @@ -259,10 +262,12 @@ var ( Patch_Version_name = map[int32]string{ 0: "PV_UNSPECIFIED", 1: "PV_64", + 2: "PV_77", } Patch_Version_value = map[string]int32{ "PV_UNSPECIFIED": 0, "PV_64": 1, + "PV_77": 2, } ) @@ -375,6 +380,8 @@ type ActivityOptions struct { WaitForCancellation bool `protobuf:"varint,8,opt,name=wait_for_cancellation,json=waitForCancellation,proto3" json:"wait_for_cancellation,omitempty"` // Specifies how to retry an Activity if an error occurs RetryPolicy *RetryPolicy `protobuf:"bytes,6,opt,name=retry_policy,json=retryPolicy,proto3" json:"retry_policy,omitempty"` + // Configure patches, by default, patches are introduced in enabled mode + Patches []*Patch `protobuf:"bytes,9,rep,name=patches,proto3" json:"patches,omitempty"` } func (x *ActivityOptions) Reset() { @@ -465,6 +472,13 @@ func (x *ActivityOptions) GetRetryPolicy() *RetryPolicy { return nil } +func (x *ActivityOptions) GetPatches() []*Patch { + if x != nil { + return x.Patches + } + return nil +} + type CLIOptions struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1628,7 +1642,7 @@ var file_temporal_v1_temporal_proto_rawDesc = []byte{ 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf9, 0x03, 0x0a, 0x0f, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa7, 0x04, 0x0a, 0x0f, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x71, 0x75, 0x65, 0x75, @@ -1660,295 +1674,299 @@ var file_temporal_v1_temporal_proto_rawDesc = []byte{ 0x74, 0x72, 0x79, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0b, 0x72, 0x65, 0x74, 0x72, - 0x79, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x22, 0x24, 0x0a, 0x0a, 0x43, 0x4c, 0x49, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x22, 0x28, 0x0a, - 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, - 0x16, 0x0a, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x22, 0xe0, 0x01, 0x0a, 0x05, 0x50, 0x61, 0x74, 0x63, - 0x68, 0x12, 0x34, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, - 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, - 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, - 0x6d, 0x6f, 0x64, 0x65, 0x22, 0x28, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x12, 0x0a, 0x0e, 0x50, 0x56, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, - 0x44, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x56, 0x5f, 0x36, 0x34, 0x10, 0x01, 0x22, 0x4a, - 0x0a, 0x04, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x56, 0x4d, 0x5f, 0x45, 0x4e, - 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x50, 0x56, 0x4d, 0x5f, 0x4d, - 0x41, 0x52, 0x4b, 0x45, 0x52, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x56, 0x4d, 0x5f, 0x52, - 0x45, 0x4d, 0x4f, 0x56, 0x45, 0x44, 0x10, 0x02, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x56, 0x4d, 0x5f, - 0x44, 0x49, 0x53, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x03, 0x22, 0x83, 0x01, 0x0a, 0x0c, 0x51, - 0x75, 0x65, 0x72, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x79, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, + 0x65, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, + 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, 0x52, 0x07, 0x70, 0x61, + 0x74, 0x63, 0x68, 0x65, 0x73, 0x22, 0x24, 0x0a, 0x0a, 0x43, 0x4c, 0x49, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x22, 0x28, 0x0a, 0x0e, 0x43, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x16, 0x0a, + 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, + 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x22, 0xeb, 0x01, 0x0a, 0x05, 0x50, 0x61, 0x74, 0x63, 0x68, 0x12, + 0x34, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x1a, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, + 0x61, 0x74, 0x63, 0x68, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, + 0x31, 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, + 0x64, 0x65, 0x22, 0x33, 0x0a, 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, + 0x0e, 0x50, 0x56, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, + 0x00, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x56, 0x5f, 0x36, 0x34, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, + 0x50, 0x56, 0x5f, 0x37, 0x37, 0x10, 0x02, 0x22, 0x4a, 0x0a, 0x04, 0x4d, 0x6f, 0x64, 0x65, 0x12, + 0x0f, 0x0a, 0x0b, 0x50, 0x56, 0x4d, 0x5f, 0x45, 0x4e, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x00, + 0x12, 0x0e, 0x0a, 0x0a, 0x50, 0x56, 0x4d, 0x5f, 0x4d, 0x41, 0x52, 0x4b, 0x45, 0x52, 0x10, 0x01, + 0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x56, 0x4d, 0x5f, 0x52, 0x45, 0x4d, 0x4f, 0x56, 0x45, 0x44, 0x10, + 0x02, 0x12, 0x10, 0x0a, 0x0c, 0x50, 0x56, 0x4d, 0x5f, 0x44, 0x49, 0x53, 0x41, 0x42, 0x4c, 0x45, + 0x44, 0x10, 0x03, 0x22, 0x83, 0x01, 0x0a, 0x0c, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x31, 0x0a, 0x03, 0x78, 0x6e, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, + 0x2e, 0x76, 0x31, 0x2e, 0x58, 0x4e, 0x53, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x03, 0x78, 0x6e, 0x73, 0x12, 0x2c, 0x0a, 0x07, 0x70, + 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x74, + 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, + 0x52, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x22, 0xa0, 0x02, 0x0a, 0x0b, 0x52, 0x65, + 0x74, 0x72, 0x79, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x44, 0x0a, 0x10, 0x69, 0x6e, 0x69, + 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0f, + 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, + 0x2f, 0x0a, 0x13, 0x62, 0x61, 0x63, 0x6b, 0x6f, 0x66, 0x66, 0x5f, 0x63, 0x6f, 0x65, 0x66, 0x66, + 0x69, 0x63, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x52, 0x12, 0x62, 0x61, + 0x63, 0x6b, 0x6f, 0x66, 0x66, 0x43, 0x6f, 0x65, 0x66, 0x66, 0x69, 0x63, 0x69, 0x65, 0x6e, 0x74, + 0x12, 0x3c, 0x0a, 0x0c, 0x6d, 0x61, 0x78, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x0b, 0x6d, 0x61, 0x78, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x21, + 0x0a, 0x0c, 0x6d, 0x61, 0x78, 0x5f, 0x61, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x6d, 0x61, 0x78, 0x41, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, + 0x73, 0x12, 0x39, 0x0a, 0x19, 0x6e, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x74, 0x72, 0x79, 0x61, 0x62, + 0x6c, 0x65, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x05, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x16, 0x6e, 0x6f, 0x6e, 0x52, 0x65, 0x74, 0x72, 0x79, 0x61, 0x62, + 0x6c, 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x54, 0x79, 0x70, 0x65, 0x73, 0x22, 0x7f, 0x0a, 0x0e, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2c, + 0x0a, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x12, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, + 0x74, 0x63, 0x68, 0x52, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x09, + 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x02, 0x18, 0x01, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1d, + 0x0a, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x71, 0x75, 0x65, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x74, 0x61, 0x73, 0x6b, 0x51, 0x75, 0x65, 0x75, 0x65, 0x22, 0x84, 0x01, + 0x0a, 0x0d, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x31, 0x0a, 0x03, 0x78, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1f, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x58, + 0x4e, 0x53, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x52, 0x03, 0x78, 0x6e, 0x73, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, + 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, + 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, 0x52, 0x07, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x65, 0x73, 0x22, 0xad, 0x02, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x61, + 0x74, 0x63, 0x68, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x74, 0x65, + 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, 0x52, + 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x76, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x12, 0x3d, 0x0a, 0x0e, 0x77, 0x61, 0x69, 0x74, 0x5f, 0x66, 0x6f, 0x72, + 0x5f, 0x73, 0x74, 0x61, 0x67, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x74, + 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x61, 0x69, 0x74, 0x50, + 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0c, 0x77, 0x61, 0x69, 0x74, 0x46, 0x6f, 0x72, 0x53, 0x74, + 0x61, 0x67, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x77, 0x61, 0x69, 0x74, 0x5f, 0x70, 0x6f, 0x6c, 0x69, + 0x63, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, + 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x61, 0x69, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, + 0x79, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0a, 0x77, 0x61, 0x69, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, + 0x79, 0x12, 0x31, 0x0a, 0x03, 0x78, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, + 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x58, 0x4e, 0x53, + 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, + 0x03, 0x78, 0x6e, 0x73, 0x22, 0x9b, 0x09, 0x0a, 0x0f, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, + 0x77, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, + 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x61, + 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x12, 0x38, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, + 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, + 0x12, 0x3b, 0x0a, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x23, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x57, + 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, + 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x52, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x12, 0x3b, 0x0a, + 0x06, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, + 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, + 0x66, 0x6c, 0x6f, 0x77, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x52, 0x06, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x46, 0x0a, 0x11, 0x65, 0x78, + 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x10, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x6f, + 0x75, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x42, 0x0a, 0x0f, 0x69, 0x64, 0x5f, 0x72, 0x65, 0x75, 0x73, 0x65, 0x5f, 0x70, + 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x74, 0x65, + 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x44, 0x52, 0x65, 0x75, 0x73, + 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0d, 0x69, 0x64, 0x52, 0x65, 0x75, 0x73, 0x65, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x20, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x02, 0x18, 0x01, 0x52, 0x09, 0x6e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x4e, 0x0a, 0x13, 0x70, 0x61, 0x72, 0x65, + 0x6e, 0x74, 0x5f, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, + 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x50, + 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x11, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, + 0x73, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x63, + 0x68, 0x65, 0x73, 0x18, 0x12, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x74, 0x65, 0x6d, 0x70, + 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, 0x52, 0x07, 0x70, + 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x12, 0x3b, 0x0a, 0x0c, 0x72, 0x65, 0x74, 0x72, 0x79, 0x5f, + 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x74, + 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x74, 0x72, 0x79, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0b, 0x72, 0x65, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x6c, + 0x69, 0x63, 0x79, 0x12, 0x3a, 0x0a, 0x0b, 0x72, 0x75, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, + 0x75, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x72, 0x75, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, + 0x2b, 0x0a, 0x11, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, + 0x75, 0x74, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x73, 0x65, 0x61, 0x72, + 0x63, 0x68, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, + 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x71, 0x75, 0x65, 0x75, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x74, 0x61, 0x73, 0x6b, 0x51, 0x75, 0x65, 0x75, 0x65, 0x12, 0x3c, 0x0a, 0x0c, 0x74, + 0x61, 0x73, 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x0c, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x74, 0x61, + 0x73, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x77, 0x61, 0x69, + 0x74, 0x5f, 0x66, 0x6f, 0x72, 0x5f, 0x63, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x77, 0x61, 0x69, 0x74, 0x46, 0x6f, + 0x72, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x31, 0x0a, + 0x03, 0x78, 0x6e, 0x73, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x65, 0x6d, + 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x58, 0x4e, 0x53, 0x41, 0x63, 0x74, 0x69, + 0x76, 0x69, 0x74, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x03, 0x78, 0x6e, 0x73, + 0x1a, 0x4c, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x65, 0x66, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x65, 0x66, 0x12, 0x31, 0x0a, 0x03, 0x78, + 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, + 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x58, 0x4e, 0x53, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, + 0x74, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x03, 0x78, 0x6e, 0x73, 0x1a, 0x63, + 0x0a, 0x06, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x65, 0x66, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x65, 0x66, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, + 0x61, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, + 0x12, 0x31, 0x0a, 0x03, 0x78, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, + 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x58, 0x4e, 0x53, 0x41, + 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x03, + 0x78, 0x6e, 0x73, 0x1a, 0x4d, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x10, 0x0a, + 0x03, 0x72, 0x65, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x65, 0x66, 0x12, 0x31, 0x0a, 0x03, 0x78, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x58, 0x4e, 0x53, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x03, 0x78, - 0x6e, 0x73, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x18, 0x03, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, - 0x31, 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, 0x52, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, - 0x22, 0xa0, 0x02, 0x0a, 0x0b, 0x52, 0x65, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, - 0x12, 0x44, 0x0a, 0x10, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0f, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x49, 0x6e, - 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x2f, 0x0a, 0x13, 0x62, 0x61, 0x63, 0x6b, 0x6f, 0x66, - 0x66, 0x5f, 0x63, 0x6f, 0x65, 0x66, 0x66, 0x69, 0x63, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x01, 0x52, 0x12, 0x62, 0x61, 0x63, 0x6b, 0x6f, 0x66, 0x66, 0x43, 0x6f, 0x65, 0x66, - 0x66, 0x69, 0x63, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x3c, 0x0a, 0x0c, 0x6d, 0x61, 0x78, 0x5f, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x6d, 0x61, 0x78, 0x49, 0x6e, 0x74, - 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x61, 0x78, 0x5f, 0x61, 0x74, 0x74, - 0x65, 0x6d, 0x70, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x6d, 0x61, 0x78, - 0x41, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73, 0x12, 0x39, 0x0a, 0x19, 0x6e, 0x6f, 0x6e, 0x5f, - 0x72, 0x65, 0x74, 0x72, 0x79, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, - 0x74, 0x79, 0x70, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x16, 0x6e, 0x6f, 0x6e, - 0x52, 0x65, 0x74, 0x72, 0x79, 0x61, 0x62, 0x6c, 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x54, 0x79, - 0x70, 0x65, 0x73, 0x22, 0x7f, 0x0a, 0x0e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, - 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, 0x52, 0x07, 0x70, 0x61, 0x74, 0x63, - 0x68, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x02, 0x18, 0x01, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x71, 0x75, - 0x65, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x61, 0x73, 0x6b, 0x51, - 0x75, 0x65, 0x75, 0x65, 0x22, 0x84, 0x01, 0x0a, 0x0d, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x4f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x31, 0x0a, 0x03, 0x78, 0x6e, - 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, - 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x58, 0x4e, 0x53, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, - 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x03, 0x78, 0x6e, 0x73, 0x12, 0x2c, 0x0a, - 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, - 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x74, - 0x63, 0x68, 0x52, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x22, 0xad, 0x02, 0x0a, 0x0d, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, - 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, 0x52, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x12, - 0x1a, 0x0a, 0x08, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x08, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x12, 0x3d, 0x0a, 0x0e, 0x77, - 0x61, 0x69, 0x74, 0x5f, 0x66, 0x6f, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x67, 0x65, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, - 0x31, 0x2e, 0x57, 0x61, 0x69, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0c, 0x77, 0x61, - 0x69, 0x74, 0x46, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x67, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x77, 0x61, - 0x69, 0x74, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x17, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x61, - 0x69, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0a, 0x77, 0x61, - 0x69, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x31, 0x0a, 0x03, 0x78, 0x6e, 0x73, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, - 0x2e, 0x76, 0x31, 0x2e, 0x58, 0x4e, 0x53, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x03, 0x78, 0x6e, 0x73, 0x22, 0x9b, 0x09, 0x0a, 0x0f, - 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18, 0x11, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x12, 0x38, 0x0a, - 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x74, - 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, - 0x6c, 0x6f, 0x77, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x3b, 0x0a, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x61, - 0x6c, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, - 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x52, 0x06, 0x73, 0x69, - 0x67, 0x6e, 0x61, 0x6c, 0x12, 0x3b, 0x0a, 0x06, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, - 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x4f, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x06, 0x75, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x12, 0x46, 0x0a, 0x11, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x10, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, - 0x6f, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x42, 0x0a, 0x0f, 0x69, 0x64, 0x5f, - 0x72, 0x65, 0x75, 0x73, 0x65, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, - 0x2e, 0x49, 0x44, 0x52, 0x65, 0x75, 0x73, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0d, - 0x69, 0x64, 0x52, 0x65, 0x75, 0x73, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x20, 0x0a, - 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x02, 0x18, 0x01, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, - 0x4e, 0x0a, 0x13, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x5f, - 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x74, - 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x65, 0x6e, - 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x11, 0x70, 0x61, - 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, - 0x2c, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x18, 0x12, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x12, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, - 0x61, 0x74, 0x63, 0x68, 0x52, 0x07, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x12, 0x3b, 0x0a, - 0x0c, 0x72, 0x65, 0x74, 0x72, 0x79, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, - 0x31, 0x2e, 0x52, 0x65, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0b, 0x72, - 0x65, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x3a, 0x0a, 0x0b, 0x72, 0x75, - 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x6e, 0x73, 0x22, 0xe2, 0x04, 0x0a, 0x12, 0x58, 0x4e, 0x53, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, + 0x74, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, + 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x71, 0x75, 0x65, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x74, 0x61, 0x73, 0x6b, 0x51, 0x75, 0x65, 0x75, 0x65, 0x12, 0x54, 0x0a, 0x19, + 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x6c, 0x6f, 0x73, + 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x72, 0x75, 0x6e, 0x54, - 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x2b, 0x0a, 0x11, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, - 0x5f, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x10, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, - 0x74, 0x65, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x71, 0x75, 0x65, 0x75, - 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x61, 0x73, 0x6b, 0x51, 0x75, 0x65, - 0x75, 0x65, 0x12, 0x3c, 0x0a, 0x0c, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, - 0x75, 0x74, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x16, 0x73, 0x63, 0x68, 0x65, + 0x64, 0x75, 0x6c, 0x65, 0x54, 0x6f, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, + 0x75, 0x74, 0x12, 0x54, 0x0a, 0x19, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x74, + 0x6f, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x16, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x6f, 0x53, 0x74, 0x61, 0x72, + 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x4e, 0x0a, 0x16, 0x73, 0x74, 0x61, 0x72, + 0x74, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, + 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x74, 0x61, 0x73, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, - 0x12, 0x32, 0x0a, 0x15, 0x77, 0x61, 0x69, 0x74, 0x5f, 0x66, 0x6f, 0x72, 0x5f, 0x63, 0x61, 0x6e, - 0x63, 0x65, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x13, 0x77, 0x61, 0x69, 0x74, 0x46, 0x6f, 0x72, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x6c, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x31, 0x0a, 0x03, 0x78, 0x6e, 0x73, 0x18, 0x10, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, - 0x58, 0x4e, 0x53, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x52, 0x03, 0x78, 0x6e, 0x73, 0x1a, 0x4c, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x72, 0x65, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, - 0x65, 0x66, 0x12, 0x31, 0x0a, 0x03, 0x78, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1f, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x58, 0x4e, - 0x53, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x52, 0x03, 0x78, 0x6e, 0x73, 0x1a, 0x63, 0x0a, 0x06, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x12, - 0x10, 0x0a, 0x03, 0x72, 0x65, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x65, - 0x66, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x31, 0x0a, 0x03, 0x78, 0x6e, 0x73, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, - 0x76, 0x31, 0x2e, 0x58, 0x4e, 0x53, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x03, 0x78, 0x6e, 0x73, 0x1a, 0x4d, 0x0a, 0x06, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x65, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x72, 0x65, 0x66, 0x12, 0x31, 0x0a, 0x03, 0x78, 0x6e, 0x73, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, - 0x31, 0x2e, 0x58, 0x4e, 0x53, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x03, 0x78, 0x6e, 0x73, 0x22, 0xe2, 0x04, 0x0a, 0x12, 0x58, 0x4e, - 0x53, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x71, 0x75, 0x65, - 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x61, 0x73, 0x6b, 0x51, 0x75, - 0x65, 0x75, 0x65, 0x12, 0x54, 0x0a, 0x19, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x5f, - 0x74, 0x6f, 0x5f, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x16, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x54, 0x6f, 0x43, 0x6c, 0x6f, - 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x54, 0x0a, 0x19, 0x73, 0x63, 0x68, - 0x65, 0x64, 0x75, 0x6c, 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, - 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x16, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, - 0x65, 0x54, 0x6f, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, - 0x4e, 0x0a, 0x16, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x6f, 0x5f, 0x63, 0x6c, 0x6f, 0x73, - 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x73, 0x74, 0x61, 0x72, - 0x74, 0x54, 0x6f, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, - 0x48, 0x0a, 0x12, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x5f, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x11, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, - 0x74, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x46, 0x0a, 0x11, 0x68, 0x65, 0x61, - 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x05, + 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x6f, 0x43, 0x6c, 0x6f, 0x73, + 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x48, 0x0a, 0x12, 0x68, 0x65, 0x61, 0x72, + 0x74, 0x62, 0x65, 0x61, 0x74, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x10, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, - 0x74, 0x12, 0x3b, 0x0a, 0x0c, 0x72, 0x65, 0x74, 0x72, 0x79, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, - 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, - 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x6c, 0x69, 0x63, - 0x79, 0x52, 0x0b, 0x72, 0x65, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x4e, - 0x0a, 0x13, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x5f, 0x70, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x74, 0x65, - 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, - 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x11, 0x70, 0x61, 0x72, - 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2a, 0x3f, - 0x0a, 0x0a, 0x43, 0x4c, 0x49, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x14, - 0x43, 0x4c, 0x49, 0x5f, 0x46, 0x45, 0x41, 0x54, 0x55, 0x52, 0x45, 0x5f, 0x44, 0x49, 0x53, 0x41, - 0x4c, 0x42, 0x45, 0x44, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x43, 0x4c, 0x49, 0x5f, 0x46, 0x45, - 0x41, 0x54, 0x55, 0x52, 0x45, 0x5f, 0x45, 0x4e, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x01, 0x2a, - 0x83, 0x02, 0x0a, 0x0d, 0x49, 0x44, 0x52, 0x65, 0x75, 0x73, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, - 0x79, 0x12, 0x28, 0x0a, 0x24, 0x57, 0x4f, 0x52, 0x4b, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x49, 0x44, - 0x5f, 0x52, 0x45, 0x55, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x55, 0x4e, - 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x2c, 0x0a, 0x28, 0x57, + 0x11, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, + 0x61, 0x6c, 0x12, 0x46, 0x0a, 0x11, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x10, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, + 0x65, 0x61, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x3b, 0x0a, 0x0c, 0x72, 0x65, + 0x74, 0x72, 0x79, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x18, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x52, + 0x65, 0x74, 0x72, 0x79, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0b, 0x72, 0x65, 0x74, 0x72, + 0x79, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x4e, 0x0a, 0x13, 0x70, 0x61, 0x72, 0x65, 0x6e, + 0x74, 0x5f, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1e, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, + 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x50, 0x6f, + 0x6c, 0x69, 0x63, 0x79, 0x52, 0x11, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, + 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2a, 0x3f, 0x0a, 0x0a, 0x43, 0x4c, 0x49, 0x46, 0x65, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4c, 0x49, 0x5f, 0x46, 0x45, 0x41, + 0x54, 0x55, 0x52, 0x45, 0x5f, 0x44, 0x49, 0x53, 0x41, 0x4c, 0x42, 0x45, 0x44, 0x10, 0x00, 0x12, + 0x17, 0x0a, 0x13, 0x43, 0x4c, 0x49, 0x5f, 0x46, 0x45, 0x41, 0x54, 0x55, 0x52, 0x45, 0x5f, 0x45, + 0x4e, 0x41, 0x42, 0x4c, 0x45, 0x44, 0x10, 0x01, 0x2a, 0x83, 0x02, 0x0a, 0x0d, 0x49, 0x44, 0x52, + 0x65, 0x75, 0x73, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x28, 0x0a, 0x24, 0x57, 0x4f, + 0x52, 0x4b, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x45, 0x55, 0x53, 0x45, 0x5f, + 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, + 0x45, 0x44, 0x10, 0x00, 0x12, 0x2c, 0x0a, 0x28, 0x57, 0x4f, 0x52, 0x4b, 0x46, 0x4c, 0x4f, 0x57, + 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x45, 0x55, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, + 0x5f, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x44, 0x55, 0x50, 0x4c, 0x49, 0x43, 0x41, 0x54, 0x45, + 0x10, 0x01, 0x12, 0x38, 0x0a, 0x34, 0x57, 0x4f, 0x52, 0x4b, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x49, + 0x44, 0x5f, 0x52, 0x45, 0x55, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x41, + 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x44, 0x55, 0x50, 0x4c, 0x49, 0x43, 0x41, 0x54, 0x45, 0x5f, 0x46, + 0x41, 0x49, 0x4c, 0x45, 0x44, 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x02, 0x12, 0x2d, 0x0a, 0x29, + 0x57, 0x4f, 0x52, 0x4b, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x45, 0x55, 0x53, + 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x5f, + 0x44, 0x55, 0x50, 0x4c, 0x49, 0x43, 0x41, 0x54, 0x45, 0x10, 0x03, 0x12, 0x31, 0x0a, 0x2d, 0x57, 0x4f, 0x52, 0x4b, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x45, 0x55, 0x53, 0x45, - 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x44, 0x55, - 0x50, 0x4c, 0x49, 0x43, 0x41, 0x54, 0x45, 0x10, 0x01, 0x12, 0x38, 0x0a, 0x34, 0x57, 0x4f, 0x52, - 0x4b, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x49, 0x44, 0x5f, 0x52, 0x45, 0x55, 0x53, 0x45, 0x5f, 0x50, - 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x5f, 0x44, 0x55, 0x50, 0x4c, - 0x49, 0x43, 0x41, 0x54, 0x45, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x5f, 0x4f, 0x4e, 0x4c, - 0x59, 0x10, 0x02, 0x12, 0x2d, 0x0a, 0x29, 0x57, 0x4f, 0x52, 0x4b, 0x46, 0x4c, 0x4f, 0x57, 0x5f, - 0x49, 0x44, 0x5f, 0x52, 0x45, 0x55, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, - 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x5f, 0x44, 0x55, 0x50, 0x4c, 0x49, 0x43, 0x41, 0x54, 0x45, - 0x10, 0x03, 0x12, 0x31, 0x0a, 0x2d, 0x57, 0x4f, 0x52, 0x4b, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x49, - 0x44, 0x5f, 0x52, 0x45, 0x55, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x54, - 0x45, 0x52, 0x4d, 0x49, 0x4e, 0x41, 0x54, 0x45, 0x5f, 0x49, 0x46, 0x5f, 0x52, 0x55, 0x4e, 0x4e, - 0x49, 0x4e, 0x47, 0x10, 0x04, 0x2a, 0xa4, 0x01, 0x0a, 0x11, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, - 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x23, 0x0a, 0x1f, 0x50, - 0x41, 0x52, 0x45, 0x4e, 0x54, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, - 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, - 0x12, 0x21, 0x0a, 0x1d, 0x50, 0x41, 0x52, 0x45, 0x4e, 0x54, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x54, 0x45, 0x52, 0x4d, 0x49, 0x4e, 0x41, 0x54, - 0x45, 0x10, 0x01, 0x12, 0x1f, 0x0a, 0x1b, 0x50, 0x41, 0x52, 0x45, 0x4e, 0x54, 0x5f, 0x43, 0x4c, - 0x4f, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x41, 0x42, 0x41, 0x4e, 0x44, - 0x4f, 0x4e, 0x10, 0x02, 0x12, 0x26, 0x0a, 0x22, 0x50, 0x41, 0x52, 0x45, 0x4e, 0x54, 0x5f, 0x43, - 0x4c, 0x4f, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x52, 0x45, 0x51, 0x55, - 0x45, 0x53, 0x54, 0x5f, 0x43, 0x41, 0x4e, 0x43, 0x45, 0x4c, 0x10, 0x03, 0x2a, 0x78, 0x0a, 0x0a, - 0x57, 0x61, 0x69, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x1b, 0x0a, 0x17, 0x57, 0x41, - 0x49, 0x54, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, - 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x18, 0x0a, 0x14, 0x57, 0x41, 0x49, 0x54, 0x5f, - 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x41, 0x44, 0x4d, 0x49, 0x54, 0x54, 0x45, 0x44, 0x10, - 0x01, 0x12, 0x18, 0x0a, 0x14, 0x57, 0x41, 0x49, 0x54, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, - 0x5f, 0x41, 0x43, 0x43, 0x45, 0x50, 0x54, 0x45, 0x44, 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, 0x57, - 0x41, 0x49, 0x54, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x43, 0x4f, 0x4d, 0x50, 0x4c, - 0x45, 0x54, 0x45, 0x44, 0x10, 0x03, 0x3a, 0x5a, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x18, 0xc1, 0x38, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x74, 0x65, 0x6d, 0x70, - 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x88, - 0x01, 0x01, 0x3a, 0x4e, 0x0a, 0x03, 0x63, 0x6c, 0x69, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc2, 0x38, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x17, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, - 0x43, 0x4c, 0x49, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x03, 0x63, 0x6c, 0x69, 0x88, - 0x01, 0x01, 0x3a, 0x5c, 0x0a, 0x08, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x12, 0x1e, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc2, - 0x38, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, - 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x52, 0x08, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, - 0x3a, 0x59, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1e, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, - 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc6, 0x38, 0x20, 0x01, + 0x45, 0x5f, 0x49, 0x46, 0x5f, 0x52, 0x55, 0x4e, 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x04, 0x2a, 0xa4, + 0x01, 0x0a, 0x11, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x50, 0x6f, + 0x6c, 0x69, 0x63, 0x79, 0x12, 0x23, 0x0a, 0x1f, 0x50, 0x41, 0x52, 0x45, 0x4e, 0x54, 0x5f, 0x43, + 0x4c, 0x4f, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, + 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x21, 0x0a, 0x1d, 0x50, 0x41, 0x52, + 0x45, 0x4e, 0x54, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, + 0x5f, 0x54, 0x45, 0x52, 0x4d, 0x49, 0x4e, 0x41, 0x54, 0x45, 0x10, 0x01, 0x12, 0x1f, 0x0a, 0x1b, + 0x50, 0x41, 0x52, 0x45, 0x4e, 0x54, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x5f, 0x50, 0x4f, 0x4c, + 0x49, 0x43, 0x59, 0x5f, 0x41, 0x42, 0x41, 0x4e, 0x44, 0x4f, 0x4e, 0x10, 0x02, 0x12, 0x26, 0x0a, + 0x22, 0x50, 0x41, 0x52, 0x45, 0x4e, 0x54, 0x5f, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x5f, 0x50, 0x4f, + 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x5f, 0x43, 0x41, 0x4e, + 0x43, 0x45, 0x4c, 0x10, 0x03, 0x2a, 0x78, 0x0a, 0x0a, 0x57, 0x61, 0x69, 0x74, 0x50, 0x6f, 0x6c, + 0x69, 0x63, 0x79, 0x12, 0x1b, 0x0a, 0x17, 0x57, 0x41, 0x49, 0x54, 0x5f, 0x50, 0x4f, 0x4c, 0x49, + 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, + 0x12, 0x18, 0x0a, 0x14, 0x57, 0x41, 0x49, 0x54, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, + 0x41, 0x44, 0x4d, 0x49, 0x54, 0x54, 0x45, 0x44, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x57, 0x41, + 0x49, 0x54, 0x5f, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x5f, 0x41, 0x43, 0x43, 0x45, 0x50, 0x54, + 0x45, 0x44, 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, 0x57, 0x41, 0x49, 0x54, 0x5f, 0x50, 0x4f, 0x4c, + 0x49, 0x43, 0x59, 0x5f, 0x43, 0x4f, 0x4d, 0x50, 0x4c, 0x45, 0x54, 0x45, 0x44, 0x10, 0x03, 0x3a, + 0x5a, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc1, 0x38, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, - 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, - 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x88, 0x01, 0x01, 0x3a, 0x53, 0x0a, 0x05, 0x71, - 0x75, 0x65, 0x72, 0x79, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, + 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x88, 0x01, 0x01, 0x3a, 0x4e, 0x0a, 0x03, 0x63, + 0x6c, 0x69, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0xc2, 0x38, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x74, 0x65, 0x6d, + 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x4c, 0x49, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x52, 0x03, 0x63, 0x6c, 0x69, 0x88, 0x01, 0x01, 0x3a, 0x5c, 0x0a, 0x08, 0x61, + 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc2, 0x38, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x74, + 0x69, 0x76, 0x69, 0x74, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x08, 0x61, 0x63, + 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x88, 0x01, 0x01, 0x3a, 0x59, 0x0a, 0x07, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc3, 0x38, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x74, 0x65, - 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4f, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x88, 0x01, 0x01, - 0x3a, 0x56, 0x0a, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, - 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc4, 0x38, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1a, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, - 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x06, 0x73, - 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x88, 0x01, 0x01, 0x3a, 0x56, 0x0a, 0x06, 0x75, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x18, 0xc5, 0x38, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x74, 0x65, 0x6d, 0x70, - 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x06, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x88, 0x01, 0x01, - 0x3a, 0x5c, 0x0a, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x1e, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, - 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc1, 0x38, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, - 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x52, 0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x88, 0x01, 0x01, 0x42, 0xb3, - 0x01, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, - 0x76, 0x31, 0x42, 0x0d, 0x54, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x63, 0x6c, 0x75, 0x64, 0x64, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, - 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x2d, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2f, 0x67, - 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2f, 0x76, 0x31, 0x3b, 0x74, - 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x54, 0x58, 0x58, 0xaa, - 0x02, 0x0b, 0x54, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0b, - 0x54, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x17, 0x54, 0x65, - 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0c, 0x54, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, - 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc6, 0x38, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x74, 0x65, + 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x88, 0x01, 0x01, 0x3a, 0x53, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x1e, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc3, 0x38, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, + 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, + 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x88, 0x01, 0x01, 0x3a, 0x56, 0x0a, 0x06, 0x73, 0x69, 0x67, + 0x6e, 0x61, 0x6c, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0xc4, 0x38, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x74, 0x65, 0x6d, + 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x88, 0x01, + 0x01, 0x3a, 0x56, 0x0a, 0x06, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, + 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc5, 0x38, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, + 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x06, + 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x88, 0x01, 0x01, 0x3a, 0x5c, 0x0a, 0x08, 0x77, 0x6f, 0x72, + 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xc1, 0x38, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x74, + 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x66, + 0x6c, 0x6f, 0x77, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x08, 0x77, 0x6f, 0x72, 0x6b, + 0x66, 0x6c, 0x6f, 0x77, 0x88, 0x01, 0x01, 0x42, 0xb3, 0x01, 0x0a, 0x0f, 0x63, 0x6f, 0x6d, 0x2e, + 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, 0x76, 0x31, 0x42, 0x0d, 0x54, 0x65, 0x6d, + 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6c, 0x75, 0x64, 0x64, 0x65, 0x6e, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x2d, 0x74, + 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x6d, 0x70, + 0x6f, 0x72, 0x61, 0x6c, 0x2f, 0x76, 0x31, 0x3b, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, + 0x76, 0x31, 0xa2, 0x02, 0x03, 0x54, 0x58, 0x58, 0xaa, 0x02, 0x0b, 0x54, 0x65, 0x6d, 0x70, 0x6f, + 0x72, 0x61, 0x6c, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0b, 0x54, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, + 0x6c, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x17, 0x54, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x5c, + 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x0c, 0x54, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1996,61 +2014,62 @@ var file_temporal_v1_temporal_proto_depIdxs = []int32{ 20, // 2: temporal.v1.ActivityOptions.start_to_close_timeout:type_name -> google.protobuf.Duration 20, // 3: temporal.v1.ActivityOptions.heartbeat_timeout:type_name -> google.protobuf.Duration 11, // 4: temporal.v1.ActivityOptions.retry_policy:type_name -> temporal.v1.RetryPolicy - 4, // 5: temporal.v1.Patch.version:type_name -> temporal.v1.Patch.Version - 5, // 6: temporal.v1.Patch.mode:type_name -> temporal.v1.Patch.Mode - 16, // 7: temporal.v1.QueryOptions.xns:type_name -> temporal.v1.XNSActivityOptions - 9, // 8: temporal.v1.QueryOptions.patches:type_name -> temporal.v1.Patch - 20, // 9: temporal.v1.RetryPolicy.initial_interval:type_name -> google.protobuf.Duration - 20, // 10: temporal.v1.RetryPolicy.max_interval:type_name -> google.protobuf.Duration - 9, // 11: temporal.v1.ServiceOptions.patches:type_name -> temporal.v1.Patch - 16, // 12: temporal.v1.SignalOptions.xns:type_name -> temporal.v1.XNSActivityOptions - 9, // 13: temporal.v1.SignalOptions.patches:type_name -> temporal.v1.Patch - 9, // 14: temporal.v1.UpdateOptions.patches:type_name -> temporal.v1.Patch - 3, // 15: temporal.v1.UpdateOptions.wait_for_stage:type_name -> temporal.v1.WaitPolicy - 3, // 16: temporal.v1.UpdateOptions.wait_policy:type_name -> temporal.v1.WaitPolicy - 16, // 17: temporal.v1.UpdateOptions.xns:type_name -> temporal.v1.XNSActivityOptions - 17, // 18: temporal.v1.WorkflowOptions.query:type_name -> temporal.v1.WorkflowOptions.Query - 18, // 19: temporal.v1.WorkflowOptions.signal:type_name -> temporal.v1.WorkflowOptions.Signal - 19, // 20: temporal.v1.WorkflowOptions.update:type_name -> temporal.v1.WorkflowOptions.Update - 20, // 21: temporal.v1.WorkflowOptions.execution_timeout:type_name -> google.protobuf.Duration - 1, // 22: temporal.v1.WorkflowOptions.id_reuse_policy:type_name -> temporal.v1.IDReusePolicy - 2, // 23: temporal.v1.WorkflowOptions.parent_close_policy:type_name -> temporal.v1.ParentClosePolicy - 9, // 24: temporal.v1.WorkflowOptions.patches:type_name -> temporal.v1.Patch - 11, // 25: temporal.v1.WorkflowOptions.retry_policy:type_name -> temporal.v1.RetryPolicy - 20, // 26: temporal.v1.WorkflowOptions.run_timeout:type_name -> google.protobuf.Duration - 20, // 27: temporal.v1.WorkflowOptions.task_timeout:type_name -> google.protobuf.Duration - 16, // 28: temporal.v1.WorkflowOptions.xns:type_name -> temporal.v1.XNSActivityOptions - 20, // 29: temporal.v1.XNSActivityOptions.schedule_to_close_timeout:type_name -> google.protobuf.Duration - 20, // 30: temporal.v1.XNSActivityOptions.schedule_to_start_timeout:type_name -> google.protobuf.Duration - 20, // 31: temporal.v1.XNSActivityOptions.start_to_close_timeout:type_name -> google.protobuf.Duration - 20, // 32: temporal.v1.XNSActivityOptions.heartbeat_interval:type_name -> google.protobuf.Duration - 20, // 33: temporal.v1.XNSActivityOptions.heartbeat_timeout:type_name -> google.protobuf.Duration - 11, // 34: temporal.v1.XNSActivityOptions.retry_policy:type_name -> temporal.v1.RetryPolicy - 2, // 35: temporal.v1.XNSActivityOptions.parent_close_policy:type_name -> temporal.v1.ParentClosePolicy - 16, // 36: temporal.v1.WorkflowOptions.Query.xns:type_name -> temporal.v1.XNSActivityOptions - 16, // 37: temporal.v1.WorkflowOptions.Signal.xns:type_name -> temporal.v1.XNSActivityOptions - 16, // 38: temporal.v1.WorkflowOptions.Update.xns:type_name -> temporal.v1.XNSActivityOptions - 21, // 39: temporal.v1.service:extendee -> google.protobuf.ServiceOptions - 21, // 40: temporal.v1.cli:extendee -> google.protobuf.ServiceOptions - 22, // 41: temporal.v1.activity:extendee -> google.protobuf.MethodOptions - 22, // 42: temporal.v1.command:extendee -> google.protobuf.MethodOptions - 22, // 43: temporal.v1.query:extendee -> google.protobuf.MethodOptions - 22, // 44: temporal.v1.signal:extendee -> google.protobuf.MethodOptions - 22, // 45: temporal.v1.update:extendee -> google.protobuf.MethodOptions - 22, // 46: temporal.v1.workflow:extendee -> google.protobuf.MethodOptions - 12, // 47: temporal.v1.service:type_name -> temporal.v1.ServiceOptions - 7, // 48: temporal.v1.cli:type_name -> temporal.v1.CLIOptions - 6, // 49: temporal.v1.activity:type_name -> temporal.v1.ActivityOptions - 8, // 50: temporal.v1.command:type_name -> temporal.v1.CommandOptions - 10, // 51: temporal.v1.query:type_name -> temporal.v1.QueryOptions - 13, // 52: temporal.v1.signal:type_name -> temporal.v1.SignalOptions - 14, // 53: temporal.v1.update:type_name -> temporal.v1.UpdateOptions - 15, // 54: temporal.v1.workflow:type_name -> temporal.v1.WorkflowOptions - 55, // [55:55] is the sub-list for method output_type - 55, // [55:55] is the sub-list for method input_type - 47, // [47:55] is the sub-list for extension type_name - 39, // [39:47] is the sub-list for extension extendee - 0, // [0:39] is the sub-list for field type_name + 9, // 5: temporal.v1.ActivityOptions.patches:type_name -> temporal.v1.Patch + 4, // 6: temporal.v1.Patch.version:type_name -> temporal.v1.Patch.Version + 5, // 7: temporal.v1.Patch.mode:type_name -> temporal.v1.Patch.Mode + 16, // 8: temporal.v1.QueryOptions.xns:type_name -> temporal.v1.XNSActivityOptions + 9, // 9: temporal.v1.QueryOptions.patches:type_name -> temporal.v1.Patch + 20, // 10: temporal.v1.RetryPolicy.initial_interval:type_name -> google.protobuf.Duration + 20, // 11: temporal.v1.RetryPolicy.max_interval:type_name -> google.protobuf.Duration + 9, // 12: temporal.v1.ServiceOptions.patches:type_name -> temporal.v1.Patch + 16, // 13: temporal.v1.SignalOptions.xns:type_name -> temporal.v1.XNSActivityOptions + 9, // 14: temporal.v1.SignalOptions.patches:type_name -> temporal.v1.Patch + 9, // 15: temporal.v1.UpdateOptions.patches:type_name -> temporal.v1.Patch + 3, // 16: temporal.v1.UpdateOptions.wait_for_stage:type_name -> temporal.v1.WaitPolicy + 3, // 17: temporal.v1.UpdateOptions.wait_policy:type_name -> temporal.v1.WaitPolicy + 16, // 18: temporal.v1.UpdateOptions.xns:type_name -> temporal.v1.XNSActivityOptions + 17, // 19: temporal.v1.WorkflowOptions.query:type_name -> temporal.v1.WorkflowOptions.Query + 18, // 20: temporal.v1.WorkflowOptions.signal:type_name -> temporal.v1.WorkflowOptions.Signal + 19, // 21: temporal.v1.WorkflowOptions.update:type_name -> temporal.v1.WorkflowOptions.Update + 20, // 22: temporal.v1.WorkflowOptions.execution_timeout:type_name -> google.protobuf.Duration + 1, // 23: temporal.v1.WorkflowOptions.id_reuse_policy:type_name -> temporal.v1.IDReusePolicy + 2, // 24: temporal.v1.WorkflowOptions.parent_close_policy:type_name -> temporal.v1.ParentClosePolicy + 9, // 25: temporal.v1.WorkflowOptions.patches:type_name -> temporal.v1.Patch + 11, // 26: temporal.v1.WorkflowOptions.retry_policy:type_name -> temporal.v1.RetryPolicy + 20, // 27: temporal.v1.WorkflowOptions.run_timeout:type_name -> google.protobuf.Duration + 20, // 28: temporal.v1.WorkflowOptions.task_timeout:type_name -> google.protobuf.Duration + 16, // 29: temporal.v1.WorkflowOptions.xns:type_name -> temporal.v1.XNSActivityOptions + 20, // 30: temporal.v1.XNSActivityOptions.schedule_to_close_timeout:type_name -> google.protobuf.Duration + 20, // 31: temporal.v1.XNSActivityOptions.schedule_to_start_timeout:type_name -> google.protobuf.Duration + 20, // 32: temporal.v1.XNSActivityOptions.start_to_close_timeout:type_name -> google.protobuf.Duration + 20, // 33: temporal.v1.XNSActivityOptions.heartbeat_interval:type_name -> google.protobuf.Duration + 20, // 34: temporal.v1.XNSActivityOptions.heartbeat_timeout:type_name -> google.protobuf.Duration + 11, // 35: temporal.v1.XNSActivityOptions.retry_policy:type_name -> temporal.v1.RetryPolicy + 2, // 36: temporal.v1.XNSActivityOptions.parent_close_policy:type_name -> temporal.v1.ParentClosePolicy + 16, // 37: temporal.v1.WorkflowOptions.Query.xns:type_name -> temporal.v1.XNSActivityOptions + 16, // 38: temporal.v1.WorkflowOptions.Signal.xns:type_name -> temporal.v1.XNSActivityOptions + 16, // 39: temporal.v1.WorkflowOptions.Update.xns:type_name -> temporal.v1.XNSActivityOptions + 21, // 40: temporal.v1.service:extendee -> google.protobuf.ServiceOptions + 21, // 41: temporal.v1.cli:extendee -> google.protobuf.ServiceOptions + 22, // 42: temporal.v1.activity:extendee -> google.protobuf.MethodOptions + 22, // 43: temporal.v1.command:extendee -> google.protobuf.MethodOptions + 22, // 44: temporal.v1.query:extendee -> google.protobuf.MethodOptions + 22, // 45: temporal.v1.signal:extendee -> google.protobuf.MethodOptions + 22, // 46: temporal.v1.update:extendee -> google.protobuf.MethodOptions + 22, // 47: temporal.v1.workflow:extendee -> google.protobuf.MethodOptions + 12, // 48: temporal.v1.service:type_name -> temporal.v1.ServiceOptions + 7, // 49: temporal.v1.cli:type_name -> temporal.v1.CLIOptions + 6, // 50: temporal.v1.activity:type_name -> temporal.v1.ActivityOptions + 8, // 51: temporal.v1.command:type_name -> temporal.v1.CommandOptions + 10, // 52: temporal.v1.query:type_name -> temporal.v1.QueryOptions + 13, // 53: temporal.v1.signal:type_name -> temporal.v1.SignalOptions + 14, // 54: temporal.v1.update:type_name -> temporal.v1.UpdateOptions + 15, // 55: temporal.v1.workflow:type_name -> temporal.v1.WorkflowOptions + 56, // [56:56] is the sub-list for method output_type + 56, // [56:56] is the sub-list for method input_type + 48, // [48:56] is the sub-list for extension type_name + 40, // [40:48] is the sub-list for extension extendee + 0, // [0:40] is the sub-list for field type_name } func init() { file_temporal_v1_temporal_proto_init() } diff --git a/gen/test/option/v1/option_temporal.pb.go b/gen/test/option/v1/option_temporal.pb.go index 13236277..43369800 100644 --- a/gen/test/option/v1/option_temporal.pb.go +++ b/gen/test/option/v1/option_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // @@ -14,6 +14,7 @@ import ( "fmt" expression "github.com/cludden/protoc-gen-go-temporal/pkg/expression" helpers "github.com/cludden/protoc-gen-go-temporal/pkg/helpers" + patch "github.com/cludden/protoc-gen-go-temporal/pkg/patch" scheme "github.com/cludden/protoc-gen-go-temporal/pkg/scheme" testutil "github.com/cludden/protoc-gen-go-temporal/pkg/testutil" gohomedir "github.com/mitchellh/go-homedir" @@ -647,6 +648,8 @@ func buildWorkflowWithInput(ctor func(workflow.Context, *WorkflowWithInputWorkfl input := &WorkflowWithInputWorkflowInput{ Req: req, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, "option-v2", workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return err @@ -763,7 +766,15 @@ func (o *WorkflowWithInputChildOptions) Build(ctx workflow.Context, req protoref if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = "option-v2" + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, "option-v2"); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = "option-v2" + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -1089,7 +1100,15 @@ func (o *ActivityWithInputActivityOptions) Build(ctx workflow.Context) (workflow if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = "option-v2" + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, "option-v2"); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = "option-v2" + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v diff --git a/gen/test/option/v1/optionv1xns/option_xns_temporal.pb.go b/gen/test/option/v1/optionv1xns/option_xns_temporal.pb.go index 1a7b191b..47d85de4 100644 --- a/gen/test/option/v1/optionv1xns/option_xns_temporal.pb.go +++ b/gen/test/option/v1/optionv1xns/option_xns_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // diff --git a/gen/test/patch/v1/patchv1xns/pv77_xns_temporal.pb.go b/gen/test/patch/v1/patchv1xns/pv77_xns_temporal.pb.go new file mode 100644 index 00000000..ab3f6490 --- /dev/null +++ b/gen/test/patch/v1/patchv1xns/pv77_xns_temporal.pb.go @@ -0,0 +1,1553 @@ +// Code generated by protoc-gen-go_temporal. DO NOT EDIT. +// versions: +// +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) +// go go1.22.2 +// protoc (unknown) +// +// source: test/patch/v1/pv77.proto +package patchv1xns + +import ( + "context" + "errors" + "fmt" + temporalv1 "github.com/cludden/protoc-gen-go-temporal/gen/temporal/v1" + xnsv1 "github.com/cludden/protoc-gen-go-temporal/gen/temporal/xns/v1" + v1 "github.com/cludden/protoc-gen-go-temporal/gen/test/patch/v1" + xns "github.com/cludden/protoc-gen-go-temporal/pkg/xns" + uuid "github.com/google/uuid" + enumsv1 "go.temporal.io/api/enums/v1" + activity "go.temporal.io/sdk/activity" + client "go.temporal.io/sdk/client" + temporal "go.temporal.io/sdk/temporal" + worker "go.temporal.io/sdk/worker" + workflow "go.temporal.io/sdk/workflow" + anypb "google.golang.org/protobuf/types/known/anypb" + durationpb "google.golang.org/protobuf/types/known/durationpb" + "time" +) + +// Pv77FooServiceOptions is used to configure test.patch.v1.Pv77FooService xns activity registration +type Pv77FooServiceOptions struct { + // errorConverter is used to customize error + errorConverter func(error) error + // filter is used to filter xns activity registrations. It receives as + // input the original activity name, and should return one of the following: + // 1. the original activity name, for no changes + // 2. a modified activity name, to override the original activity name + // 3. an empty string, to skip registration + filter func(string) string +} + +// NewPv77FooServiceOptions initializes a new Pv77FooServiceOptions value +func NewPv77FooServiceOptions() *Pv77FooServiceOptions { + return &Pv77FooServiceOptions{} +} + +// WithErrorConverter overrides the default error converter applied to xns activity errors +func (opts *Pv77FooServiceOptions) WithErrorConverter(errorConverter func(error) error) *Pv77FooServiceOptions { + opts.errorConverter = errorConverter + return opts +} + +// Filter is used to filter registered xns activities or customize their name +func (opts *Pv77FooServiceOptions) WithFilter(filter func(string) string) *Pv77FooServiceOptions { + opts.filter = filter + return opts +} + +// convertError is applied to all xns activity errors +func (opts *Pv77FooServiceOptions) convertError(err error) error { + if err == nil { + return nil + } + if opts != nil && opts.errorConverter != nil { + return opts.errorConverter(err) + } + return xns.ErrorToApplicationError(err) +} + +// filterActivity is used to filter xns activity registrations +func (opts *Pv77FooServiceOptions) filterActivity(name string) string { + if opts == nil || opts.filter == nil { + return name + } + return opts.filter(name) +} + +// pv77FooServiceOptions is a reference to the Pv77FooServiceOptions initialized at registration +var pv77FooServiceOptions *Pv77FooServiceOptions + +// RegisterPv77FooServiceActivities registers test.patch.v1.Pv77FooService cross-namespace activities +func RegisterPv77FooServiceActivities(r worker.ActivityRegistry, c v1.Pv77FooServiceClient, options ...*Pv77FooServiceOptions) { + if pv77FooServiceOptions == nil && len(options) > 0 && options[0] != nil { + pv77FooServiceOptions = options[0] + } + a := &pv77FooServiceActivities{c} + if name := pv77FooServiceOptions.filterActivity("test.patch.v1.Pv77FooService.CancelWorkflow"); name != "" { + r.RegisterActivityWithOptions(a.CancelWorkflow, activity.RegisterOptions{Name: name}) + } + if name := pv77FooServiceOptions.filterActivity(v1.Pv77FooWorkflowName); name != "" { + r.RegisterActivityWithOptions(a.Pv77Foo, activity.RegisterOptions{Name: name}) + } +} + +// Pv77FooWorkflowOptions are used to configure a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow execution +type Pv77FooWorkflowOptions struct { + ActivityOptions *workflow.ActivityOptions + Detached bool + HeartbeatInterval time.Duration + ParentClosePolicy enumsv1.ParentClosePolicy + StartWorkflowOptions *client.StartWorkflowOptions +} + +// NewPv77FooWorkflowOptions initializes a new Pv77FooWorkflowOptions value +func NewPv77FooWorkflowOptions() *Pv77FooWorkflowOptions { + return &Pv77FooWorkflowOptions{} +} + +// WithActivityOptions can be used to customize the activity options +func (opts *Pv77FooWorkflowOptions) WithActivityOptions(ao workflow.ActivityOptions) *Pv77FooWorkflowOptions { + opts.ActivityOptions = &ao + return opts +} + +// WithDetached can be used to start a workflow execution and exit immediately +func (opts *Pv77FooWorkflowOptions) WithDetached(d bool) *Pv77FooWorkflowOptions { + opts.Detached = d + return opts +} + +// WithHeartbeatInterval can be used to customize the activity heartbeat interval +func (opts *Pv77FooWorkflowOptions) WithHeartbeatInterval(d time.Duration) *Pv77FooWorkflowOptions { + opts.HeartbeatInterval = d + return opts +} + +// WithParentClosePolicy can be used to customize the cancellation propagation behavior +func (opts *Pv77FooWorkflowOptions) WithParentClosePolicy(policy enumsv1.ParentClosePolicy) *Pv77FooWorkflowOptions { + opts.ParentClosePolicy = policy + return opts +} + +// WithStartWorkflowOptions can be used to customize the start workflow options +func (opts *Pv77FooWorkflowOptions) WithStartWorkflow(swo client.StartWorkflowOptions) *Pv77FooWorkflowOptions { + opts.StartWorkflowOptions = &swo + return opts +} + +// Pv77FooRun provides a handle to a test.patch.v1.Pv77FooService.Pv77Foo workflow execution +type Pv77FooRun interface { + // Cancel cancels the workflow + Cancel(workflow.Context) error + + // Future returns the inner workflow.Future + Future() workflow.Future + + // Get returns the inner workflow.Future + Get(workflow.Context) (*v1.Pv77FooOutput, error) + + // ID returns the workflow id + ID() string +} + +// pv77FooRun provides a(n) Pv77FooRun implementation +type pv77FooRun struct { + cancel func() + future workflow.Future + id string +} + +// Cancel the underlying workflow execution +func (r *pv77FooRun) Cancel(ctx workflow.Context) error { + if r.cancel != nil { + r.cancel() + if _, err := r.Get(ctx); err != nil && !errors.Is(err, workflow.ErrCanceled) { + return err + } + return nil + } + return CancelPv77FooServiceWorkflow(ctx, r.id, "") +} + +// Future returns the underlying activity future +func (r *pv77FooRun) Future() workflow.Future { + return r.future +} + +// Get blocks on activity completion and returns the underlying workflow result +func (r *pv77FooRun) Get(ctx workflow.Context) (*v1.Pv77FooOutput, error) { + var resp v1.Pv77FooOutput + if err := r.future.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// ID returns the underlying workflow id +func (r *pv77FooRun) ID() string { + return r.id +} + +// Pv77Foo executes a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow and blocks until error or response is received +func Pv77Foo(ctx workflow.Context, req *v1.Pv77FooInput, opts ...*Pv77FooWorkflowOptions) (*v1.Pv77FooOutput, error) { + run, err := Pv77FooAsync(ctx, req, opts...) + if err != nil { + return nil, err + } + return run.Get(ctx) +} + +// Pv77FooAsync executes a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow and returns a handle to the underlying activity +func Pv77FooAsync(ctx workflow.Context, req *v1.Pv77FooInput, opts ...*Pv77FooWorkflowOptions) (Pv77FooRun, error) { + activityName := pv77FooServiceOptions.filterActivity(v1.Pv77FooWorkflowName) + if activityName == "" { + return nil, temporal.NewNonRetryableApplicationError( + fmt.Sprintf("no activity registered for %s", v1.Pv77FooWorkflowName), + "Unimplemented", + nil, + ) + } + + opt := &Pv77FooWorkflowOptions{} + if len(opts) > 0 && opts[0] != nil { + opt = opts[0] + } + if opt.HeartbeatInterval == 0 { + opt.HeartbeatInterval = time.Second * 30 + } + + // configure activity options + ao := workflow.GetActivityOptions(ctx) + if opt.ActivityOptions != nil { + ao = *opt.ActivityOptions + } + if ao.HeartbeatTimeout == 0 { + ao.HeartbeatTimeout = opt.HeartbeatInterval * 2 + } + // WaitForCancellation must be set otherwise the underlying workflow is not guaranteed to be canceled + ao.WaitForCancellation = true + + if ao.StartToCloseTimeout == 0 && ao.ScheduleToCloseTimeout == 0 { + ao.ScheduleToCloseTimeout = 86400000000000 // 1 day + } + ctx = workflow.WithActivityOptions(ctx, ao) + + // configure start workflow options + wo := client.StartWorkflowOptions{} + if opt.StartWorkflowOptions != nil { + wo = *opt.StartWorkflowOptions + } + if wo.ID == "" { + if err := workflow.SideEffect(ctx, func(ctx workflow.Context) any { + id, err := uuid.NewRandom() + if err != nil { + workflow.GetLogger(ctx).Error("error generating workflow id", "error", err) + return nil + } + return id + }).Get(&wo.ID); err != nil { + return nil, err + } + } + if wo.ID == "" { + return nil, temporal.NewNonRetryableApplicationError("workflow id is required", "InvalidArgument", nil) + } + + // marshal start workflow options protobuf message + swo, err := xns.MarshalStartWorkflowOptions(wo) + if err != nil { + return nil, fmt.Errorf("error marshalling start workflow options: %w", err) + } + + // marshal workflow request protobuf message + wreq, err := anypb.New(req) + if err != nil { + return nil, fmt.Errorf("error marshalling workflow request: %w", err) + } + + var parentClosePolicy temporalv1.ParentClosePolicy + switch opt.ParentClosePolicy { + case enumsv1.PARENT_CLOSE_POLICY_ABANDON: + parentClosePolicy = temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_ABANDON + case enumsv1.PARENT_CLOSE_POLICY_REQUEST_CANCEL: + parentClosePolicy = temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL + case enumsv1.PARENT_CLOSE_POLICY_TERMINATE: + parentClosePolicy = temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE + } + + ctx, cancel := workflow.WithCancel(ctx) + return &pv77FooRun{ + cancel: cancel, + id: wo.ID, + future: workflow.ExecuteActivity(ctx, activityName, &xnsv1.WorkflowRequest{ + Detached: opt.Detached, + HeartbeatInterval: durationpb.New(opt.HeartbeatInterval), + ParentClosePolicy: parentClosePolicy, + Request: wreq, + StartWorkflowOptions: swo, + }), + }, nil +} + +// CancelPv77FooServiceWorkflow cancels an existing workflow +func CancelPv77FooServiceWorkflow(ctx workflow.Context, workflowID string, runID string) error { + return CancelPv77FooServiceWorkflowAsync(ctx, workflowID, runID).Get(ctx, nil) +} + +// CancelPv77FooServiceWorkflowAsync cancels an existing workflow +func CancelPv77FooServiceWorkflowAsync(ctx workflow.Context, workflowID string, runID string) workflow.Future { + activityName := pv77FooServiceOptions.filterActivity("test.patch.v1.Pv77FooService.CancelWorkflow") + if activityName == "" { + f, s := workflow.NewFuture(ctx) + s.SetError(temporal.NewNonRetryableApplicationError( + "no activity registered for test.patch.v1.Pv77FooService.CancelWorkflow", + "Unimplemented", + nil, + )) + return f + } + ao := workflow.GetActivityOptions(ctx) + if ao.StartToCloseTimeout == 0 && ao.ScheduleToCloseTimeout == 0 { + ao.StartToCloseTimeout = time.Minute + } + ctx = workflow.WithActivityOptions(ctx, ao) + return workflow.ExecuteActivity(ctx, activityName, workflowID, runID) +} + +// pv77FooServiceActivities provides activities that can be used to interact with a(n) Pv77FooService service's workflow, queries, signals, and updates across namespaces +type pv77FooServiceActivities struct { + client v1.Pv77FooServiceClient +} + +// CancelWorkflow cancels an existing workflow execution +func (a *pv77FooServiceActivities) CancelWorkflow(ctx context.Context, workflowID string, runID string) error { + return a.client.CancelWorkflow(ctx, workflowID, runID) +} + +// Pv77Foo executes a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow via an activity +func (a *pv77FooServiceActivities) Pv77Foo(ctx context.Context, input *xnsv1.WorkflowRequest) (resp *v1.Pv77FooOutput, err error) { + // unmarshal workflow request + var req v1.Pv77FooInput + if err := input.Request.UnmarshalTo(&req); err != nil { + return nil, pv77FooServiceOptions.convertError(temporal.NewNonRetryableApplicationError( + fmt.Sprintf("error unmarshalling workflow request of type %s as github.com/cludden/protoc-gen-go-temporal/gen/test/patch/v1.Pv77FooInput", input.Request.GetTypeUrl()), + "InvalidArgument", + err, + )) + } + + // initialize workflow execution + var run v1.Pv77FooRun + run, err = a.client.Pv77FooAsync(ctx, &req, v1.NewPv77FooOptions().WithStartWorkflowOptions( + xns.UnmarshalStartWorkflowOptions(input.GetStartWorkflowOptions()), + )) + if err != nil { + return nil, pv77FooServiceOptions.convertError(err) + } + + // exit early if detached enabled + if input.GetDetached() { + return nil, nil + } + + // otherwise, wait for execution to complete in child goroutine + doneCh := make(chan struct{}) + go func() { + resp, err = run.Get(ctx) + close(doneCh) + }() + + heartbeatInterval := input.GetHeartbeatInterval().AsDuration() + if heartbeatInterval == 0 { + heartbeatInterval = time.Second * 30 + } + + // heartbeat activity while waiting for workflow execution to complete + for { + select { + // send heartbeats periodically + case <-time.After(heartbeatInterval): + activity.RecordHeartbeat(ctx, run.ID()) + + // return retryable error on worker close + case <-activity.GetWorkerStopChannel(ctx): + return nil, temporal.NewApplicationError("worker is stopping", "WorkerStopped") + + // catch parent activity context cancellation. in most cases, this should indicate a + // server-sent cancellation, but there's a non-zero possibility that this cancellation + // is received due to the worker stopping, prior to detecting the closing of the worker + // stop channel. to give us an opportunity to detect a cancellation stemming from the + // worker closing, we again check to see if the worker stop channel is closed before + // propagating the cancellation + case <-ctx.Done(): + select { + case <-activity.GetWorkerStopChannel(ctx): + return nil, temporal.NewApplicationError("worker is stopping", "WorkerStopped") + default: + parentClosePolicy := input.GetParentClosePolicy() + if parentClosePolicy == temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL || parentClosePolicy == temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE { + disconnectedCtx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + if parentClosePolicy == temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL { + err = run.Cancel(disconnectedCtx) + } else { + err = run.Terminate(disconnectedCtx, "xns activity cancellation received", "error", ctx.Err()) + } + if err != nil { + return nil, pv77FooServiceOptions.convertError(err) + } + } + return nil, pv77FooServiceOptions.convertError(temporal.NewCanceledError(ctx.Err().Error())) + } + + // handle workflow completion + case <-doneCh: + return resp, pv77FooServiceOptions.convertError(err) + } + } +} + +// Pv77BarServiceOptions is used to configure test.patch.v1.Pv77BarService xns activity registration +type Pv77BarServiceOptions struct { + // errorConverter is used to customize error + errorConverter func(error) error + // filter is used to filter xns activity registrations. It receives as + // input the original activity name, and should return one of the following: + // 1. the original activity name, for no changes + // 2. a modified activity name, to override the original activity name + // 3. an empty string, to skip registration + filter func(string) string +} + +// NewPv77BarServiceOptions initializes a new Pv77BarServiceOptions value +func NewPv77BarServiceOptions() *Pv77BarServiceOptions { + return &Pv77BarServiceOptions{} +} + +// WithErrorConverter overrides the default error converter applied to xns activity errors +func (opts *Pv77BarServiceOptions) WithErrorConverter(errorConverter func(error) error) *Pv77BarServiceOptions { + opts.errorConverter = errorConverter + return opts +} + +// Filter is used to filter registered xns activities or customize their name +func (opts *Pv77BarServiceOptions) WithFilter(filter func(string) string) *Pv77BarServiceOptions { + opts.filter = filter + return opts +} + +// convertError is applied to all xns activity errors +func (opts *Pv77BarServiceOptions) convertError(err error) error { + if err == nil { + return nil + } + if opts != nil && opts.errorConverter != nil { + return opts.errorConverter(err) + } + return xns.ErrorToApplicationError(err) +} + +// filterActivity is used to filter xns activity registrations +func (opts *Pv77BarServiceOptions) filterActivity(name string) string { + if opts == nil || opts.filter == nil { + return name + } + return opts.filter(name) +} + +// pv77BarServiceOptions is a reference to the Pv77BarServiceOptions initialized at registration +var pv77BarServiceOptions *Pv77BarServiceOptions + +// RegisterPv77BarServiceActivities registers test.patch.v1.Pv77BarService cross-namespace activities +func RegisterPv77BarServiceActivities(r worker.ActivityRegistry, c v1.Pv77BarServiceClient, options ...*Pv77BarServiceOptions) { + if pv77BarServiceOptions == nil && len(options) > 0 && options[0] != nil { + pv77BarServiceOptions = options[0] + } + a := &pv77BarServiceActivities{c} + if name := pv77BarServiceOptions.filterActivity("test.patch.v1.Pv77BarService.CancelWorkflow"); name != "" { + r.RegisterActivityWithOptions(a.CancelWorkflow, activity.RegisterOptions{Name: name}) + } + if name := pv77BarServiceOptions.filterActivity(v1.Pv77BarWorkflowName); name != "" { + r.RegisterActivityWithOptions(a.Pv77Bar, activity.RegisterOptions{Name: name}) + } +} + +// Pv77BarWorkflowOptions are used to configure a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow execution +type Pv77BarWorkflowOptions struct { + ActivityOptions *workflow.ActivityOptions + Detached bool + HeartbeatInterval time.Duration + ParentClosePolicy enumsv1.ParentClosePolicy + StartWorkflowOptions *client.StartWorkflowOptions +} + +// NewPv77BarWorkflowOptions initializes a new Pv77BarWorkflowOptions value +func NewPv77BarWorkflowOptions() *Pv77BarWorkflowOptions { + return &Pv77BarWorkflowOptions{} +} + +// WithActivityOptions can be used to customize the activity options +func (opts *Pv77BarWorkflowOptions) WithActivityOptions(ao workflow.ActivityOptions) *Pv77BarWorkflowOptions { + opts.ActivityOptions = &ao + return opts +} + +// WithDetached can be used to start a workflow execution and exit immediately +func (opts *Pv77BarWorkflowOptions) WithDetached(d bool) *Pv77BarWorkflowOptions { + opts.Detached = d + return opts +} + +// WithHeartbeatInterval can be used to customize the activity heartbeat interval +func (opts *Pv77BarWorkflowOptions) WithHeartbeatInterval(d time.Duration) *Pv77BarWorkflowOptions { + opts.HeartbeatInterval = d + return opts +} + +// WithParentClosePolicy can be used to customize the cancellation propagation behavior +func (opts *Pv77BarWorkflowOptions) WithParentClosePolicy(policy enumsv1.ParentClosePolicy) *Pv77BarWorkflowOptions { + opts.ParentClosePolicy = policy + return opts +} + +// WithStartWorkflowOptions can be used to customize the start workflow options +func (opts *Pv77BarWorkflowOptions) WithStartWorkflow(swo client.StartWorkflowOptions) *Pv77BarWorkflowOptions { + opts.StartWorkflowOptions = &swo + return opts +} + +// Pv77BarRun provides a handle to a test.patch.v1.Pv77BarService.Pv77Bar workflow execution +type Pv77BarRun interface { + // Cancel cancels the workflow + Cancel(workflow.Context) error + + // Future returns the inner workflow.Future + Future() workflow.Future + + // Get returns the inner workflow.Future + Get(workflow.Context) (*v1.Pv77BarOutput, error) + + // ID returns the workflow id + ID() string +} + +// pv77BarRun provides a(n) Pv77BarRun implementation +type pv77BarRun struct { + cancel func() + future workflow.Future + id string +} + +// Cancel the underlying workflow execution +func (r *pv77BarRun) Cancel(ctx workflow.Context) error { + if r.cancel != nil { + r.cancel() + if _, err := r.Get(ctx); err != nil && !errors.Is(err, workflow.ErrCanceled) { + return err + } + return nil + } + return CancelPv77BarServiceWorkflow(ctx, r.id, "") +} + +// Future returns the underlying activity future +func (r *pv77BarRun) Future() workflow.Future { + return r.future +} + +// Get blocks on activity completion and returns the underlying workflow result +func (r *pv77BarRun) Get(ctx workflow.Context) (*v1.Pv77BarOutput, error) { + var resp v1.Pv77BarOutput + if err := r.future.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// ID returns the underlying workflow id +func (r *pv77BarRun) ID() string { + return r.id +} + +// Pv77Bar executes a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow and blocks until error or response is received +func Pv77Bar(ctx workflow.Context, req *v1.Pv77BarInput, opts ...*Pv77BarWorkflowOptions) (*v1.Pv77BarOutput, error) { + run, err := Pv77BarAsync(ctx, req, opts...) + if err != nil { + return nil, err + } + return run.Get(ctx) +} + +// Pv77BarAsync executes a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow and returns a handle to the underlying activity +func Pv77BarAsync(ctx workflow.Context, req *v1.Pv77BarInput, opts ...*Pv77BarWorkflowOptions) (Pv77BarRun, error) { + activityName := pv77BarServiceOptions.filterActivity(v1.Pv77BarWorkflowName) + if activityName == "" { + return nil, temporal.NewNonRetryableApplicationError( + fmt.Sprintf("no activity registered for %s", v1.Pv77BarWorkflowName), + "Unimplemented", + nil, + ) + } + + opt := &Pv77BarWorkflowOptions{} + if len(opts) > 0 && opts[0] != nil { + opt = opts[0] + } + if opt.HeartbeatInterval == 0 { + opt.HeartbeatInterval = time.Second * 30 + } + + // configure activity options + ao := workflow.GetActivityOptions(ctx) + if opt.ActivityOptions != nil { + ao = *opt.ActivityOptions + } + if ao.HeartbeatTimeout == 0 { + ao.HeartbeatTimeout = opt.HeartbeatInterval * 2 + } + // WaitForCancellation must be set otherwise the underlying workflow is not guaranteed to be canceled + ao.WaitForCancellation = true + + if ao.StartToCloseTimeout == 0 && ao.ScheduleToCloseTimeout == 0 { + ao.ScheduleToCloseTimeout = 86400000000000 // 1 day + } + ctx = workflow.WithActivityOptions(ctx, ao) + + // configure start workflow options + wo := client.StartWorkflowOptions{} + if opt.StartWorkflowOptions != nil { + wo = *opt.StartWorkflowOptions + } + if wo.ID == "" { + if err := workflow.SideEffect(ctx, func(ctx workflow.Context) any { + id, err := uuid.NewRandom() + if err != nil { + workflow.GetLogger(ctx).Error("error generating workflow id", "error", err) + return nil + } + return id + }).Get(&wo.ID); err != nil { + return nil, err + } + } + if wo.ID == "" { + return nil, temporal.NewNonRetryableApplicationError("workflow id is required", "InvalidArgument", nil) + } + + // marshal start workflow options protobuf message + swo, err := xns.MarshalStartWorkflowOptions(wo) + if err != nil { + return nil, fmt.Errorf("error marshalling start workflow options: %w", err) + } + + // marshal workflow request protobuf message + wreq, err := anypb.New(req) + if err != nil { + return nil, fmt.Errorf("error marshalling workflow request: %w", err) + } + + var parentClosePolicy temporalv1.ParentClosePolicy + switch opt.ParentClosePolicy { + case enumsv1.PARENT_CLOSE_POLICY_ABANDON: + parentClosePolicy = temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_ABANDON + case enumsv1.PARENT_CLOSE_POLICY_REQUEST_CANCEL: + parentClosePolicy = temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL + case enumsv1.PARENT_CLOSE_POLICY_TERMINATE: + parentClosePolicy = temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE + } + + ctx, cancel := workflow.WithCancel(ctx) + return &pv77BarRun{ + cancel: cancel, + id: wo.ID, + future: workflow.ExecuteActivity(ctx, activityName, &xnsv1.WorkflowRequest{ + Detached: opt.Detached, + HeartbeatInterval: durationpb.New(opt.HeartbeatInterval), + ParentClosePolicy: parentClosePolicy, + Request: wreq, + StartWorkflowOptions: swo, + }), + }, nil +} + +// CancelPv77BarServiceWorkflow cancels an existing workflow +func CancelPv77BarServiceWorkflow(ctx workflow.Context, workflowID string, runID string) error { + return CancelPv77BarServiceWorkflowAsync(ctx, workflowID, runID).Get(ctx, nil) +} + +// CancelPv77BarServiceWorkflowAsync cancels an existing workflow +func CancelPv77BarServiceWorkflowAsync(ctx workflow.Context, workflowID string, runID string) workflow.Future { + activityName := pv77BarServiceOptions.filterActivity("test.patch.v1.Pv77BarService.CancelWorkflow") + if activityName == "" { + f, s := workflow.NewFuture(ctx) + s.SetError(temporal.NewNonRetryableApplicationError( + "no activity registered for test.patch.v1.Pv77BarService.CancelWorkflow", + "Unimplemented", + nil, + )) + return f + } + ao := workflow.GetActivityOptions(ctx) + if ao.StartToCloseTimeout == 0 && ao.ScheduleToCloseTimeout == 0 { + ao.StartToCloseTimeout = time.Minute + } + ctx = workflow.WithActivityOptions(ctx, ao) + return workflow.ExecuteActivity(ctx, activityName, workflowID, runID) +} + +// pv77BarServiceActivities provides activities that can be used to interact with a(n) Pv77BarService service's workflow, queries, signals, and updates across namespaces +type pv77BarServiceActivities struct { + client v1.Pv77BarServiceClient +} + +// CancelWorkflow cancels an existing workflow execution +func (a *pv77BarServiceActivities) CancelWorkflow(ctx context.Context, workflowID string, runID string) error { + return a.client.CancelWorkflow(ctx, workflowID, runID) +} + +// Pv77Bar executes a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow via an activity +func (a *pv77BarServiceActivities) Pv77Bar(ctx context.Context, input *xnsv1.WorkflowRequest) (resp *v1.Pv77BarOutput, err error) { + // unmarshal workflow request + var req v1.Pv77BarInput + if err := input.Request.UnmarshalTo(&req); err != nil { + return nil, pv77BarServiceOptions.convertError(temporal.NewNonRetryableApplicationError( + fmt.Sprintf("error unmarshalling workflow request of type %s as github.com/cludden/protoc-gen-go-temporal/gen/test/patch/v1.Pv77BarInput", input.Request.GetTypeUrl()), + "InvalidArgument", + err, + )) + } + + // initialize workflow execution + var run v1.Pv77BarRun + run, err = a.client.Pv77BarAsync(ctx, &req, v1.NewPv77BarOptions().WithStartWorkflowOptions( + xns.UnmarshalStartWorkflowOptions(input.GetStartWorkflowOptions()), + )) + if err != nil { + return nil, pv77BarServiceOptions.convertError(err) + } + + // exit early if detached enabled + if input.GetDetached() { + return nil, nil + } + + // otherwise, wait for execution to complete in child goroutine + doneCh := make(chan struct{}) + go func() { + resp, err = run.Get(ctx) + close(doneCh) + }() + + heartbeatInterval := input.GetHeartbeatInterval().AsDuration() + if heartbeatInterval == 0 { + heartbeatInterval = time.Second * 30 + } + + // heartbeat activity while waiting for workflow execution to complete + for { + select { + // send heartbeats periodically + case <-time.After(heartbeatInterval): + activity.RecordHeartbeat(ctx, run.ID()) + + // return retryable error on worker close + case <-activity.GetWorkerStopChannel(ctx): + return nil, temporal.NewApplicationError("worker is stopping", "WorkerStopped") + + // catch parent activity context cancellation. in most cases, this should indicate a + // server-sent cancellation, but there's a non-zero possibility that this cancellation + // is received due to the worker stopping, prior to detecting the closing of the worker + // stop channel. to give us an opportunity to detect a cancellation stemming from the + // worker closing, we again check to see if the worker stop channel is closed before + // propagating the cancellation + case <-ctx.Done(): + select { + case <-activity.GetWorkerStopChannel(ctx): + return nil, temporal.NewApplicationError("worker is stopping", "WorkerStopped") + default: + parentClosePolicy := input.GetParentClosePolicy() + if parentClosePolicy == temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL || parentClosePolicy == temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE { + disconnectedCtx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + if parentClosePolicy == temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL { + err = run.Cancel(disconnectedCtx) + } else { + err = run.Terminate(disconnectedCtx, "xns activity cancellation received", "error", ctx.Err()) + } + if err != nil { + return nil, pv77BarServiceOptions.convertError(err) + } + } + return nil, pv77BarServiceOptions.convertError(temporal.NewCanceledError(ctx.Err().Error())) + } + + // handle workflow completion + case <-doneCh: + return resp, pv77BarServiceOptions.convertError(err) + } + } +} + +// Pv77BazServiceOptions is used to configure test.patch.v1.Pv77BazService xns activity registration +type Pv77BazServiceOptions struct { + // errorConverter is used to customize error + errorConverter func(error) error + // filter is used to filter xns activity registrations. It receives as + // input the original activity name, and should return one of the following: + // 1. the original activity name, for no changes + // 2. a modified activity name, to override the original activity name + // 3. an empty string, to skip registration + filter func(string) string +} + +// NewPv77BazServiceOptions initializes a new Pv77BazServiceOptions value +func NewPv77BazServiceOptions() *Pv77BazServiceOptions { + return &Pv77BazServiceOptions{} +} + +// WithErrorConverter overrides the default error converter applied to xns activity errors +func (opts *Pv77BazServiceOptions) WithErrorConverter(errorConverter func(error) error) *Pv77BazServiceOptions { + opts.errorConverter = errorConverter + return opts +} + +// Filter is used to filter registered xns activities or customize their name +func (opts *Pv77BazServiceOptions) WithFilter(filter func(string) string) *Pv77BazServiceOptions { + opts.filter = filter + return opts +} + +// convertError is applied to all xns activity errors +func (opts *Pv77BazServiceOptions) convertError(err error) error { + if err == nil { + return nil + } + if opts != nil && opts.errorConverter != nil { + return opts.errorConverter(err) + } + return xns.ErrorToApplicationError(err) +} + +// filterActivity is used to filter xns activity registrations +func (opts *Pv77BazServiceOptions) filterActivity(name string) string { + if opts == nil || opts.filter == nil { + return name + } + return opts.filter(name) +} + +// pv77BazServiceOptions is a reference to the Pv77BazServiceOptions initialized at registration +var pv77BazServiceOptions *Pv77BazServiceOptions + +// RegisterPv77BazServiceActivities registers test.patch.v1.Pv77BazService cross-namespace activities +func RegisterPv77BazServiceActivities(r worker.ActivityRegistry, c v1.Pv77BazServiceClient, options ...*Pv77BazServiceOptions) { + if pv77BazServiceOptions == nil && len(options) > 0 && options[0] != nil { + pv77BazServiceOptions = options[0] + } + a := &pv77BazServiceActivities{c} + if name := pv77BazServiceOptions.filterActivity("test.patch.v1.Pv77BazService.CancelWorkflow"); name != "" { + r.RegisterActivityWithOptions(a.CancelWorkflow, activity.RegisterOptions{Name: name}) + } + if name := pv77BazServiceOptions.filterActivity(v1.Pv77BazWorkflowName); name != "" { + r.RegisterActivityWithOptions(a.Pv77Baz, activity.RegisterOptions{Name: name}) + } +} + +// Pv77BazWorkflowOptions are used to configure a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow execution +type Pv77BazWorkflowOptions struct { + ActivityOptions *workflow.ActivityOptions + Detached bool + HeartbeatInterval time.Duration + ParentClosePolicy enumsv1.ParentClosePolicy + StartWorkflowOptions *client.StartWorkflowOptions +} + +// NewPv77BazWorkflowOptions initializes a new Pv77BazWorkflowOptions value +func NewPv77BazWorkflowOptions() *Pv77BazWorkflowOptions { + return &Pv77BazWorkflowOptions{} +} + +// WithActivityOptions can be used to customize the activity options +func (opts *Pv77BazWorkflowOptions) WithActivityOptions(ao workflow.ActivityOptions) *Pv77BazWorkflowOptions { + opts.ActivityOptions = &ao + return opts +} + +// WithDetached can be used to start a workflow execution and exit immediately +func (opts *Pv77BazWorkflowOptions) WithDetached(d bool) *Pv77BazWorkflowOptions { + opts.Detached = d + return opts +} + +// WithHeartbeatInterval can be used to customize the activity heartbeat interval +func (opts *Pv77BazWorkflowOptions) WithHeartbeatInterval(d time.Duration) *Pv77BazWorkflowOptions { + opts.HeartbeatInterval = d + return opts +} + +// WithParentClosePolicy can be used to customize the cancellation propagation behavior +func (opts *Pv77BazWorkflowOptions) WithParentClosePolicy(policy enumsv1.ParentClosePolicy) *Pv77BazWorkflowOptions { + opts.ParentClosePolicy = policy + return opts +} + +// WithStartWorkflowOptions can be used to customize the start workflow options +func (opts *Pv77BazWorkflowOptions) WithStartWorkflow(swo client.StartWorkflowOptions) *Pv77BazWorkflowOptions { + opts.StartWorkflowOptions = &swo + return opts +} + +// Pv77BazRun provides a handle to a test.patch.v1.Pv77BazService.Pv77Baz workflow execution +type Pv77BazRun interface { + // Cancel cancels the workflow + Cancel(workflow.Context) error + + // Future returns the inner workflow.Future + Future() workflow.Future + + // Get returns the inner workflow.Future + Get(workflow.Context) (*v1.Pv77BazOutput, error) + + // ID returns the workflow id + ID() string +} + +// pv77BazRun provides a(n) Pv77BazRun implementation +type pv77BazRun struct { + cancel func() + future workflow.Future + id string +} + +// Cancel the underlying workflow execution +func (r *pv77BazRun) Cancel(ctx workflow.Context) error { + if r.cancel != nil { + r.cancel() + if _, err := r.Get(ctx); err != nil && !errors.Is(err, workflow.ErrCanceled) { + return err + } + return nil + } + return CancelPv77BazServiceWorkflow(ctx, r.id, "") +} + +// Future returns the underlying activity future +func (r *pv77BazRun) Future() workflow.Future { + return r.future +} + +// Get blocks on activity completion and returns the underlying workflow result +func (r *pv77BazRun) Get(ctx workflow.Context) (*v1.Pv77BazOutput, error) { + var resp v1.Pv77BazOutput + if err := r.future.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// ID returns the underlying workflow id +func (r *pv77BazRun) ID() string { + return r.id +} + +// Pv77Baz executes a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow and blocks until error or response is received +func Pv77Baz(ctx workflow.Context, req *v1.Pv77BazInput, opts ...*Pv77BazWorkflowOptions) (*v1.Pv77BazOutput, error) { + run, err := Pv77BazAsync(ctx, req, opts...) + if err != nil { + return nil, err + } + return run.Get(ctx) +} + +// Pv77BazAsync executes a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow and returns a handle to the underlying activity +func Pv77BazAsync(ctx workflow.Context, req *v1.Pv77BazInput, opts ...*Pv77BazWorkflowOptions) (Pv77BazRun, error) { + activityName := pv77BazServiceOptions.filterActivity(v1.Pv77BazWorkflowName) + if activityName == "" { + return nil, temporal.NewNonRetryableApplicationError( + fmt.Sprintf("no activity registered for %s", v1.Pv77BazWorkflowName), + "Unimplemented", + nil, + ) + } + + opt := &Pv77BazWorkflowOptions{} + if len(opts) > 0 && opts[0] != nil { + opt = opts[0] + } + if opt.HeartbeatInterval == 0 { + opt.HeartbeatInterval = time.Second * 30 + } + + // configure activity options + ao := workflow.GetActivityOptions(ctx) + if opt.ActivityOptions != nil { + ao = *opt.ActivityOptions + } + if ao.HeartbeatTimeout == 0 { + ao.HeartbeatTimeout = opt.HeartbeatInterval * 2 + } + // WaitForCancellation must be set otherwise the underlying workflow is not guaranteed to be canceled + ao.WaitForCancellation = true + + if ao.StartToCloseTimeout == 0 && ao.ScheduleToCloseTimeout == 0 { + ao.ScheduleToCloseTimeout = 86400000000000 // 1 day + } + ctx = workflow.WithActivityOptions(ctx, ao) + + // configure start workflow options + wo := client.StartWorkflowOptions{} + if opt.StartWorkflowOptions != nil { + wo = *opt.StartWorkflowOptions + } + if wo.ID == "" { + if err := workflow.SideEffect(ctx, func(ctx workflow.Context) any { + id, err := uuid.NewRandom() + if err != nil { + workflow.GetLogger(ctx).Error("error generating workflow id", "error", err) + return nil + } + return id + }).Get(&wo.ID); err != nil { + return nil, err + } + } + if wo.ID == "" { + return nil, temporal.NewNonRetryableApplicationError("workflow id is required", "InvalidArgument", nil) + } + + // marshal start workflow options protobuf message + swo, err := xns.MarshalStartWorkflowOptions(wo) + if err != nil { + return nil, fmt.Errorf("error marshalling start workflow options: %w", err) + } + + // marshal workflow request protobuf message + wreq, err := anypb.New(req) + if err != nil { + return nil, fmt.Errorf("error marshalling workflow request: %w", err) + } + + var parentClosePolicy temporalv1.ParentClosePolicy + switch opt.ParentClosePolicy { + case enumsv1.PARENT_CLOSE_POLICY_ABANDON: + parentClosePolicy = temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_ABANDON + case enumsv1.PARENT_CLOSE_POLICY_REQUEST_CANCEL: + parentClosePolicy = temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL + case enumsv1.PARENT_CLOSE_POLICY_TERMINATE: + parentClosePolicy = temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE + } + + ctx, cancel := workflow.WithCancel(ctx) + return &pv77BazRun{ + cancel: cancel, + id: wo.ID, + future: workflow.ExecuteActivity(ctx, activityName, &xnsv1.WorkflowRequest{ + Detached: opt.Detached, + HeartbeatInterval: durationpb.New(opt.HeartbeatInterval), + ParentClosePolicy: parentClosePolicy, + Request: wreq, + StartWorkflowOptions: swo, + }), + }, nil +} + +// CancelPv77BazServiceWorkflow cancels an existing workflow +func CancelPv77BazServiceWorkflow(ctx workflow.Context, workflowID string, runID string) error { + return CancelPv77BazServiceWorkflowAsync(ctx, workflowID, runID).Get(ctx, nil) +} + +// CancelPv77BazServiceWorkflowAsync cancels an existing workflow +func CancelPv77BazServiceWorkflowAsync(ctx workflow.Context, workflowID string, runID string) workflow.Future { + activityName := pv77BazServiceOptions.filterActivity("test.patch.v1.Pv77BazService.CancelWorkflow") + if activityName == "" { + f, s := workflow.NewFuture(ctx) + s.SetError(temporal.NewNonRetryableApplicationError( + "no activity registered for test.patch.v1.Pv77BazService.CancelWorkflow", + "Unimplemented", + nil, + )) + return f + } + ao := workflow.GetActivityOptions(ctx) + if ao.StartToCloseTimeout == 0 && ao.ScheduleToCloseTimeout == 0 { + ao.StartToCloseTimeout = time.Minute + } + ctx = workflow.WithActivityOptions(ctx, ao) + return workflow.ExecuteActivity(ctx, activityName, workflowID, runID) +} + +// pv77BazServiceActivities provides activities that can be used to interact with a(n) Pv77BazService service's workflow, queries, signals, and updates across namespaces +type pv77BazServiceActivities struct { + client v1.Pv77BazServiceClient +} + +// CancelWorkflow cancels an existing workflow execution +func (a *pv77BazServiceActivities) CancelWorkflow(ctx context.Context, workflowID string, runID string) error { + return a.client.CancelWorkflow(ctx, workflowID, runID) +} + +// Pv77Baz executes a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow via an activity +func (a *pv77BazServiceActivities) Pv77Baz(ctx context.Context, input *xnsv1.WorkflowRequest) (resp *v1.Pv77BazOutput, err error) { + // unmarshal workflow request + var req v1.Pv77BazInput + if err := input.Request.UnmarshalTo(&req); err != nil { + return nil, pv77BazServiceOptions.convertError(temporal.NewNonRetryableApplicationError( + fmt.Sprintf("error unmarshalling workflow request of type %s as github.com/cludden/protoc-gen-go-temporal/gen/test/patch/v1.Pv77BazInput", input.Request.GetTypeUrl()), + "InvalidArgument", + err, + )) + } + + // initialize workflow execution + var run v1.Pv77BazRun + run, err = a.client.Pv77BazAsync(ctx, &req, v1.NewPv77BazOptions().WithStartWorkflowOptions( + xns.UnmarshalStartWorkflowOptions(input.GetStartWorkflowOptions()), + )) + if err != nil { + return nil, pv77BazServiceOptions.convertError(err) + } + + // exit early if detached enabled + if input.GetDetached() { + return nil, nil + } + + // otherwise, wait for execution to complete in child goroutine + doneCh := make(chan struct{}) + go func() { + resp, err = run.Get(ctx) + close(doneCh) + }() + + heartbeatInterval := input.GetHeartbeatInterval().AsDuration() + if heartbeatInterval == 0 { + heartbeatInterval = time.Second * 30 + } + + // heartbeat activity while waiting for workflow execution to complete + for { + select { + // send heartbeats periodically + case <-time.After(heartbeatInterval): + activity.RecordHeartbeat(ctx, run.ID()) + + // return retryable error on worker close + case <-activity.GetWorkerStopChannel(ctx): + return nil, temporal.NewApplicationError("worker is stopping", "WorkerStopped") + + // catch parent activity context cancellation. in most cases, this should indicate a + // server-sent cancellation, but there's a non-zero possibility that this cancellation + // is received due to the worker stopping, prior to detecting the closing of the worker + // stop channel. to give us an opportunity to detect a cancellation stemming from the + // worker closing, we again check to see if the worker stop channel is closed before + // propagating the cancellation + case <-ctx.Done(): + select { + case <-activity.GetWorkerStopChannel(ctx): + return nil, temporal.NewApplicationError("worker is stopping", "WorkerStopped") + default: + parentClosePolicy := input.GetParentClosePolicy() + if parentClosePolicy == temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL || parentClosePolicy == temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE { + disconnectedCtx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + if parentClosePolicy == temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL { + err = run.Cancel(disconnectedCtx) + } else { + err = run.Terminate(disconnectedCtx, "xns activity cancellation received", "error", ctx.Err()) + } + if err != nil { + return nil, pv77BazServiceOptions.convertError(err) + } + } + return nil, pv77BazServiceOptions.convertError(temporal.NewCanceledError(ctx.Err().Error())) + } + + // handle workflow completion + case <-doneCh: + return resp, pv77BazServiceOptions.convertError(err) + } + } +} + +// Pv77QuxServiceOptions is used to configure test.patch.v1.Pv77QuxService xns activity registration +type Pv77QuxServiceOptions struct { + // errorConverter is used to customize error + errorConverter func(error) error + // filter is used to filter xns activity registrations. It receives as + // input the original activity name, and should return one of the following: + // 1. the original activity name, for no changes + // 2. a modified activity name, to override the original activity name + // 3. an empty string, to skip registration + filter func(string) string +} + +// NewPv77QuxServiceOptions initializes a new Pv77QuxServiceOptions value +func NewPv77QuxServiceOptions() *Pv77QuxServiceOptions { + return &Pv77QuxServiceOptions{} +} + +// WithErrorConverter overrides the default error converter applied to xns activity errors +func (opts *Pv77QuxServiceOptions) WithErrorConverter(errorConverter func(error) error) *Pv77QuxServiceOptions { + opts.errorConverter = errorConverter + return opts +} + +// Filter is used to filter registered xns activities or customize their name +func (opts *Pv77QuxServiceOptions) WithFilter(filter func(string) string) *Pv77QuxServiceOptions { + opts.filter = filter + return opts +} + +// convertError is applied to all xns activity errors +func (opts *Pv77QuxServiceOptions) convertError(err error) error { + if err == nil { + return nil + } + if opts != nil && opts.errorConverter != nil { + return opts.errorConverter(err) + } + return xns.ErrorToApplicationError(err) +} + +// filterActivity is used to filter xns activity registrations +func (opts *Pv77QuxServiceOptions) filterActivity(name string) string { + if opts == nil || opts.filter == nil { + return name + } + return opts.filter(name) +} + +// pv77QuxServiceOptions is a reference to the Pv77QuxServiceOptions initialized at registration +var pv77QuxServiceOptions *Pv77QuxServiceOptions + +// RegisterPv77QuxServiceActivities registers test.patch.v1.Pv77QuxService cross-namespace activities +func RegisterPv77QuxServiceActivities(r worker.ActivityRegistry, c v1.Pv77QuxServiceClient, options ...*Pv77QuxServiceOptions) { + if pv77QuxServiceOptions == nil && len(options) > 0 && options[0] != nil { + pv77QuxServiceOptions = options[0] + } + a := &pv77QuxServiceActivities{c} + if name := pv77QuxServiceOptions.filterActivity("test.patch.v1.Pv77QuxService.CancelWorkflow"); name != "" { + r.RegisterActivityWithOptions(a.CancelWorkflow, activity.RegisterOptions{Name: name}) + } + if name := pv77QuxServiceOptions.filterActivity(v1.Pv77QuxWorkflowName); name != "" { + r.RegisterActivityWithOptions(a.Pv77Qux, activity.RegisterOptions{Name: name}) + } +} + +// Pv77QuxWorkflowOptions are used to configure a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow execution +type Pv77QuxWorkflowOptions struct { + ActivityOptions *workflow.ActivityOptions + Detached bool + HeartbeatInterval time.Duration + ParentClosePolicy enumsv1.ParentClosePolicy + StartWorkflowOptions *client.StartWorkflowOptions +} + +// NewPv77QuxWorkflowOptions initializes a new Pv77QuxWorkflowOptions value +func NewPv77QuxWorkflowOptions() *Pv77QuxWorkflowOptions { + return &Pv77QuxWorkflowOptions{} +} + +// WithActivityOptions can be used to customize the activity options +func (opts *Pv77QuxWorkflowOptions) WithActivityOptions(ao workflow.ActivityOptions) *Pv77QuxWorkflowOptions { + opts.ActivityOptions = &ao + return opts +} + +// WithDetached can be used to start a workflow execution and exit immediately +func (opts *Pv77QuxWorkflowOptions) WithDetached(d bool) *Pv77QuxWorkflowOptions { + opts.Detached = d + return opts +} + +// WithHeartbeatInterval can be used to customize the activity heartbeat interval +func (opts *Pv77QuxWorkflowOptions) WithHeartbeatInterval(d time.Duration) *Pv77QuxWorkflowOptions { + opts.HeartbeatInterval = d + return opts +} + +// WithParentClosePolicy can be used to customize the cancellation propagation behavior +func (opts *Pv77QuxWorkflowOptions) WithParentClosePolicy(policy enumsv1.ParentClosePolicy) *Pv77QuxWorkflowOptions { + opts.ParentClosePolicy = policy + return opts +} + +// WithStartWorkflowOptions can be used to customize the start workflow options +func (opts *Pv77QuxWorkflowOptions) WithStartWorkflow(swo client.StartWorkflowOptions) *Pv77QuxWorkflowOptions { + opts.StartWorkflowOptions = &swo + return opts +} + +// Pv77QuxRun provides a handle to a test.patch.v1.Pv77QuxService.Pv77Qux workflow execution +type Pv77QuxRun interface { + // Cancel cancels the workflow + Cancel(workflow.Context) error + + // Future returns the inner workflow.Future + Future() workflow.Future + + // Get returns the inner workflow.Future + Get(workflow.Context) (*v1.Pv77QuxOutput, error) + + // ID returns the workflow id + ID() string +} + +// pv77QuxRun provides a(n) Pv77QuxRun implementation +type pv77QuxRun struct { + cancel func() + future workflow.Future + id string +} + +// Cancel the underlying workflow execution +func (r *pv77QuxRun) Cancel(ctx workflow.Context) error { + if r.cancel != nil { + r.cancel() + if _, err := r.Get(ctx); err != nil && !errors.Is(err, workflow.ErrCanceled) { + return err + } + return nil + } + return CancelPv77QuxServiceWorkflow(ctx, r.id, "") +} + +// Future returns the underlying activity future +func (r *pv77QuxRun) Future() workflow.Future { + return r.future +} + +// Get blocks on activity completion and returns the underlying workflow result +func (r *pv77QuxRun) Get(ctx workflow.Context) (*v1.Pv77QuxOutput, error) { + var resp v1.Pv77QuxOutput + if err := r.future.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// ID returns the underlying workflow id +func (r *pv77QuxRun) ID() string { + return r.id +} + +// Pv77Qux executes a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow and blocks until error or response is received +func Pv77Qux(ctx workflow.Context, req *v1.Pv77QuxInput, opts ...*Pv77QuxWorkflowOptions) (*v1.Pv77QuxOutput, error) { + run, err := Pv77QuxAsync(ctx, req, opts...) + if err != nil { + return nil, err + } + return run.Get(ctx) +} + +// Pv77QuxAsync executes a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow and returns a handle to the underlying activity +func Pv77QuxAsync(ctx workflow.Context, req *v1.Pv77QuxInput, opts ...*Pv77QuxWorkflowOptions) (Pv77QuxRun, error) { + activityName := pv77QuxServiceOptions.filterActivity(v1.Pv77QuxWorkflowName) + if activityName == "" { + return nil, temporal.NewNonRetryableApplicationError( + fmt.Sprintf("no activity registered for %s", v1.Pv77QuxWorkflowName), + "Unimplemented", + nil, + ) + } + + opt := &Pv77QuxWorkflowOptions{} + if len(opts) > 0 && opts[0] != nil { + opt = opts[0] + } + if opt.HeartbeatInterval == 0 { + opt.HeartbeatInterval = time.Second * 30 + } + + // configure activity options + ao := workflow.GetActivityOptions(ctx) + if opt.ActivityOptions != nil { + ao = *opt.ActivityOptions + } + if ao.HeartbeatTimeout == 0 { + ao.HeartbeatTimeout = opt.HeartbeatInterval * 2 + } + // WaitForCancellation must be set otherwise the underlying workflow is not guaranteed to be canceled + ao.WaitForCancellation = true + + if ao.StartToCloseTimeout == 0 && ao.ScheduleToCloseTimeout == 0 { + ao.ScheduleToCloseTimeout = 86400000000000 // 1 day + } + ctx = workflow.WithActivityOptions(ctx, ao) + + // configure start workflow options + wo := client.StartWorkflowOptions{} + if opt.StartWorkflowOptions != nil { + wo = *opt.StartWorkflowOptions + } + if wo.ID == "" { + if err := workflow.SideEffect(ctx, func(ctx workflow.Context) any { + id, err := uuid.NewRandom() + if err != nil { + workflow.GetLogger(ctx).Error("error generating workflow id", "error", err) + return nil + } + return id + }).Get(&wo.ID); err != nil { + return nil, err + } + } + if wo.ID == "" { + return nil, temporal.NewNonRetryableApplicationError("workflow id is required", "InvalidArgument", nil) + } + + // marshal start workflow options protobuf message + swo, err := xns.MarshalStartWorkflowOptions(wo) + if err != nil { + return nil, fmt.Errorf("error marshalling start workflow options: %w", err) + } + + // marshal workflow request protobuf message + wreq, err := anypb.New(req) + if err != nil { + return nil, fmt.Errorf("error marshalling workflow request: %w", err) + } + + var parentClosePolicy temporalv1.ParentClosePolicy + switch opt.ParentClosePolicy { + case enumsv1.PARENT_CLOSE_POLICY_ABANDON: + parentClosePolicy = temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_ABANDON + case enumsv1.PARENT_CLOSE_POLICY_REQUEST_CANCEL: + parentClosePolicy = temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL + case enumsv1.PARENT_CLOSE_POLICY_TERMINATE: + parentClosePolicy = temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE + } + + ctx, cancel := workflow.WithCancel(ctx) + return &pv77QuxRun{ + cancel: cancel, + id: wo.ID, + future: workflow.ExecuteActivity(ctx, activityName, &xnsv1.WorkflowRequest{ + Detached: opt.Detached, + HeartbeatInterval: durationpb.New(opt.HeartbeatInterval), + ParentClosePolicy: parentClosePolicy, + Request: wreq, + StartWorkflowOptions: swo, + }), + }, nil +} + +// CancelPv77QuxServiceWorkflow cancels an existing workflow +func CancelPv77QuxServiceWorkflow(ctx workflow.Context, workflowID string, runID string) error { + return CancelPv77QuxServiceWorkflowAsync(ctx, workflowID, runID).Get(ctx, nil) +} + +// CancelPv77QuxServiceWorkflowAsync cancels an existing workflow +func CancelPv77QuxServiceWorkflowAsync(ctx workflow.Context, workflowID string, runID string) workflow.Future { + activityName := pv77QuxServiceOptions.filterActivity("test.patch.v1.Pv77QuxService.CancelWorkflow") + if activityName == "" { + f, s := workflow.NewFuture(ctx) + s.SetError(temporal.NewNonRetryableApplicationError( + "no activity registered for test.patch.v1.Pv77QuxService.CancelWorkflow", + "Unimplemented", + nil, + )) + return f + } + ao := workflow.GetActivityOptions(ctx) + if ao.StartToCloseTimeout == 0 && ao.ScheduleToCloseTimeout == 0 { + ao.StartToCloseTimeout = time.Minute + } + ctx = workflow.WithActivityOptions(ctx, ao) + return workflow.ExecuteActivity(ctx, activityName, workflowID, runID) +} + +// pv77QuxServiceActivities provides activities that can be used to interact with a(n) Pv77QuxService service's workflow, queries, signals, and updates across namespaces +type pv77QuxServiceActivities struct { + client v1.Pv77QuxServiceClient +} + +// CancelWorkflow cancels an existing workflow execution +func (a *pv77QuxServiceActivities) CancelWorkflow(ctx context.Context, workflowID string, runID string) error { + return a.client.CancelWorkflow(ctx, workflowID, runID) +} + +// Pv77Qux executes a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow via an activity +func (a *pv77QuxServiceActivities) Pv77Qux(ctx context.Context, input *xnsv1.WorkflowRequest) (resp *v1.Pv77QuxOutput, err error) { + // unmarshal workflow request + var req v1.Pv77QuxInput + if err := input.Request.UnmarshalTo(&req); err != nil { + return nil, pv77QuxServiceOptions.convertError(temporal.NewNonRetryableApplicationError( + fmt.Sprintf("error unmarshalling workflow request of type %s as github.com/cludden/protoc-gen-go-temporal/gen/test/patch/v1.Pv77QuxInput", input.Request.GetTypeUrl()), + "InvalidArgument", + err, + )) + } + + // initialize workflow execution + var run v1.Pv77QuxRun + run, err = a.client.Pv77QuxAsync(ctx, &req, v1.NewPv77QuxOptions().WithStartWorkflowOptions( + xns.UnmarshalStartWorkflowOptions(input.GetStartWorkflowOptions()), + )) + if err != nil { + return nil, pv77QuxServiceOptions.convertError(err) + } + + // exit early if detached enabled + if input.GetDetached() { + return nil, nil + } + + // otherwise, wait for execution to complete in child goroutine + doneCh := make(chan struct{}) + go func() { + resp, err = run.Get(ctx) + close(doneCh) + }() + + heartbeatInterval := input.GetHeartbeatInterval().AsDuration() + if heartbeatInterval == 0 { + heartbeatInterval = time.Second * 30 + } + + // heartbeat activity while waiting for workflow execution to complete + for { + select { + // send heartbeats periodically + case <-time.After(heartbeatInterval): + activity.RecordHeartbeat(ctx, run.ID()) + + // return retryable error on worker close + case <-activity.GetWorkerStopChannel(ctx): + return nil, temporal.NewApplicationError("worker is stopping", "WorkerStopped") + + // catch parent activity context cancellation. in most cases, this should indicate a + // server-sent cancellation, but there's a non-zero possibility that this cancellation + // is received due to the worker stopping, prior to detecting the closing of the worker + // stop channel. to give us an opportunity to detect a cancellation stemming from the + // worker closing, we again check to see if the worker stop channel is closed before + // propagating the cancellation + case <-ctx.Done(): + select { + case <-activity.GetWorkerStopChannel(ctx): + return nil, temporal.NewApplicationError("worker is stopping", "WorkerStopped") + default: + parentClosePolicy := input.GetParentClosePolicy() + if parentClosePolicy == temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL || parentClosePolicy == temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_TERMINATE { + disconnectedCtx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + if parentClosePolicy == temporalv1.ParentClosePolicy_PARENT_CLOSE_POLICY_REQUEST_CANCEL { + err = run.Cancel(disconnectedCtx) + } else { + err = run.Terminate(disconnectedCtx, "xns activity cancellation received", "error", ctx.Err()) + } + if err != nil { + return nil, pv77QuxServiceOptions.convertError(err) + } + } + return nil, pv77QuxServiceOptions.convertError(temporal.NewCanceledError(ctx.Err().Error())) + } + + // handle workflow completion + case <-doneCh: + return resp, pv77QuxServiceOptions.convertError(err) + } + } +} diff --git a/gen/test/patch/v1/pv77.pb.go b/gen/test/patch/v1/pv77.pb.go new file mode 100644 index 00000000..ea34bfc8 --- /dev/null +++ b/gen/test/patch/v1/pv77.pb.go @@ -0,0 +1,859 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc (unknown) +// source: test/patch/v1/pv77.proto + +package patchv1 + +import ( + _ "github.com/cludden/protoc-gen-go-temporal/gen/temporal/v1" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Pv77Input struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Next []string `protobuf:"bytes,1,rep,name=next,proto3" json:"next,omitempty"` +} + +func (x *Pv77Input) Reset() { + *x = Pv77Input{} + if protoimpl.UnsafeEnabled { + mi := &file_test_patch_v1_pv77_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Pv77Input) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Pv77Input) ProtoMessage() {} + +func (x *Pv77Input) ProtoReflect() protoreflect.Message { + mi := &file_test_patch_v1_pv77_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Pv77Input.ProtoReflect.Descriptor instead. +func (*Pv77Input) Descriptor() ([]byte, []int) { + return file_test_patch_v1_pv77_proto_rawDescGZIP(), []int{0} +} + +func (x *Pv77Input) GetNext() []string { + if x != nil { + return x.Next + } + return nil +} + +type Pv77Output struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TaskQueues []string `protobuf:"bytes,1,rep,name=task_queues,json=taskQueues,proto3" json:"task_queues,omitempty"` + Defaults map[string]string `protobuf:"bytes,2,rep,name=defaults,proto3" json:"defaults,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *Pv77Output) Reset() { + *x = Pv77Output{} + if protoimpl.UnsafeEnabled { + mi := &file_test_patch_v1_pv77_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Pv77Output) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Pv77Output) ProtoMessage() {} + +func (x *Pv77Output) ProtoReflect() protoreflect.Message { + mi := &file_test_patch_v1_pv77_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Pv77Output.ProtoReflect.Descriptor instead. +func (*Pv77Output) Descriptor() ([]byte, []int) { + return file_test_patch_v1_pv77_proto_rawDescGZIP(), []int{1} +} + +func (x *Pv77Output) GetTaskQueues() []string { + if x != nil { + return x.TaskQueues + } + return nil +} + +func (x *Pv77Output) GetDefaults() map[string]string { + if x != nil { + return x.Defaults + } + return nil +} + +type Pv77FooInput struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Next []string `protobuf:"bytes,1,rep,name=next,proto3" json:"next,omitempty"` +} + +func (x *Pv77FooInput) Reset() { + *x = Pv77FooInput{} + if protoimpl.UnsafeEnabled { + mi := &file_test_patch_v1_pv77_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Pv77FooInput) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Pv77FooInput) ProtoMessage() {} + +func (x *Pv77FooInput) ProtoReflect() protoreflect.Message { + mi := &file_test_patch_v1_pv77_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Pv77FooInput.ProtoReflect.Descriptor instead. +func (*Pv77FooInput) Descriptor() ([]byte, []int) { + return file_test_patch_v1_pv77_proto_rawDescGZIP(), []int{2} +} + +func (x *Pv77FooInput) GetNext() []string { + if x != nil { + return x.Next + } + return nil +} + +type Pv77FooOutput struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TaskQueues []string `protobuf:"bytes,1,rep,name=task_queues,json=taskQueues,proto3" json:"task_queues,omitempty"` + Defaults map[string]string `protobuf:"bytes,2,rep,name=defaults,proto3" json:"defaults,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *Pv77FooOutput) Reset() { + *x = Pv77FooOutput{} + if protoimpl.UnsafeEnabled { + mi := &file_test_patch_v1_pv77_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Pv77FooOutput) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Pv77FooOutput) ProtoMessage() {} + +func (x *Pv77FooOutput) ProtoReflect() protoreflect.Message { + mi := &file_test_patch_v1_pv77_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Pv77FooOutput.ProtoReflect.Descriptor instead. +func (*Pv77FooOutput) Descriptor() ([]byte, []int) { + return file_test_patch_v1_pv77_proto_rawDescGZIP(), []int{3} +} + +func (x *Pv77FooOutput) GetTaskQueues() []string { + if x != nil { + return x.TaskQueues + } + return nil +} + +func (x *Pv77FooOutput) GetDefaults() map[string]string { + if x != nil { + return x.Defaults + } + return nil +} + +type Pv77BarInput struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Next []string `protobuf:"bytes,1,rep,name=next,proto3" json:"next,omitempty"` +} + +func (x *Pv77BarInput) Reset() { + *x = Pv77BarInput{} + if protoimpl.UnsafeEnabled { + mi := &file_test_patch_v1_pv77_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Pv77BarInput) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Pv77BarInput) ProtoMessage() {} + +func (x *Pv77BarInput) ProtoReflect() protoreflect.Message { + mi := &file_test_patch_v1_pv77_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Pv77BarInput.ProtoReflect.Descriptor instead. +func (*Pv77BarInput) Descriptor() ([]byte, []int) { + return file_test_patch_v1_pv77_proto_rawDescGZIP(), []int{4} +} + +func (x *Pv77BarInput) GetNext() []string { + if x != nil { + return x.Next + } + return nil +} + +type Pv77BarOutput struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TaskQueues []string `protobuf:"bytes,1,rep,name=task_queues,json=taskQueues,proto3" json:"task_queues,omitempty"` + Defaults map[string]string `protobuf:"bytes,2,rep,name=defaults,proto3" json:"defaults,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *Pv77BarOutput) Reset() { + *x = Pv77BarOutput{} + if protoimpl.UnsafeEnabled { + mi := &file_test_patch_v1_pv77_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Pv77BarOutput) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Pv77BarOutput) ProtoMessage() {} + +func (x *Pv77BarOutput) ProtoReflect() protoreflect.Message { + mi := &file_test_patch_v1_pv77_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Pv77BarOutput.ProtoReflect.Descriptor instead. +func (*Pv77BarOutput) Descriptor() ([]byte, []int) { + return file_test_patch_v1_pv77_proto_rawDescGZIP(), []int{5} +} + +func (x *Pv77BarOutput) GetTaskQueues() []string { + if x != nil { + return x.TaskQueues + } + return nil +} + +func (x *Pv77BarOutput) GetDefaults() map[string]string { + if x != nil { + return x.Defaults + } + return nil +} + +type Pv77BazInput struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Next []string `protobuf:"bytes,1,rep,name=next,proto3" json:"next,omitempty"` +} + +func (x *Pv77BazInput) Reset() { + *x = Pv77BazInput{} + if protoimpl.UnsafeEnabled { + mi := &file_test_patch_v1_pv77_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Pv77BazInput) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Pv77BazInput) ProtoMessage() {} + +func (x *Pv77BazInput) ProtoReflect() protoreflect.Message { + mi := &file_test_patch_v1_pv77_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Pv77BazInput.ProtoReflect.Descriptor instead. +func (*Pv77BazInput) Descriptor() ([]byte, []int) { + return file_test_patch_v1_pv77_proto_rawDescGZIP(), []int{6} +} + +func (x *Pv77BazInput) GetNext() []string { + if x != nil { + return x.Next + } + return nil +} + +type Pv77BazOutput struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TaskQueues []string `protobuf:"bytes,1,rep,name=task_queues,json=taskQueues,proto3" json:"task_queues,omitempty"` + Defaults map[string]string `protobuf:"bytes,2,rep,name=defaults,proto3" json:"defaults,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *Pv77BazOutput) Reset() { + *x = Pv77BazOutput{} + if protoimpl.UnsafeEnabled { + mi := &file_test_patch_v1_pv77_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Pv77BazOutput) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Pv77BazOutput) ProtoMessage() {} + +func (x *Pv77BazOutput) ProtoReflect() protoreflect.Message { + mi := &file_test_patch_v1_pv77_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Pv77BazOutput.ProtoReflect.Descriptor instead. +func (*Pv77BazOutput) Descriptor() ([]byte, []int) { + return file_test_patch_v1_pv77_proto_rawDescGZIP(), []int{7} +} + +func (x *Pv77BazOutput) GetTaskQueues() []string { + if x != nil { + return x.TaskQueues + } + return nil +} + +func (x *Pv77BazOutput) GetDefaults() map[string]string { + if x != nil { + return x.Defaults + } + return nil +} + +type Pv77QuxInput struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Next []string `protobuf:"bytes,1,rep,name=next,proto3" json:"next,omitempty"` +} + +func (x *Pv77QuxInput) Reset() { + *x = Pv77QuxInput{} + if protoimpl.UnsafeEnabled { + mi := &file_test_patch_v1_pv77_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Pv77QuxInput) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Pv77QuxInput) ProtoMessage() {} + +func (x *Pv77QuxInput) ProtoReflect() protoreflect.Message { + mi := &file_test_patch_v1_pv77_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Pv77QuxInput.ProtoReflect.Descriptor instead. +func (*Pv77QuxInput) Descriptor() ([]byte, []int) { + return file_test_patch_v1_pv77_proto_rawDescGZIP(), []int{8} +} + +func (x *Pv77QuxInput) GetNext() []string { + if x != nil { + return x.Next + } + return nil +} + +type Pv77QuxOutput struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TaskQueues []string `protobuf:"bytes,1,rep,name=task_queues,json=taskQueues,proto3" json:"task_queues,omitempty"` + Defaults map[string]string `protobuf:"bytes,2,rep,name=defaults,proto3" json:"defaults,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *Pv77QuxOutput) Reset() { + *x = Pv77QuxOutput{} + if protoimpl.UnsafeEnabled { + mi := &file_test_patch_v1_pv77_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Pv77QuxOutput) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Pv77QuxOutput) ProtoMessage() {} + +func (x *Pv77QuxOutput) ProtoReflect() protoreflect.Message { + mi := &file_test_patch_v1_pv77_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Pv77QuxOutput.ProtoReflect.Descriptor instead. +func (*Pv77QuxOutput) Descriptor() ([]byte, []int) { + return file_test_patch_v1_pv77_proto_rawDescGZIP(), []int{9} +} + +func (x *Pv77QuxOutput) GetTaskQueues() []string { + if x != nil { + return x.TaskQueues + } + return nil +} + +func (x *Pv77QuxOutput) GetDefaults() map[string]string { + if x != nil { + return x.Defaults + } + return nil +} + +var File_test_patch_v1_pv77_proto protoreflect.FileDescriptor + +var file_test_patch_v1_pv77_proto_rawDesc = []byte{ + 0x0a, 0x18, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2f, 0x76, 0x31, 0x2f, + 0x70, 0x76, 0x37, 0x37, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x74, 0x65, 0x73, 0x74, + 0x2e, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x1a, 0x1a, 0x74, 0x65, 0x6d, 0x70, 0x6f, + 0x72, 0x61, 0x6c, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1f, 0x0a, 0x09, 0x50, 0x76, 0x37, 0x37, 0x49, 0x6e, 0x70, + 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x65, 0x78, 0x74, 0x22, 0xaf, 0x01, 0x0a, 0x0a, 0x50, 0x76, 0x37, 0x37, 0x4f, + 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x71, 0x75, + 0x65, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x61, 0x73, 0x6b, + 0x51, 0x75, 0x65, 0x75, 0x65, 0x73, 0x12, 0x43, 0x0a, 0x08, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, + 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, + 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x76, 0x37, 0x37, 0x4f, 0x75, 0x74, + 0x70, 0x75, 0x74, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x08, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x1a, 0x3b, 0x0a, 0x0d, 0x44, + 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x22, 0x0a, 0x0c, 0x50, 0x76, 0x37, 0x37, + 0x46, 0x6f, 0x6f, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x65, 0x78, 0x74, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x65, 0x78, 0x74, 0x22, 0xb5, 0x01, 0x0a, + 0x0d, 0x50, 0x76, 0x37, 0x37, 0x46, 0x6f, 0x6f, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x1f, + 0x0a, 0x0b, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x71, 0x75, 0x65, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x51, 0x75, 0x65, 0x75, 0x65, 0x73, 0x12, + 0x46, 0x0a, 0x08, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x2a, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, + 0x31, 0x2e, 0x50, 0x76, 0x37, 0x37, 0x46, 0x6f, 0x6f, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, + 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x64, + 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x1a, 0x3b, 0x0a, 0x0d, 0x44, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x3a, 0x02, 0x38, 0x01, 0x22, 0x22, 0x0a, 0x0c, 0x50, 0x76, 0x37, 0x37, 0x42, 0x61, 0x72, 0x49, + 0x6e, 0x70, 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x65, 0x78, 0x74, 0x22, 0xb5, 0x01, 0x0a, 0x0d, 0x50, 0x76, 0x37, + 0x37, 0x42, 0x61, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x61, + 0x73, 0x6b, 0x5f, 0x71, 0x75, 0x65, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x51, 0x75, 0x65, 0x75, 0x65, 0x73, 0x12, 0x46, 0x0a, 0x08, 0x64, + 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, + 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x76, + 0x37, 0x37, 0x42, 0x61, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x44, 0x65, 0x66, 0x61, + 0x75, 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x64, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x73, 0x1a, 0x3b, 0x0a, 0x0d, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0x22, 0x0a, 0x0c, 0x50, 0x76, 0x37, 0x37, 0x42, 0x61, 0x7a, 0x49, 0x6e, 0x70, 0x75, 0x74, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x65, 0x78, 0x74, 0x22, 0xb5, 0x01, 0x0a, 0x0d, 0x50, 0x76, 0x37, 0x37, 0x42, 0x61, 0x7a, + 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x71, + 0x75, 0x65, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x61, 0x73, + 0x6b, 0x51, 0x75, 0x65, 0x75, 0x65, 0x73, 0x12, 0x46, 0x0a, 0x08, 0x64, 0x65, 0x66, 0x61, 0x75, + 0x6c, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x74, 0x65, 0x73, 0x74, + 0x2e, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x76, 0x37, 0x37, 0x42, 0x61, + 0x7a, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x1a, + 0x3b, 0x0a, 0x0d, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x22, 0x0a, 0x0c, + 0x50, 0x76, 0x37, 0x37, 0x51, 0x75, 0x78, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x65, 0x78, 0x74, + 0x22, 0xb5, 0x01, 0x0a, 0x0d, 0x50, 0x76, 0x37, 0x37, 0x51, 0x75, 0x78, 0x4f, 0x75, 0x74, 0x70, + 0x75, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x71, 0x75, 0x65, 0x75, 0x65, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x61, 0x73, 0x6b, 0x51, 0x75, 0x65, + 0x75, 0x65, 0x73, 0x12, 0x46, 0x0a, 0x08, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x76, 0x37, 0x37, 0x51, 0x75, 0x78, 0x4f, 0x75, 0x74, + 0x70, 0x75, 0x74, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x52, 0x08, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x1a, 0x3b, 0x0a, 0x0d, 0x44, + 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, 0x96, 0x01, 0x0a, 0x0e, 0x50, 0x76, 0x37, + 0x37, 0x46, 0x6f, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x71, 0x0a, 0x07, 0x50, + 0x76, 0x37, 0x37, 0x46, 0x6f, 0x6f, 0x12, 0x1b, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x61, + 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x76, 0x37, 0x37, 0x46, 0x6f, 0x6f, 0x49, 0x6e, + 0x70, 0x75, 0x74, 0x1a, 0x1c, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x61, 0x74, 0x63, 0x68, + 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x76, 0x37, 0x37, 0x46, 0x6f, 0x6f, 0x4f, 0x75, 0x74, 0x70, 0x75, + 0x74, 0x22, 0x2b, 0x8a, 0xc4, 0x03, 0x00, 0x92, 0xc4, 0x03, 0x23, 0x22, 0x02, 0x08, 0x05, 0x3a, + 0x1d, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, + 0x76, 0x37, 0x37, 0x46, 0x6f, 0x6f, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x1a, 0x11, + 0x8a, 0xc4, 0x03, 0x0d, 0x0a, 0x07, 0x70, 0x76, 0x37, 0x37, 0x2d, 0x76, 0x31, 0x1a, 0x02, 0x08, + 0x02, 0x32, 0x98, 0x01, 0x0a, 0x0e, 0x50, 0x76, 0x37, 0x37, 0x42, 0x61, 0x72, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x71, 0x0a, 0x07, 0x50, 0x76, 0x37, 0x37, 0x42, 0x61, 0x72, 0x12, + 0x1b, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, + 0x50, 0x76, 0x37, 0x37, 0x42, 0x61, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x1a, 0x1c, 0x2e, 0x74, + 0x65, 0x73, 0x74, 0x2e, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x76, 0x37, + 0x37, 0x42, 0x61, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x22, 0x2b, 0x8a, 0xc4, 0x03, 0x00, + 0x92, 0xc4, 0x03, 0x23, 0x22, 0x02, 0x08, 0x05, 0x3a, 0x1d, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, + 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x76, 0x37, 0x37, 0x42, 0x61, 0x72, 0x41, + 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x1a, 0x13, 0x8a, 0xc4, 0x03, 0x0f, 0x0a, 0x07, 0x70, + 0x76, 0x37, 0x37, 0x2d, 0x76, 0x31, 0x1a, 0x04, 0x08, 0x02, 0x10, 0x01, 0x32, 0x98, 0x01, 0x0a, + 0x0e, 0x50, 0x76, 0x37, 0x37, 0x42, 0x61, 0x7a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x71, 0x0a, 0x07, 0x50, 0x76, 0x37, 0x37, 0x42, 0x61, 0x7a, 0x12, 0x1b, 0x2e, 0x74, 0x65, 0x73, + 0x74, 0x2e, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x76, 0x37, 0x37, 0x42, + 0x61, 0x7a, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x1a, 0x1c, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, + 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x76, 0x37, 0x37, 0x42, 0x61, 0x7a, 0x4f, + 0x75, 0x74, 0x70, 0x75, 0x74, 0x22, 0x2b, 0x8a, 0xc4, 0x03, 0x00, 0x92, 0xc4, 0x03, 0x23, 0x22, + 0x02, 0x08, 0x05, 0x3a, 0x1d, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, + 0x76, 0x31, 0x2e, 0x50, 0x76, 0x37, 0x37, 0x42, 0x61, 0x7a, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, + 0x74, 0x79, 0x1a, 0x13, 0x8a, 0xc4, 0x03, 0x0f, 0x0a, 0x07, 0x70, 0x76, 0x37, 0x37, 0x2d, 0x76, + 0x33, 0x1a, 0x04, 0x08, 0x02, 0x10, 0x02, 0x32, 0x98, 0x01, 0x0a, 0x0e, 0x50, 0x76, 0x37, 0x37, + 0x51, 0x75, 0x78, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x71, 0x0a, 0x07, 0x50, 0x76, + 0x37, 0x37, 0x51, 0x75, 0x78, 0x12, 0x1b, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x76, 0x37, 0x37, 0x51, 0x75, 0x78, 0x49, 0x6e, 0x70, + 0x75, 0x74, 0x1a, 0x1c, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, + 0x76, 0x31, 0x2e, 0x50, 0x76, 0x37, 0x37, 0x51, 0x75, 0x78, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, + 0x22, 0x2b, 0x8a, 0xc4, 0x03, 0x00, 0x92, 0xc4, 0x03, 0x23, 0x22, 0x02, 0x08, 0x05, 0x3a, 0x1d, + 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x76, + 0x37, 0x37, 0x51, 0x75, 0x78, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x1a, 0x13, 0x8a, + 0xc4, 0x03, 0x0f, 0x0a, 0x07, 0x70, 0x76, 0x37, 0x37, 0x2d, 0x76, 0x32, 0x1a, 0x04, 0x08, 0x02, + 0x10, 0x03, 0x42, 0xb9, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, + 0x70, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x76, 0x31, 0x42, 0x09, 0x50, 0x76, 0x37, 0x37, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x63, 0x6c, 0x75, 0x64, 0x64, 0x65, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, + 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x2d, 0x74, 0x65, 0x6d, 0x70, 0x6f, 0x72, 0x61, 0x6c, + 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x70, 0x61, 0x74, 0x63, 0x68, 0x2f, + 0x76, 0x31, 0x3b, 0x70, 0x61, 0x74, 0x63, 0x68, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x54, 0x50, 0x58, + 0xaa, 0x02, 0x0d, 0x54, 0x65, 0x73, 0x74, 0x2e, 0x50, 0x61, 0x74, 0x63, 0x68, 0x2e, 0x56, 0x31, + 0xca, 0x02, 0x0d, 0x54, 0x65, 0x73, 0x74, 0x5c, 0x50, 0x61, 0x74, 0x63, 0x68, 0x5c, 0x56, 0x31, + 0xe2, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x5c, 0x50, 0x61, 0x74, 0x63, 0x68, 0x5c, 0x56, 0x31, + 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0f, 0x54, + 0x65, 0x73, 0x74, 0x3a, 0x3a, 0x50, 0x61, 0x74, 0x63, 0x68, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_test_patch_v1_pv77_proto_rawDescOnce sync.Once + file_test_patch_v1_pv77_proto_rawDescData = file_test_patch_v1_pv77_proto_rawDesc +) + +func file_test_patch_v1_pv77_proto_rawDescGZIP() []byte { + file_test_patch_v1_pv77_proto_rawDescOnce.Do(func() { + file_test_patch_v1_pv77_proto_rawDescData = protoimpl.X.CompressGZIP(file_test_patch_v1_pv77_proto_rawDescData) + }) + return file_test_patch_v1_pv77_proto_rawDescData +} + +var file_test_patch_v1_pv77_proto_msgTypes = make([]protoimpl.MessageInfo, 15) +var file_test_patch_v1_pv77_proto_goTypes = []any{ + (*Pv77Input)(nil), // 0: test.patch.v1.Pv77Input + (*Pv77Output)(nil), // 1: test.patch.v1.Pv77Output + (*Pv77FooInput)(nil), // 2: test.patch.v1.Pv77FooInput + (*Pv77FooOutput)(nil), // 3: test.patch.v1.Pv77FooOutput + (*Pv77BarInput)(nil), // 4: test.patch.v1.Pv77BarInput + (*Pv77BarOutput)(nil), // 5: test.patch.v1.Pv77BarOutput + (*Pv77BazInput)(nil), // 6: test.patch.v1.Pv77BazInput + (*Pv77BazOutput)(nil), // 7: test.patch.v1.Pv77BazOutput + (*Pv77QuxInput)(nil), // 8: test.patch.v1.Pv77QuxInput + (*Pv77QuxOutput)(nil), // 9: test.patch.v1.Pv77QuxOutput + nil, // 10: test.patch.v1.Pv77Output.DefaultsEntry + nil, // 11: test.patch.v1.Pv77FooOutput.DefaultsEntry + nil, // 12: test.patch.v1.Pv77BarOutput.DefaultsEntry + nil, // 13: test.patch.v1.Pv77BazOutput.DefaultsEntry + nil, // 14: test.patch.v1.Pv77QuxOutput.DefaultsEntry +} +var file_test_patch_v1_pv77_proto_depIdxs = []int32{ + 10, // 0: test.patch.v1.Pv77Output.defaults:type_name -> test.patch.v1.Pv77Output.DefaultsEntry + 11, // 1: test.patch.v1.Pv77FooOutput.defaults:type_name -> test.patch.v1.Pv77FooOutput.DefaultsEntry + 12, // 2: test.patch.v1.Pv77BarOutput.defaults:type_name -> test.patch.v1.Pv77BarOutput.DefaultsEntry + 13, // 3: test.patch.v1.Pv77BazOutput.defaults:type_name -> test.patch.v1.Pv77BazOutput.DefaultsEntry + 14, // 4: test.patch.v1.Pv77QuxOutput.defaults:type_name -> test.patch.v1.Pv77QuxOutput.DefaultsEntry + 2, // 5: test.patch.v1.Pv77FooService.Pv77Foo:input_type -> test.patch.v1.Pv77FooInput + 4, // 6: test.patch.v1.Pv77BarService.Pv77Bar:input_type -> test.patch.v1.Pv77BarInput + 6, // 7: test.patch.v1.Pv77BazService.Pv77Baz:input_type -> test.patch.v1.Pv77BazInput + 8, // 8: test.patch.v1.Pv77QuxService.Pv77Qux:input_type -> test.patch.v1.Pv77QuxInput + 3, // 9: test.patch.v1.Pv77FooService.Pv77Foo:output_type -> test.patch.v1.Pv77FooOutput + 5, // 10: test.patch.v1.Pv77BarService.Pv77Bar:output_type -> test.patch.v1.Pv77BarOutput + 7, // 11: test.patch.v1.Pv77BazService.Pv77Baz:output_type -> test.patch.v1.Pv77BazOutput + 9, // 12: test.patch.v1.Pv77QuxService.Pv77Qux:output_type -> test.patch.v1.Pv77QuxOutput + 9, // [9:13] is the sub-list for method output_type + 5, // [5:9] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_test_patch_v1_pv77_proto_init() } +func file_test_patch_v1_pv77_proto_init() { + if File_test_patch_v1_pv77_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_test_patch_v1_pv77_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*Pv77Input); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_patch_v1_pv77_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*Pv77Output); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_patch_v1_pv77_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*Pv77FooInput); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_patch_v1_pv77_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*Pv77FooOutput); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_patch_v1_pv77_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*Pv77BarInput); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_patch_v1_pv77_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*Pv77BarOutput); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_patch_v1_pv77_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*Pv77BazInput); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_patch_v1_pv77_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*Pv77BazOutput); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_patch_v1_pv77_proto_msgTypes[8].Exporter = func(v any, i int) any { + switch v := v.(*Pv77QuxInput); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_patch_v1_pv77_proto_msgTypes[9].Exporter = func(v any, i int) any { + switch v := v.(*Pv77QuxOutput); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_test_patch_v1_pv77_proto_rawDesc, + NumEnums: 0, + NumMessages: 15, + NumExtensions: 0, + NumServices: 4, + }, + GoTypes: file_test_patch_v1_pv77_proto_goTypes, + DependencyIndexes: file_test_patch_v1_pv77_proto_depIdxs, + MessageInfos: file_test_patch_v1_pv77_proto_msgTypes, + }.Build() + File_test_patch_v1_pv77_proto = out.File + file_test_patch_v1_pv77_proto_rawDesc = nil + file_test_patch_v1_pv77_proto_goTypes = nil + file_test_patch_v1_pv77_proto_depIdxs = nil +} diff --git a/gen/test/patch/v1/pv77_temporal.pb.go b/gen/test/patch/v1/pv77_temporal.pb.go new file mode 100644 index 00000000..a7e20de0 --- /dev/null +++ b/gen/test/patch/v1/pv77_temporal.pb.go @@ -0,0 +1,4741 @@ +// Code generated by protoc-gen-go_temporal. DO NOT EDIT. +// versions: +// +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) +// go go1.22.2 +// protoc (unknown) +// +// source: test/patch/v1/pv77.proto +package patchv1 + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + helpers "github.com/cludden/protoc-gen-go-temporal/pkg/helpers" + patch "github.com/cludden/protoc-gen-go-temporal/pkg/patch" + scheme "github.com/cludden/protoc-gen-go-temporal/pkg/scheme" + gohomedir "github.com/mitchellh/go-homedir" + v2 "github.com/urfave/cli/v2" + enumsv1 "go.temporal.io/api/enums/v1" + activity "go.temporal.io/sdk/activity" + client "go.temporal.io/sdk/client" + temporal "go.temporal.io/sdk/temporal" + testsuite "go.temporal.io/sdk/testsuite" + worker "go.temporal.io/sdk/worker" + workflow "go.temporal.io/sdk/workflow" + protojson "google.golang.org/protobuf/encoding/protojson" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + "log/slog" + "os" + "sort" + "time" +) + +// Pv77FooServiceTaskQueue is the default task-queue for a test.patch.v1.Pv77FooService worker +const Pv77FooServiceTaskQueue = "pv77-v1" + +// test.patch.v1.Pv77FooService workflow names +const ( + Pv77FooWorkflowName = "test.patch.v1.Pv77FooService.Pv77Foo" +) + +// test.patch.v1.Pv77FooService activity names +const ( + Pv77FooActivityName = "test.patch.v1.Pv77FooActivity" +) + +// Pv77FooServiceClient describes a client for a(n) test.patch.v1.Pv77FooService worker +type Pv77FooServiceClient interface { + // Pv77Foo executes a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow and blocks until error or response received + Pv77Foo(ctx context.Context, req *Pv77FooInput, opts ...*Pv77FooOptions) (*Pv77FooOutput, error) + + // Pv77FooAsync starts a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow and returns a handle to the workflow run + Pv77FooAsync(ctx context.Context, req *Pv77FooInput, opts ...*Pv77FooOptions) (Pv77FooRun, error) + + // GetPv77Foo retrieves a handle to an existing test.patch.v1.Pv77FooService.Pv77Foo workflow execution + GetPv77Foo(ctx context.Context, workflowID string, runID string) Pv77FooRun + + // CancelWorkflow requests cancellation of an existing workflow execution + CancelWorkflow(ctx context.Context, workflowID string, runID string) error + + // TerminateWorkflow an existing workflow execution + TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error +} + +// pv77FooServiceClient implements a temporal client for a test.patch.v1.Pv77FooService service +type pv77FooServiceClient struct { + client client.Client + log *slog.Logger +} + +// NewPv77FooServiceClient initializes a new test.patch.v1.Pv77FooService client +func NewPv77FooServiceClient(c client.Client, options ...*pv77FooServiceClientOptions) Pv77FooServiceClient { + var cfg *pv77FooServiceClientOptions + if len(options) > 0 { + cfg = options[0] + } else { + cfg = NewPv77FooServiceClientOptions() + } + return &pv77FooServiceClient{ + client: c, + log: cfg.getLogger(), + } +} + +// NewPv77FooServiceClientWithOptions initializes a new Pv77FooService client with the given options +func NewPv77FooServiceClientWithOptions(c client.Client, opts client.Options, options ...*pv77FooServiceClientOptions) (Pv77FooServiceClient, error) { + var err error + c, err = client.NewClientFromExisting(c, opts) + if err != nil { + return nil, fmt.Errorf("error initializing client with options: %w", err) + } + var cfg *pv77FooServiceClientOptions + if len(options) > 0 { + cfg = options[0] + } else { + cfg = NewPv77FooServiceClientOptions() + } + return &pv77FooServiceClient{ + client: c, + log: cfg.getLogger(), + }, nil +} + +// pv77FooServiceClientOptions describes optional runtime configuration for a Pv77FooServiceClient +type pv77FooServiceClientOptions struct { + log *slog.Logger +} + +// NewPv77FooServiceClientOptions initializes a new pv77FooServiceClientOptions value +func NewPv77FooServiceClientOptions() *pv77FooServiceClientOptions { + return &pv77FooServiceClientOptions{} +} + +// WithLogger can be used to override the default logger +func (opts *pv77FooServiceClientOptions) WithLogger(l *slog.Logger) *pv77FooServiceClientOptions { + if l != nil { + opts.log = l + } + return opts +} + +// getLogger returns the configured logger, or the default logger +func (opts *pv77FooServiceClientOptions) getLogger() *slog.Logger { + if opts != nil && opts.log != nil { + return opts.log + } + return slog.Default() +} + +// test.patch.v1.Pv77FooService.Pv77Foo executes a test.patch.v1.Pv77FooService.Pv77Foo workflow and blocks until error or response received +func (c *pv77FooServiceClient) Pv77Foo(ctx context.Context, req *Pv77FooInput, options ...*Pv77FooOptions) (*Pv77FooOutput, error) { + run, err := c.Pv77FooAsync(ctx, req, options...) + if err != nil { + return nil, err + } + return run.Get(ctx) +} + +// Pv77FooAsync starts a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow and returns a handle to the workflow run +func (c *pv77FooServiceClient) Pv77FooAsync(ctx context.Context, req *Pv77FooInput, options ...*Pv77FooOptions) (Pv77FooRun, error) { + var o *Pv77FooOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77FooOptions() + } + opts, err := o.Build(req.ProtoReflect()) + if err != nil { + return nil, fmt.Errorf("error initializing client.StartWorkflowOptions: %w", err) + } + run, err := c.client.ExecuteWorkflow(ctx, opts, Pv77FooWorkflowName, req) + if err != nil { + return nil, err + } + if run == nil { + return nil, errors.New("execute workflow returned nil run") + } + return &pv77FooRun{ + client: c, + run: run, + }, nil +} + +// GetPv77Foo fetches an existing test.patch.v1.Pv77FooService.Pv77Foo execution +func (c *pv77FooServiceClient) GetPv77Foo(ctx context.Context, workflowID string, runID string) Pv77FooRun { + return &pv77FooRun{ + client: c, + run: c.client.GetWorkflow(ctx, workflowID, runID), + } +} + +// CancelWorkflow requests cancellation of an existing workflow execution +func (c *pv77FooServiceClient) CancelWorkflow(ctx context.Context, workflowID string, runID string) error { + return c.client.CancelWorkflow(ctx, workflowID, runID) +} + +// TerminateWorkflow terminates an existing workflow execution +func (c *pv77FooServiceClient) TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error { + return c.client.TerminateWorkflow(ctx, workflowID, runID, reason, details...) +} + +// Pv77FooOptions provides configuration for a test.patch.v1.Pv77FooService.Pv77Foo workflow operation +type Pv77FooOptions struct { + options client.StartWorkflowOptions + executionTimeout *time.Duration + id *string + idReusePolicy enumsv1.WorkflowIdReusePolicy + retryPolicy *temporal.RetryPolicy + runTimeout *time.Duration + searchAttributes map[string]any + taskQueue *string + taskTimeout *time.Duration +} + +// NewPv77FooOptions initializes a new Pv77FooOptions value +func NewPv77FooOptions() *Pv77FooOptions { + return &Pv77FooOptions{} +} + +// Build initializes a new go.temporal.io/sdk/client.StartWorkflowOptions value with defaults and overrides applied +func (o *Pv77FooOptions) Build(req protoreflect.Message) (client.StartWorkflowOptions, error) { + opts := o.options + if v := o.id; v != nil { + opts.ID = *v + } + if v := o.idReusePolicy; v != enumsv1.WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED { + opts.WorkflowIDReusePolicy = v + } + if v := o.taskQueue; v != nil { + opts.TaskQueue = *v + } else if opts.TaskQueue == "" { + opts.TaskQueue = Pv77FooServiceTaskQueue + } + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.searchAttributes; v != nil { + opts.SearchAttributes = o.searchAttributes + } + if v := o.executionTimeout; v != nil { + opts.WorkflowExecutionTimeout = *v + } + if v := o.runTimeout; v != nil { + opts.WorkflowRunTimeout = *v + } + if v := o.taskTimeout; v != nil { + opts.WorkflowTaskTimeout = *v + } + return opts, nil +} + +// WithStartWorkflowOptions sets the initial go.temporal.io/sdk/client.StartWorkflowOptions +func (o *Pv77FooOptions) WithStartWorkflowOptions(options client.StartWorkflowOptions) *Pv77FooOptions { + o.options = options + return o +} + +// WithExecutionTimeout sets the WorkflowExecutionTimeout value +func (o *Pv77FooOptions) WithExecutionTimeout(d time.Duration) *Pv77FooOptions { + o.executionTimeout = &d + return o +} + +// WithID sets the ID value +func (o *Pv77FooOptions) WithID(id string) *Pv77FooOptions { + o.id = &id + return o +} + +// WithIDReusePolicy sets the WorkflowIDReusePolicy value +func (o *Pv77FooOptions) WithIDReusePolicy(policy enumsv1.WorkflowIdReusePolicy) *Pv77FooOptions { + o.idReusePolicy = policy + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77FooOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77FooOptions { + o.retryPolicy = policy + return o +} + +// WithRunTimeout sets the WorkflowRunTimeout value +func (o *Pv77FooOptions) WithRunTimeout(d time.Duration) *Pv77FooOptions { + o.runTimeout = &d + return o +} + +// WithSearchAttributes sets the SearchAttributes value +func (o *Pv77FooOptions) WithSearchAttributes(sa map[string]any) *Pv77FooOptions { + o.searchAttributes = sa + return o +} + +// WithTaskTimeout sets the WorkflowTaskTimeout value +func (o *Pv77FooOptions) WithTaskTimeout(d time.Duration) *Pv77FooOptions { + o.taskTimeout = &d + return o +} + +// WithTaskQueue sets the TaskQueue value +func (o *Pv77FooOptions) WithTaskQueue(tq string) *Pv77FooOptions { + o.taskQueue = &tq + return o +} + +// Pv77FooRun describes a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow run +type Pv77FooRun interface { + // ID returns the workflow ID + ID() string + + // RunID returns the workflow instance ID + RunID() string + + // Run returns the inner client.WorkflowRun + Run() client.WorkflowRun + + // Get blocks until the workflow is complete and returns the result + Get(ctx context.Context) (*Pv77FooOutput, error) + + // Cancel requests cancellation of a workflow in execution, returning an error if applicable + Cancel(ctx context.Context) error + + // Terminate terminates a workflow in execution, returning an error if applicable + Terminate(ctx context.Context, reason string, details ...interface{}) error +} + +// pv77FooRun provides an internal implementation of a(n) Pv77FooRunRun +type pv77FooRun struct { + client *pv77FooServiceClient + run client.WorkflowRun +} + +// ID returns the workflow ID +func (r *pv77FooRun) ID() string { + return r.run.GetID() +} + +// Run returns the inner client.WorkflowRun +func (r *pv77FooRun) Run() client.WorkflowRun { + return r.run +} + +// RunID returns the execution ID +func (r *pv77FooRun) RunID() string { + return r.run.GetRunID() +} + +// Cancel requests cancellation of a workflow in execution, returning an error if applicable +func (r *pv77FooRun) Cancel(ctx context.Context) error { + return r.client.CancelWorkflow(ctx, r.ID(), r.RunID()) +} + +// Get blocks until the workflow is complete, returning the result if applicable +func (r *pv77FooRun) Get(ctx context.Context) (*Pv77FooOutput, error) { + var resp Pv77FooOutput + if err := r.run.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// Terminate terminates a workflow in execution, returning an error if applicable +func (r *pv77FooRun) Terminate(ctx context.Context, reason string, details ...interface{}) error { + return r.client.TerminateWorkflow(ctx, r.ID(), r.RunID(), reason, details...) +} + +// Reference to generated workflow functions +var ( + // Pv77FooFunction implements a "test.patch.v1.Pv77FooService.Pv77Foo" workflow + Pv77FooFunction func(workflow.Context, *Pv77FooInput) (*Pv77FooOutput, error) +) + +// Pv77FooServiceWorkflowFunctions describes a mockable dependency for inlining workflows within other workflows +type ( + // Pv77FooServiceWorkflowFunctions describes a mockable dependency for inlining workflows within other workflows + Pv77FooServiceWorkflowFunctions interface { + // Pv77Foo executes a "test.patch.v1.Pv77FooService.Pv77Foo" workflow inline + Pv77Foo(workflow.Context, *Pv77FooInput) (*Pv77FooOutput, error) + } + // pv77FooServiceWorkflowFunctions provides an internal Pv77FooServiceWorkflowFunctions implementation + pv77FooServiceWorkflowFunctions struct{} +) + +func NewPv77FooServiceWorkflowFunctions() Pv77FooServiceWorkflowFunctions { + return &pv77FooServiceWorkflowFunctions{} +} + +// Pv77Foo executes a "test.patch.v1.Pv77FooService.Pv77Foo" workflow inline +func (f *pv77FooServiceWorkflowFunctions) Pv77Foo(ctx workflow.Context, req *Pv77FooInput) (*Pv77FooOutput, error) { + if Pv77FooFunction == nil { + return nil, errors.New("Pv77Foo requires workflow registration via RegisterPv77FooServiceWorkflows or RegisterPv77FooWorkflow") + } + return Pv77FooFunction(ctx, req) +} + +// Pv77FooServiceWorkflows provides methods for initializing new test.patch.v1.Pv77FooService workflow values +type Pv77FooServiceWorkflows interface { + // Pv77Foo initializes a new a(n) Pv77FooWorkflow implementation + Pv77Foo(ctx workflow.Context, input *Pv77FooWorkflowInput) (Pv77FooWorkflow, error) +} + +// RegisterPv77FooServiceWorkflows registers test.patch.v1.Pv77FooService workflows with the given worker +func RegisterPv77FooServiceWorkflows(r worker.WorkflowRegistry, workflows Pv77FooServiceWorkflows) { + RegisterPv77FooWorkflow(r, workflows.Pv77Foo) +} + +// RegisterPv77FooWorkflow registers a test.patch.v1.Pv77FooService.Pv77Foo workflow with the given worker +func RegisterPv77FooWorkflow(r worker.WorkflowRegistry, wf func(workflow.Context, *Pv77FooWorkflowInput) (Pv77FooWorkflow, error)) { + Pv77FooFunction = buildPv77Foo(wf) + r.RegisterWorkflowWithOptions(Pv77FooFunction, workflow.RegisterOptions{Name: Pv77FooWorkflowName}) +} + +// buildPv77Foo converts a Pv77Foo workflow struct into a valid workflow function +func buildPv77Foo(ctor func(workflow.Context, *Pv77FooWorkflowInput) (Pv77FooWorkflow, error)) func(workflow.Context, *Pv77FooInput) (*Pv77FooOutput, error) { + return func(ctx workflow.Context, req *Pv77FooInput) (*Pv77FooOutput, error) { + input := &Pv77FooWorkflowInput{ + Req: req, + } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, Pv77FooServiceTaskQueue, workflow.GetInfo(ctx).TaskQueueName) + wf, err := ctor(ctx, input) + if err != nil { + return nil, err + } + if initializable, ok := wf.(helpers.Initializable); ok { + if err := initializable.Initialize(ctx); err != nil { + return nil, err + } + } + return wf.Execute(ctx) + } +} + +// Pv77FooWorkflowInput describes the input to a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow constructor +type Pv77FooWorkflowInput struct { + Req *Pv77FooInput +} + +// Pv77FooWorkflow describes a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow implementation +type Pv77FooWorkflow interface { + // Execute defines the entrypoint to a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow + Execute(ctx workflow.Context) (*Pv77FooOutput, error) +} + +// Pv77FooChild executes a child test.patch.v1.Pv77FooService.Pv77Foo workflow and blocks until error or response received +func Pv77FooChild(ctx workflow.Context, req *Pv77FooInput, options ...*Pv77FooChildOptions) (*Pv77FooOutput, error) { + childRun, err := Pv77FooChildAsync(ctx, req, options...) + if err != nil { + return nil, err + } + return childRun.Get(ctx) +} + +// Pv77FooChildAsync starts a child test.patch.v1.Pv77FooService.Pv77Foo workflow and returns a handle to the child workflow run +func Pv77FooChildAsync(ctx workflow.Context, req *Pv77FooInput, options ...*Pv77FooChildOptions) (*Pv77FooChildRun, error) { + var o *Pv77FooChildOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77FooChildOptions() + } + opts, err := o.Build(ctx, req.ProtoReflect()) + if err != nil { + return nil, fmt.Errorf("error initializing workflow.ChildWorkflowOptions: %w", err) + } + ctx = workflow.WithChildOptions(ctx, opts) + return &Pv77FooChildRun{Future: workflow.ExecuteChildWorkflow(ctx, Pv77FooWorkflowName, req)}, nil +} + +// Pv77FooChildOptions provides configuration for a child test.patch.v1.Pv77FooService.Pv77Foo workflow operation +type Pv77FooChildOptions struct { + options workflow.ChildWorkflowOptions + executionTimeout *time.Duration + id *string + idReusePolicy enumsv1.WorkflowIdReusePolicy + retryPolicy *temporal.RetryPolicy + runTimeout *time.Duration + searchAttributes map[string]any + taskQueue *string + taskTimeout *time.Duration + parentClosePolicy enumsv1.ParentClosePolicy + waitForCancellation *bool +} + +// NewPv77FooChildOptions initializes a new Pv77FooChildOptions value +func NewPv77FooChildOptions() *Pv77FooChildOptions { + return &Pv77FooChildOptions{} +} + +// Build initializes a new go.temporal.io/sdk/workflow.ChildWorkflowOptions value with defaults and overrides applied +func (o *Pv77FooChildOptions) Build(ctx workflow.Context, req protoreflect.Message) (workflow.ChildWorkflowOptions, error) { + opts := o.options + if v := o.id; v != nil { + opts.WorkflowID = *v + } + if v := o.idReusePolicy; v != enumsv1.WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED { + opts.WorkflowIDReusePolicy = v + } + if v := o.taskQueue; v != nil { + opts.TaskQueue = *v + } else if opts.TaskQueue == "" { + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, Pv77FooServiceTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = Pv77FooServiceTaskQueue + } + } + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.searchAttributes; v != nil { + opts.SearchAttributes = o.searchAttributes + } + if v := o.executionTimeout; v != nil { + opts.WorkflowExecutionTimeout = *v + } + if v := o.runTimeout; v != nil { + opts.WorkflowRunTimeout = *v + } + if v := o.taskTimeout; v != nil { + opts.WorkflowTaskTimeout = *v + } + if v := o.parentClosePolicy; v != enumsv1.PARENT_CLOSE_POLICY_UNSPECIFIED { + opts.ParentClosePolicy = v + } + if v := o.waitForCancellation; v != nil { + opts.WaitForCancellation = *v + } + return opts, nil +} + +// WithChildWorkflowOptions sets the initial go.temporal.io/sdk/workflow.ChildWorkflowOptions +func (o *Pv77FooChildOptions) WithChildWorkflowOptions(options workflow.ChildWorkflowOptions) *Pv77FooChildOptions { + o.options = options + return o +} + +// WithExecutionTimeout sets the WorkflowExecutionTimeout value +func (o *Pv77FooChildOptions) WithExecutionTimeout(d time.Duration) *Pv77FooChildOptions { + o.executionTimeout = &d + return o +} + +// WithID sets the WorkflowID value +func (o *Pv77FooChildOptions) WithID(id string) *Pv77FooChildOptions { + o.id = &id + return o +} + +// WithIDReusePolicy sets the WorkflowIDReusePolicy value +func (o *Pv77FooChildOptions) WithIDReusePolicy(policy enumsv1.WorkflowIdReusePolicy) *Pv77FooChildOptions { + o.idReusePolicy = policy + return o +} + +// WithParentClosePolicy sets the WorkflowIDReusePolicy value +func (o *Pv77FooChildOptions) WithParentClosePolicy(policy enumsv1.ParentClosePolicy) *Pv77FooChildOptions { + o.parentClosePolicy = policy + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77FooChildOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77FooChildOptions { + o.retryPolicy = policy + return o +} + +// WithRunTimeout sets the WorkflowRunTimeout value +func (o *Pv77FooChildOptions) WithRunTimeout(d time.Duration) *Pv77FooChildOptions { + o.runTimeout = &d + return o +} + +// WithSearchAttributes sets the SearchAttributes value +func (o *Pv77FooChildOptions) WithSearchAttributes(sa map[string]any) *Pv77FooChildOptions { + o.searchAttributes = sa + return o +} + +// WithTaskTimeout sets the WorkflowTaskTimeout value +func (o *Pv77FooChildOptions) WithTaskTimeout(d time.Duration) *Pv77FooChildOptions { + o.taskTimeout = &d + return o +} + +// WithTaskQueue sets the TaskQueue value +func (o *Pv77FooChildOptions) WithTaskQueue(tq string) *Pv77FooChildOptions { + o.taskQueue = &tq + return o +} + +// WithWaitForCancellation sets the WaitForCancellation value +func (o *Pv77FooChildOptions) WithWaitForCancellation(wait bool) *Pv77FooChildOptions { + o.waitForCancellation = &wait + return o +} + +// Pv77FooChildRun describes a child Pv77Foo workflow run +type Pv77FooChildRun struct { + Future workflow.ChildWorkflowFuture +} + +// Get blocks until the workflow is completed, returning the response value +func (r *Pv77FooChildRun) Get(ctx workflow.Context) (*Pv77FooOutput, error) { + var resp Pv77FooOutput + if err := r.Future.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// Select adds this completion to the selector. Callback can be nil. +func (r *Pv77FooChildRun) Select(sel workflow.Selector, fn func(*Pv77FooChildRun)) workflow.Selector { + return sel.AddFuture(r.Future, func(workflow.Future) { + if fn != nil { + fn(r) + } + }) +} + +// SelectStart adds waiting for start to the selector. Callback can be nil. +func (r *Pv77FooChildRun) SelectStart(sel workflow.Selector, fn func(*Pv77FooChildRun)) workflow.Selector { + return sel.AddFuture(r.Future.GetChildWorkflowExecution(), func(workflow.Future) { + if fn != nil { + fn(r) + } + }) +} + +// WaitStart waits for the child workflow to start +func (r *Pv77FooChildRun) WaitStart(ctx workflow.Context) (*workflow.Execution, error) { + var exec workflow.Execution + if err := r.Future.GetChildWorkflowExecution().Get(ctx, &exec); err != nil { + return nil, err + } + return &exec, nil +} + +// Pv77FooServiceActivities describes available worker activities +type Pv77FooServiceActivities interface { + // test.patch.v1.Pv77FooService.Pv77Foo implements a(n) test.patch.v1.Pv77FooActivity activity definition + Pv77Foo(ctx context.Context, req *Pv77FooInput) (*Pv77FooOutput, error) +} + +// RegisterPv77FooServiceActivities registers activities with a worker +func RegisterPv77FooServiceActivities(r worker.ActivityRegistry, activities Pv77FooServiceActivities) { + RegisterPv77FooActivity(r, activities.Pv77Foo) +} + +// RegisterPv77FooActivity registers a test.patch.v1.Pv77FooActivity activity +func RegisterPv77FooActivity(r worker.ActivityRegistry, fn func(context.Context, *Pv77FooInput) (*Pv77FooOutput, error)) { + r.RegisterActivityWithOptions(fn, activity.RegisterOptions{ + Name: Pv77FooActivityName, + }) +} + +// Pv77FooFuture describes a(n) test.patch.v1.Pv77FooActivity activity execution +type Pv77FooFuture struct { + Future workflow.Future +} + +// Get blocks on the activity's completion, returning the response +func (f *Pv77FooFuture) Get(ctx workflow.Context) (*Pv77FooOutput, error) { + var resp Pv77FooOutput + if err := f.Future.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// Select adds the activity's completion to the selector, callback can be nil +func (f *Pv77FooFuture) Select(sel workflow.Selector, fn func(*Pv77FooFuture)) workflow.Selector { + return sel.AddFuture(f.Future, func(workflow.Future) { + if fn != nil { + fn(f) + } + }) +} + +// Pv77Foo executes a(n) test.patch.v1.Pv77FooActivity activity +func Pv77Foo(ctx workflow.Context, req *Pv77FooInput, options ...*Pv77FooActivityOptions) (*Pv77FooOutput, error) { + return Pv77FooAsync(ctx, req, options...).Get(ctx) +} + +// Pv77FooAsync executes a(n) test.patch.v1.Pv77FooActivity activity (asynchronously) +func Pv77FooAsync(ctx workflow.Context, req *Pv77FooInput, options ...*Pv77FooActivityOptions) *Pv77FooFuture { + var o *Pv77FooActivityOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77FooActivityOptions() + } + var err error + if ctx, err = o.Build(ctx); err != nil { + errF, errS := workflow.NewFuture(ctx) + errS.SetError(err) + return &Pv77FooFuture{Future: errF} + } + activity := Pv77FooActivityName + future := &Pv77FooFuture{Future: workflow.ExecuteActivity(ctx, activity, req)} + return future +} + +// Pv77FooLocal executes a(n) test.patch.v1.Pv77FooActivity activity (locally) +func Pv77FooLocal(ctx workflow.Context, req *Pv77FooInput, options ...*Pv77FooLocalActivityOptions) (*Pv77FooOutput, error) { + return Pv77FooLocalAsync(ctx, req, options...).Get(ctx) +} + +// Pv77FooLocalAsync executes a(n) test.patch.v1.Pv77FooActivity activity (asynchronously, locally) +func Pv77FooLocalAsync(ctx workflow.Context, req *Pv77FooInput, options ...*Pv77FooLocalActivityOptions) *Pv77FooFuture { + var o *Pv77FooLocalActivityOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77FooLocalActivityOptions() + } + var err error + if ctx, err = o.Build(ctx); err != nil { + errF, errS := workflow.NewFuture(ctx) + errS.SetError(err) + return &Pv77FooFuture{Future: errF} + } + var activity any + if o.fn != nil { + activity = o.fn + } else { + activity = Pv77FooActivityName + } + future := &Pv77FooFuture{Future: workflow.ExecuteLocalActivity(ctx, activity, req)} + return future +} + +// Pv77FooActivityOptions provides configuration for a(n) test.patch.v1.Pv77FooActivity activity +type Pv77FooActivityOptions struct { + options workflow.ActivityOptions + retryPolicy *temporal.RetryPolicy + scheduleToCloseTimeout *time.Duration + startToCloseTimeout *time.Duration + heartbeatTimeout *time.Duration + scheduleToStartTimeout *time.Duration + taskQueue *string + waitForCancellation *bool +} + +// NewPv77FooActivityOptions initializes a new Pv77FooActivityOptions value +func NewPv77FooActivityOptions() *Pv77FooActivityOptions { + return &Pv77FooActivityOptions{} +} + +// Build initializes a workflow.Context with appropriate ActivityOptions values derived from schema defaults and any user-defined overrides +func (o *Pv77FooActivityOptions) Build(ctx workflow.Context) (workflow.Context, error) { + opts := o.options + if v := o.heartbeatTimeout; v != nil { + opts.HeartbeatTimeout = *v + } + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.scheduleToCloseTimeout; v != nil { + opts.ScheduleToCloseTimeout = *v + } + if v := o.scheduleToStartTimeout; v != nil { + opts.ScheduleToStartTimeout = *v + } + if v := o.startToCloseTimeout; v != nil { + opts.StartToCloseTimeout = *v + } else if opts.StartToCloseTimeout == 0 { + opts.StartToCloseTimeout = 5000000000 // 5 seconds + } + if v := o.taskQueue; v != nil { + opts.TaskQueue = *v + } else if opts.TaskQueue == "" { + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, Pv77FooServiceTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = Pv77FooServiceTaskQueue + } + } + if v := o.waitForCancellation; v != nil { + opts.WaitForCancellation = *v + } + return workflow.WithActivityOptions(ctx, opts), nil +} + +// WithActivityOptions specifies an initial ActivityOptions value to which defaults will be applied +func (o *Pv77FooActivityOptions) WithActivityOptions(options workflow.ActivityOptions) *Pv77FooActivityOptions { + o.options = options + return o +} + +// WithHeartbeatTimeout sets the HeartbeatTimeout value +func (o *Pv77FooActivityOptions) WithHeartbeatTimeout(d time.Duration) *Pv77FooActivityOptions { + o.heartbeatTimeout = &d + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77FooActivityOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77FooActivityOptions { + o.retryPolicy = policy + return o +} + +// WithScheduleToCloseTimeout sets the ScheduleToCloseTimeout value +func (o *Pv77FooActivityOptions) WithScheduleToCloseTimeout(d time.Duration) *Pv77FooActivityOptions { + o.scheduleToCloseTimeout = &d + return o +} + +// WithScheduleToStartTimeout sets the ScheduleToStartTimeout value +func (o *Pv77FooActivityOptions) WithScheduleToStartTimeout(d time.Duration) *Pv77FooActivityOptions { + o.scheduleToStartTimeout = &d + return o +} + +// WithStartToCloseTimeout sets the StartToCloseTimeout value +func (o *Pv77FooActivityOptions) WithStartToCloseTimeout(d time.Duration) *Pv77FooActivityOptions { + o.startToCloseTimeout = &d + return o +} + +// WithTaskQueue sets the TaskQueue value +func (o *Pv77FooActivityOptions) WithTaskQueue(tq string) *Pv77FooActivityOptions { + o.taskQueue = &tq + return o +} + +// WithWaitForCancellation sets the WaitForCancellation value +func (o *Pv77FooActivityOptions) WithWaitForCancellation(wait bool) *Pv77FooActivityOptions { + o.waitForCancellation = &wait + return o +} + +// Pv77FooLocalActivityOptions provides configuration for a(n) test.patch.v1.Pv77FooActivity activity +type Pv77FooLocalActivityOptions struct { + options workflow.LocalActivityOptions + retryPolicy *temporal.RetryPolicy + scheduleToCloseTimeout *time.Duration + startToCloseTimeout *time.Duration + fn func(context.Context, *Pv77FooInput) (*Pv77FooOutput, error) +} + +// NewPv77FooLocalActivityOptions initializes a new Pv77FooLocalActivityOptions value +func NewPv77FooLocalActivityOptions() *Pv77FooLocalActivityOptions { + return &Pv77FooLocalActivityOptions{} +} + +// Build initializes a workflow.Context with appropriate LocalActivityOptions values derived from schema defaults and any user-defined overrides +func (o *Pv77FooLocalActivityOptions) Build(ctx workflow.Context) (workflow.Context, error) { + opts := o.options + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.scheduleToCloseTimeout; v != nil { + opts.ScheduleToCloseTimeout = *v + } + if v := o.startToCloseTimeout; v != nil { + opts.StartToCloseTimeout = *v + } else if opts.StartToCloseTimeout == 0 { + opts.StartToCloseTimeout = 5000000000 // 5 seconds + } + return workflow.WithLocalActivityOptions(ctx, opts), nil +} + +// Local specifies a custom test.patch.v1.Pv77FooActivity implementation +func (o *Pv77FooLocalActivityOptions) Local(fn func(context.Context, *Pv77FooInput) (*Pv77FooOutput, error)) *Pv77FooLocalActivityOptions { + o.fn = fn + return o +} + +// WithLocalActivityOptions specifies an initial LocalActivityOptions value to which defaults will be applied +func (o *Pv77FooLocalActivityOptions) WithLocalActivityOptions(options workflow.LocalActivityOptions) *Pv77FooLocalActivityOptions { + o.options = options + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77FooLocalActivityOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77FooLocalActivityOptions { + o.retryPolicy = policy + return o +} + +// WithScheduleToCloseTimeout sets the ScheduleToCloseTimeout value +func (o *Pv77FooLocalActivityOptions) WithScheduleToCloseTimeout(d time.Duration) *Pv77FooLocalActivityOptions { + o.scheduleToCloseTimeout = &d + return o +} + +// WithStartToCloseTimeout sets the StartToCloseTimeout value +func (o *Pv77FooLocalActivityOptions) WithStartToCloseTimeout(d time.Duration) *Pv77FooLocalActivityOptions { + o.startToCloseTimeout = &d + return o +} + +// TestClient provides a testsuite-compatible Client +type TestPv77FooServiceClient struct { + env *testsuite.TestWorkflowEnvironment + workflows Pv77FooServiceWorkflows +} + +var _ Pv77FooServiceClient = &TestPv77FooServiceClient{} + +// NewTestPv77FooServiceClient initializes a new TestPv77FooServiceClient value +func NewTestPv77FooServiceClient(env *testsuite.TestWorkflowEnvironment, workflows Pv77FooServiceWorkflows, activities Pv77FooServiceActivities) *TestPv77FooServiceClient { + if workflows != nil { + RegisterPv77FooServiceWorkflows(env, workflows) + } + if activities != nil { + RegisterPv77FooServiceActivities(env, activities) + } + return &TestPv77FooServiceClient{env, workflows} +} + +// Pv77Foo executes a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow in the test environment +func (c *TestPv77FooServiceClient) Pv77Foo(ctx context.Context, req *Pv77FooInput, opts ...*Pv77FooOptions) (*Pv77FooOutput, error) { + run, err := c.Pv77FooAsync(ctx, req, opts...) + if err != nil { + return nil, err + } + return run.Get(ctx) +} + +// Pv77FooAsync executes a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow in the test environment +func (c *TestPv77FooServiceClient) Pv77FooAsync(ctx context.Context, req *Pv77FooInput, options ...*Pv77FooOptions) (Pv77FooRun, error) { + var o *Pv77FooOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77FooOptions() + } + opts, err := o.Build(req.ProtoReflect()) + if err != nil { + return nil, fmt.Errorf("error initializing client.StartWorkflowOptions: %w", err) + } + return &testPv77FooRun{client: c, env: c.env, opts: &opts, req: req, workflows: c.workflows}, nil +} + +// GetPv77Foo is a noop +func (c *TestPv77FooServiceClient) GetPv77Foo(ctx context.Context, workflowID string, runID string) Pv77FooRun { + return &testPv77FooRun{env: c.env, workflows: c.workflows} +} + +// CancelWorkflow requests cancellation of an existing workflow execution +func (c *TestPv77FooServiceClient) CancelWorkflow(ctx context.Context, workflowID string, runID string) error { + c.env.CancelWorkflow() + return nil +} + +// TerminateWorkflow terminates an existing workflow execution +func (c *TestPv77FooServiceClient) TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error { + return c.CancelWorkflow(ctx, workflowID, runID) +} + +var _ Pv77FooRun = &testPv77FooRun{} + +// testPv77FooRun provides convenience methods for interacting with a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow in the test environment +type testPv77FooRun struct { + client *TestPv77FooServiceClient + env *testsuite.TestWorkflowEnvironment + opts *client.StartWorkflowOptions + req *Pv77FooInput + workflows Pv77FooServiceWorkflows +} + +// Cancel requests cancellation of a workflow in execution, returning an error if applicable +func (r *testPv77FooRun) Cancel(ctx context.Context) error { + return r.client.CancelWorkflow(ctx, r.ID(), r.RunID()) +} + +// Get retrieves a test test.patch.v1.Pv77FooService.Pv77Foo workflow result +func (r *testPv77FooRun) Get(context.Context) (*Pv77FooOutput, error) { + r.env.ExecuteWorkflow(Pv77FooWorkflowName, r.req) + if !r.env.IsWorkflowCompleted() { + return nil, errors.New("workflow in progress") + } + if err := r.env.GetWorkflowError(); err != nil { + return nil, err + } + var result Pv77FooOutput + if err := r.env.GetWorkflowResult(&result); err != nil { + return nil, err + } + return &result, nil +} + +// ID returns a test test.patch.v1.Pv77FooService.Pv77Foo workflow run's workflow ID +func (r *testPv77FooRun) ID() string { + if r.opts != nil { + return r.opts.ID + } + return "" +} + +// Run noop implementation +func (r *testPv77FooRun) Run() client.WorkflowRun { + return nil +} + +// RunID noop implementation +func (r *testPv77FooRun) RunID() string { + return "" +} + +// Terminate terminates a workflow in execution, returning an error if applicable +func (r *testPv77FooRun) Terminate(ctx context.Context, reason string, details ...interface{}) error { + return r.client.TerminateWorkflow(ctx, r.ID(), r.RunID(), reason, details...) +} + +// Pv77FooServiceCliOptions describes runtime configuration for test.patch.v1.Pv77FooService cli +type Pv77FooServiceCliOptions struct { + after func(*v2.Context) error + before func(*v2.Context) error + clientForCommand func(*v2.Context) (client.Client, error) + worker func(*v2.Context, client.Client) (worker.Worker, error) +} + +// NewPv77FooServiceCliOptions initializes a new Pv77FooServiceCliOptions value +func NewPv77FooServiceCliOptions() *Pv77FooServiceCliOptions { + return &Pv77FooServiceCliOptions{} +} + +// WithAfter injects a custom After hook to be run after any command invocation +func (opts *Pv77FooServiceCliOptions) WithAfter(fn func(*v2.Context) error) *Pv77FooServiceCliOptions { + opts.after = fn + return opts +} + +// WithBefore injects a custom Before hook to be run prior to any command invocation +func (opts *Pv77FooServiceCliOptions) WithBefore(fn func(*v2.Context) error) *Pv77FooServiceCliOptions { + opts.before = fn + return opts +} + +// WithClient provides a Temporal client factory for use by commands +func (opts *Pv77FooServiceCliOptions) WithClient(fn func(*v2.Context) (client.Client, error)) *Pv77FooServiceCliOptions { + opts.clientForCommand = fn + return opts +} + +// WithWorker provides an method for initializing a worker +func (opts *Pv77FooServiceCliOptions) WithWorker(fn func(*v2.Context, client.Client) (worker.Worker, error)) *Pv77FooServiceCliOptions { + opts.worker = fn + return opts +} + +// NewPv77FooServiceCli initializes a cli for a(n) test.patch.v1.Pv77FooService service +func NewPv77FooServiceCli(options ...*Pv77FooServiceCliOptions) (*v2.App, error) { + commands, err := newPv77FooServiceCommands(options...) + if err != nil { + return nil, fmt.Errorf("error initializing subcommands: %w", err) + } + return &v2.App{ + Name: "pv-77-foo-service", + Commands: commands, + }, nil +} + +// NewPv77FooServiceCliCommand initializes a cli command for a test.patch.v1.Pv77FooService service with subcommands for each query, signal, update, and workflow +func NewPv77FooServiceCliCommand(options ...*Pv77FooServiceCliOptions) (*v2.Command, error) { + subcommands, err := newPv77FooServiceCommands(options...) + if err != nil { + return nil, fmt.Errorf("error initializing subcommands: %w", err) + } + return &v2.Command{ + Name: "pv-77-foo-service", + Subcommands: subcommands, + }, nil +} + +// newPv77FooServiceCommands initializes (sub)commands for a test.patch.v1.Pv77FooService cli or command +func newPv77FooServiceCommands(options ...*Pv77FooServiceCliOptions) ([]*v2.Command, error) { + opts := &Pv77FooServiceCliOptions{} + if len(options) > 0 { + opts = options[0] + } + if opts.clientForCommand == nil { + opts.clientForCommand = func(*v2.Context) (client.Client, error) { + return client.Dial(client.Options{}) + } + } + commands := []*v2.Command{ + { + Name: "pv-77-foo", + Usage: "executes a(n) test.patch.v1.Pv77FooService.Pv77Foo workflow", + Category: "WORKFLOWS", + UseShortOptionHandling: true, + Before: opts.before, + After: opts.after, + Flags: []v2.Flag{ + &v2.BoolFlag{ + Name: "detach", + Usage: "run workflow in the background and print workflow and execution id", + Aliases: []string{"d"}, + }, + &v2.StringFlag{ + Name: "task-queue", + Usage: "task queue name", + Aliases: []string{"t"}, + EnvVars: []string{"TEMPORAL_TASK_QUEUE_NAME", "TEMPORAL_TASK_QUEUE", "TASK_QUEUE_NAME", "TASK_QUEUE"}, + Value: "pv77-v1", + }, + &v2.StringFlag{ + Name: "input-file", + Usage: "path to json-formatted input file", + Aliases: []string{"f"}, + }, + &v2.StringSliceFlag{ + Name: "next", + Usage: "set the value of the operation's \"Next\" parameter", + Category: "INPUT", + }, + }, + Action: func(cmd *v2.Context) error { + tc, err := opts.clientForCommand(cmd) + if err != nil { + return fmt.Errorf("error initializing client for command: %w", err) + } + defer tc.Close() + c := NewPv77FooServiceClient(tc) + req, err := UnmarshalCliFlagsToPv77FooInput(cmd) + if err != nil { + return fmt.Errorf("error unmarshalling request: %w", err) + } + opts := client.StartWorkflowOptions{} + if tq := cmd.String("task-queue"); tq != "" { + opts.TaskQueue = tq + } + run, err := c.Pv77FooAsync(cmd.Context, req, NewPv77FooOptions().WithStartWorkflowOptions(opts)) + if err != nil { + return fmt.Errorf("error starting %s workflow: %w", Pv77FooWorkflowName, err) + } + if cmd.Bool("detach") { + fmt.Println("success") + fmt.Printf("workflow id: %s\n", run.ID()) + fmt.Printf("run id: %s\n", run.RunID()) + return nil + } + if resp, err := run.Get(cmd.Context); err != nil { + return err + } else { + b, err := protojson.Marshal(resp) + if err != nil { + return fmt.Errorf("error serializing response json: %w", err) + } + var out bytes.Buffer + if err := json.Indent(&out, b, "", " "); err != nil { + return fmt.Errorf("error formatting json: %w", err) + } + fmt.Println(out.String()) + return nil + } + }, + }, + } + if opts.worker != nil { + commands = append(commands, []*v2.Command{ + { + Name: "worker", + Usage: "runs a test.patch.v1.Pv77FooService worker process", + UseShortOptionHandling: true, + Before: opts.before, + After: opts.after, + Action: func(cmd *v2.Context) error { + c, err := opts.clientForCommand(cmd) + if err != nil { + return fmt.Errorf("error initializing client for command: %w", err) + } + defer c.Close() + w, err := opts.worker(cmd, c) + if opts.worker != nil { + if err != nil { + return fmt.Errorf("error initializing worker: %w", err) + } + } + if err := w.Start(); err != nil { + return fmt.Errorf("error starting worker: %w", err) + } + defer w.Stop() + <-cmd.Context.Done() + return nil + }, + }, + }...) + } + sort.Slice(commands, func(i, j int) bool { + return commands[i].Name < commands[j].Name + }) + return commands, nil +} + +// UnmarshalCliFlagsToPv77FooInput unmarshals a Pv77FooInput from command line flags +func UnmarshalCliFlagsToPv77FooInput(cmd *v2.Context) (*Pv77FooInput, error) { + var result Pv77FooInput + var hasValues bool + if cmd.IsSet("input-file") { + inputFile, err := gohomedir.Expand(cmd.String("input-file")) + if err != nil { + inputFile = cmd.String("input-file") + } + b, err := os.ReadFile(inputFile) + if err != nil { + return nil, fmt.Errorf("error reading input-file: %w", err) + } + if err := protojson.Unmarshal(b, &result); err != nil { + return nil, fmt.Errorf("error parsing input-file json: %w", err) + } + hasValues = true + } + if cmd.IsSet("next") { + hasValues = true + var tmp Pv77FooInput + if err := protojson.Unmarshal([]byte(fmt.Sprintf("{\"next\":%s}", cmd.String("next"))), &tmp); err != nil { + return nil, fmt.Errorf("error unmarshalling \"next\" map flag: %w", err) + } + result.Next = tmp.Next + } + if !hasValues { + return nil, nil + } + return &result, nil +} + +// WithPv77FooServiceSchemeTypes registers all Pv77FooService protobuf types with the given scheme +func WithPv77FooServiceSchemeTypes() scheme.Option { + return func(s *scheme.Scheme) { + s.RegisterType(File_test_patch_v1_pv77_proto.Messages().ByName("Pv77FooInput")) + s.RegisterType(File_test_patch_v1_pv77_proto.Messages().ByName("Pv77FooOutput")) + s.RegisterType(File_test_patch_v1_pv77_proto.Messages().ByName("Pv77FooOutput").Messages().ByName("DefaultsEntry")) + } +} + +// Pv77BarServiceTaskQueue is the default task-queue for a test.patch.v1.Pv77BarService worker +const Pv77BarServiceTaskQueue = "pv77-v1" + +// test.patch.v1.Pv77BarService workflow names +const ( + Pv77BarWorkflowName = "test.patch.v1.Pv77BarService.Pv77Bar" +) + +// test.patch.v1.Pv77BarService activity names +const ( + Pv77BarActivityName = "test.patch.v1.Pv77BarActivity" +) + +// Pv77BarServiceClient describes a client for a(n) test.patch.v1.Pv77BarService worker +type Pv77BarServiceClient interface { + // Pv77Bar executes a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow and blocks until error or response received + Pv77Bar(ctx context.Context, req *Pv77BarInput, opts ...*Pv77BarOptions) (*Pv77BarOutput, error) + + // Pv77BarAsync starts a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow and returns a handle to the workflow run + Pv77BarAsync(ctx context.Context, req *Pv77BarInput, opts ...*Pv77BarOptions) (Pv77BarRun, error) + + // GetPv77Bar retrieves a handle to an existing test.patch.v1.Pv77BarService.Pv77Bar workflow execution + GetPv77Bar(ctx context.Context, workflowID string, runID string) Pv77BarRun + + // CancelWorkflow requests cancellation of an existing workflow execution + CancelWorkflow(ctx context.Context, workflowID string, runID string) error + + // TerminateWorkflow an existing workflow execution + TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error +} + +// pv77BarServiceClient implements a temporal client for a test.patch.v1.Pv77BarService service +type pv77BarServiceClient struct { + client client.Client + log *slog.Logger +} + +// NewPv77BarServiceClient initializes a new test.patch.v1.Pv77BarService client +func NewPv77BarServiceClient(c client.Client, options ...*pv77BarServiceClientOptions) Pv77BarServiceClient { + var cfg *pv77BarServiceClientOptions + if len(options) > 0 { + cfg = options[0] + } else { + cfg = NewPv77BarServiceClientOptions() + } + return &pv77BarServiceClient{ + client: c, + log: cfg.getLogger(), + } +} + +// NewPv77BarServiceClientWithOptions initializes a new Pv77BarService client with the given options +func NewPv77BarServiceClientWithOptions(c client.Client, opts client.Options, options ...*pv77BarServiceClientOptions) (Pv77BarServiceClient, error) { + var err error + c, err = client.NewClientFromExisting(c, opts) + if err != nil { + return nil, fmt.Errorf("error initializing client with options: %w", err) + } + var cfg *pv77BarServiceClientOptions + if len(options) > 0 { + cfg = options[0] + } else { + cfg = NewPv77BarServiceClientOptions() + } + return &pv77BarServiceClient{ + client: c, + log: cfg.getLogger(), + }, nil +} + +// pv77BarServiceClientOptions describes optional runtime configuration for a Pv77BarServiceClient +type pv77BarServiceClientOptions struct { + log *slog.Logger +} + +// NewPv77BarServiceClientOptions initializes a new pv77BarServiceClientOptions value +func NewPv77BarServiceClientOptions() *pv77BarServiceClientOptions { + return &pv77BarServiceClientOptions{} +} + +// WithLogger can be used to override the default logger +func (opts *pv77BarServiceClientOptions) WithLogger(l *slog.Logger) *pv77BarServiceClientOptions { + if l != nil { + opts.log = l + } + return opts +} + +// getLogger returns the configured logger, or the default logger +func (opts *pv77BarServiceClientOptions) getLogger() *slog.Logger { + if opts != nil && opts.log != nil { + return opts.log + } + return slog.Default() +} + +// test.patch.v1.Pv77BarService.Pv77Bar executes a test.patch.v1.Pv77BarService.Pv77Bar workflow and blocks until error or response received +func (c *pv77BarServiceClient) Pv77Bar(ctx context.Context, req *Pv77BarInput, options ...*Pv77BarOptions) (*Pv77BarOutput, error) { + run, err := c.Pv77BarAsync(ctx, req, options...) + if err != nil { + return nil, err + } + return run.Get(ctx) +} + +// Pv77BarAsync starts a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow and returns a handle to the workflow run +func (c *pv77BarServiceClient) Pv77BarAsync(ctx context.Context, req *Pv77BarInput, options ...*Pv77BarOptions) (Pv77BarRun, error) { + var o *Pv77BarOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77BarOptions() + } + opts, err := o.Build(req.ProtoReflect()) + if err != nil { + return nil, fmt.Errorf("error initializing client.StartWorkflowOptions: %w", err) + } + run, err := c.client.ExecuteWorkflow(ctx, opts, Pv77BarWorkflowName, req) + if err != nil { + return nil, err + } + if run == nil { + return nil, errors.New("execute workflow returned nil run") + } + return &pv77BarRun{ + client: c, + run: run, + }, nil +} + +// GetPv77Bar fetches an existing test.patch.v1.Pv77BarService.Pv77Bar execution +func (c *pv77BarServiceClient) GetPv77Bar(ctx context.Context, workflowID string, runID string) Pv77BarRun { + return &pv77BarRun{ + client: c, + run: c.client.GetWorkflow(ctx, workflowID, runID), + } +} + +// CancelWorkflow requests cancellation of an existing workflow execution +func (c *pv77BarServiceClient) CancelWorkflow(ctx context.Context, workflowID string, runID string) error { + return c.client.CancelWorkflow(ctx, workflowID, runID) +} + +// TerminateWorkflow terminates an existing workflow execution +func (c *pv77BarServiceClient) TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error { + return c.client.TerminateWorkflow(ctx, workflowID, runID, reason, details...) +} + +// Pv77BarOptions provides configuration for a test.patch.v1.Pv77BarService.Pv77Bar workflow operation +type Pv77BarOptions struct { + options client.StartWorkflowOptions + executionTimeout *time.Duration + id *string + idReusePolicy enumsv1.WorkflowIdReusePolicy + retryPolicy *temporal.RetryPolicy + runTimeout *time.Duration + searchAttributes map[string]any + taskQueue *string + taskTimeout *time.Duration +} + +// NewPv77BarOptions initializes a new Pv77BarOptions value +func NewPv77BarOptions() *Pv77BarOptions { + return &Pv77BarOptions{} +} + +// Build initializes a new go.temporal.io/sdk/client.StartWorkflowOptions value with defaults and overrides applied +func (o *Pv77BarOptions) Build(req protoreflect.Message) (client.StartWorkflowOptions, error) { + opts := o.options + if v := o.id; v != nil { + opts.ID = *v + } + if v := o.idReusePolicy; v != enumsv1.WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED { + opts.WorkflowIDReusePolicy = v + } + if v := o.taskQueue; v != nil { + opts.TaskQueue = *v + } else if opts.TaskQueue == "" { + opts.TaskQueue = Pv77BarServiceTaskQueue + } + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.searchAttributes; v != nil { + opts.SearchAttributes = o.searchAttributes + } + if v := o.executionTimeout; v != nil { + opts.WorkflowExecutionTimeout = *v + } + if v := o.runTimeout; v != nil { + opts.WorkflowRunTimeout = *v + } + if v := o.taskTimeout; v != nil { + opts.WorkflowTaskTimeout = *v + } + return opts, nil +} + +// WithStartWorkflowOptions sets the initial go.temporal.io/sdk/client.StartWorkflowOptions +func (o *Pv77BarOptions) WithStartWorkflowOptions(options client.StartWorkflowOptions) *Pv77BarOptions { + o.options = options + return o +} + +// WithExecutionTimeout sets the WorkflowExecutionTimeout value +func (o *Pv77BarOptions) WithExecutionTimeout(d time.Duration) *Pv77BarOptions { + o.executionTimeout = &d + return o +} + +// WithID sets the ID value +func (o *Pv77BarOptions) WithID(id string) *Pv77BarOptions { + o.id = &id + return o +} + +// WithIDReusePolicy sets the WorkflowIDReusePolicy value +func (o *Pv77BarOptions) WithIDReusePolicy(policy enumsv1.WorkflowIdReusePolicy) *Pv77BarOptions { + o.idReusePolicy = policy + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77BarOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77BarOptions { + o.retryPolicy = policy + return o +} + +// WithRunTimeout sets the WorkflowRunTimeout value +func (o *Pv77BarOptions) WithRunTimeout(d time.Duration) *Pv77BarOptions { + o.runTimeout = &d + return o +} + +// WithSearchAttributes sets the SearchAttributes value +func (o *Pv77BarOptions) WithSearchAttributes(sa map[string]any) *Pv77BarOptions { + o.searchAttributes = sa + return o +} + +// WithTaskTimeout sets the WorkflowTaskTimeout value +func (o *Pv77BarOptions) WithTaskTimeout(d time.Duration) *Pv77BarOptions { + o.taskTimeout = &d + return o +} + +// WithTaskQueue sets the TaskQueue value +func (o *Pv77BarOptions) WithTaskQueue(tq string) *Pv77BarOptions { + o.taskQueue = &tq + return o +} + +// Pv77BarRun describes a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow run +type Pv77BarRun interface { + // ID returns the workflow ID + ID() string + + // RunID returns the workflow instance ID + RunID() string + + // Run returns the inner client.WorkflowRun + Run() client.WorkflowRun + + // Get blocks until the workflow is complete and returns the result + Get(ctx context.Context) (*Pv77BarOutput, error) + + // Cancel requests cancellation of a workflow in execution, returning an error if applicable + Cancel(ctx context.Context) error + + // Terminate terminates a workflow in execution, returning an error if applicable + Terminate(ctx context.Context, reason string, details ...interface{}) error +} + +// pv77BarRun provides an internal implementation of a(n) Pv77BarRunRun +type pv77BarRun struct { + client *pv77BarServiceClient + run client.WorkflowRun +} + +// ID returns the workflow ID +func (r *pv77BarRun) ID() string { + return r.run.GetID() +} + +// Run returns the inner client.WorkflowRun +func (r *pv77BarRun) Run() client.WorkflowRun { + return r.run +} + +// RunID returns the execution ID +func (r *pv77BarRun) RunID() string { + return r.run.GetRunID() +} + +// Cancel requests cancellation of a workflow in execution, returning an error if applicable +func (r *pv77BarRun) Cancel(ctx context.Context) error { + return r.client.CancelWorkflow(ctx, r.ID(), r.RunID()) +} + +// Get blocks until the workflow is complete, returning the result if applicable +func (r *pv77BarRun) Get(ctx context.Context) (*Pv77BarOutput, error) { + var resp Pv77BarOutput + if err := r.run.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// Terminate terminates a workflow in execution, returning an error if applicable +func (r *pv77BarRun) Terminate(ctx context.Context, reason string, details ...interface{}) error { + return r.client.TerminateWorkflow(ctx, r.ID(), r.RunID(), reason, details...) +} + +// Reference to generated workflow functions +var ( + // Pv77BarFunction implements a "test.patch.v1.Pv77BarService.Pv77Bar" workflow + Pv77BarFunction func(workflow.Context, *Pv77BarInput) (*Pv77BarOutput, error) +) + +// Pv77BarServiceWorkflowFunctions describes a mockable dependency for inlining workflows within other workflows +type ( + // Pv77BarServiceWorkflowFunctions describes a mockable dependency for inlining workflows within other workflows + Pv77BarServiceWorkflowFunctions interface { + // Pv77Bar executes a "test.patch.v1.Pv77BarService.Pv77Bar" workflow inline + Pv77Bar(workflow.Context, *Pv77BarInput) (*Pv77BarOutput, error) + } + // pv77BarServiceWorkflowFunctions provides an internal Pv77BarServiceWorkflowFunctions implementation + pv77BarServiceWorkflowFunctions struct{} +) + +func NewPv77BarServiceWorkflowFunctions() Pv77BarServiceWorkflowFunctions { + return &pv77BarServiceWorkflowFunctions{} +} + +// Pv77Bar executes a "test.patch.v1.Pv77BarService.Pv77Bar" workflow inline +func (f *pv77BarServiceWorkflowFunctions) Pv77Bar(ctx workflow.Context, req *Pv77BarInput) (*Pv77BarOutput, error) { + if Pv77BarFunction == nil { + return nil, errors.New("Pv77Bar requires workflow registration via RegisterPv77BarServiceWorkflows or RegisterPv77BarWorkflow") + } + return Pv77BarFunction(ctx, req) +} + +// Pv77BarServiceWorkflows provides methods for initializing new test.patch.v1.Pv77BarService workflow values +type Pv77BarServiceWorkflows interface { + // Pv77Bar initializes a new a(n) Pv77BarWorkflow implementation + Pv77Bar(ctx workflow.Context, input *Pv77BarWorkflowInput) (Pv77BarWorkflow, error) +} + +// RegisterPv77BarServiceWorkflows registers test.patch.v1.Pv77BarService workflows with the given worker +func RegisterPv77BarServiceWorkflows(r worker.WorkflowRegistry, workflows Pv77BarServiceWorkflows) { + RegisterPv77BarWorkflow(r, workflows.Pv77Bar) +} + +// RegisterPv77BarWorkflow registers a test.patch.v1.Pv77BarService.Pv77Bar workflow with the given worker +func RegisterPv77BarWorkflow(r worker.WorkflowRegistry, wf func(workflow.Context, *Pv77BarWorkflowInput) (Pv77BarWorkflow, error)) { + Pv77BarFunction = buildPv77Bar(wf) + r.RegisterWorkflowWithOptions(Pv77BarFunction, workflow.RegisterOptions{Name: Pv77BarWorkflowName}) +} + +// buildPv77Bar converts a Pv77Bar workflow struct into a valid workflow function +func buildPv77Bar(ctor func(workflow.Context, *Pv77BarWorkflowInput) (Pv77BarWorkflow, error)) func(workflow.Context, *Pv77BarInput) (*Pv77BarOutput, error) { + return func(ctx workflow.Context, req *Pv77BarInput) (*Pv77BarOutput, error) { + input := &Pv77BarWorkflowInput{ + Req: req, + } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, Pv77BarServiceTaskQueue, workflow.GetInfo(ctx).TaskQueueName) + wf, err := ctor(ctx, input) + if err != nil { + return nil, err + } + if initializable, ok := wf.(helpers.Initializable); ok { + if err := initializable.Initialize(ctx); err != nil { + return nil, err + } + } + return wf.Execute(ctx) + } +} + +// Pv77BarWorkflowInput describes the input to a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow constructor +type Pv77BarWorkflowInput struct { + Req *Pv77BarInput +} + +// Pv77BarWorkflow describes a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow implementation +type Pv77BarWorkflow interface { + // Execute defines the entrypoint to a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow + Execute(ctx workflow.Context) (*Pv77BarOutput, error) +} + +// Pv77BarChild executes a child test.patch.v1.Pv77BarService.Pv77Bar workflow and blocks until error or response received +func Pv77BarChild(ctx workflow.Context, req *Pv77BarInput, options ...*Pv77BarChildOptions) (*Pv77BarOutput, error) { + childRun, err := Pv77BarChildAsync(ctx, req, options...) + if err != nil { + return nil, err + } + return childRun.Get(ctx) +} + +// Pv77BarChildAsync starts a child test.patch.v1.Pv77BarService.Pv77Bar workflow and returns a handle to the child workflow run +func Pv77BarChildAsync(ctx workflow.Context, req *Pv77BarInput, options ...*Pv77BarChildOptions) (*Pv77BarChildRun, error) { + var o *Pv77BarChildOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77BarChildOptions() + } + opts, err := o.Build(ctx, req.ProtoReflect()) + if err != nil { + return nil, fmt.Errorf("error initializing workflow.ChildWorkflowOptions: %w", err) + } + ctx = workflow.WithChildOptions(ctx, opts) + return &Pv77BarChildRun{Future: workflow.ExecuteChildWorkflow(ctx, Pv77BarWorkflowName, req)}, nil +} + +// Pv77BarChildOptions provides configuration for a child test.patch.v1.Pv77BarService.Pv77Bar workflow operation +type Pv77BarChildOptions struct { + options workflow.ChildWorkflowOptions + executionTimeout *time.Duration + id *string + idReusePolicy enumsv1.WorkflowIdReusePolicy + retryPolicy *temporal.RetryPolicy + runTimeout *time.Duration + searchAttributes map[string]any + taskQueue *string + taskTimeout *time.Duration + parentClosePolicy enumsv1.ParentClosePolicy + waitForCancellation *bool +} + +// NewPv77BarChildOptions initializes a new Pv77BarChildOptions value +func NewPv77BarChildOptions() *Pv77BarChildOptions { + return &Pv77BarChildOptions{} +} + +// Build initializes a new go.temporal.io/sdk/workflow.ChildWorkflowOptions value with defaults and overrides applied +func (o *Pv77BarChildOptions) Build(ctx workflow.Context, req protoreflect.Message) (workflow.ChildWorkflowOptions, error) { + opts := o.options + if v := o.id; v != nil { + opts.WorkflowID = *v + } + if v := o.idReusePolicy; v != enumsv1.WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED { + opts.WorkflowIDReusePolicy = v + } + if v := o.taskQueue; v != nil { + opts.TaskQueue = *v + } else if opts.TaskQueue == "" { + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if tq := patch.DefaultTaskQueue(ctx, Pv77BarServiceTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.searchAttributes; v != nil { + opts.SearchAttributes = o.searchAttributes + } + if v := o.executionTimeout; v != nil { + opts.WorkflowExecutionTimeout = *v + } + if v := o.runTimeout; v != nil { + opts.WorkflowRunTimeout = *v + } + if v := o.taskTimeout; v != nil { + opts.WorkflowTaskTimeout = *v + } + if v := o.parentClosePolicy; v != enumsv1.PARENT_CLOSE_POLICY_UNSPECIFIED { + opts.ParentClosePolicy = v + } + if v := o.waitForCancellation; v != nil { + opts.WaitForCancellation = *v + } + return opts, nil +} + +// WithChildWorkflowOptions sets the initial go.temporal.io/sdk/workflow.ChildWorkflowOptions +func (o *Pv77BarChildOptions) WithChildWorkflowOptions(options workflow.ChildWorkflowOptions) *Pv77BarChildOptions { + o.options = options + return o +} + +// WithExecutionTimeout sets the WorkflowExecutionTimeout value +func (o *Pv77BarChildOptions) WithExecutionTimeout(d time.Duration) *Pv77BarChildOptions { + o.executionTimeout = &d + return o +} + +// WithID sets the WorkflowID value +func (o *Pv77BarChildOptions) WithID(id string) *Pv77BarChildOptions { + o.id = &id + return o +} + +// WithIDReusePolicy sets the WorkflowIDReusePolicy value +func (o *Pv77BarChildOptions) WithIDReusePolicy(policy enumsv1.WorkflowIdReusePolicy) *Pv77BarChildOptions { + o.idReusePolicy = policy + return o +} + +// WithParentClosePolicy sets the WorkflowIDReusePolicy value +func (o *Pv77BarChildOptions) WithParentClosePolicy(policy enumsv1.ParentClosePolicy) *Pv77BarChildOptions { + o.parentClosePolicy = policy + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77BarChildOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77BarChildOptions { + o.retryPolicy = policy + return o +} + +// WithRunTimeout sets the WorkflowRunTimeout value +func (o *Pv77BarChildOptions) WithRunTimeout(d time.Duration) *Pv77BarChildOptions { + o.runTimeout = &d + return o +} + +// WithSearchAttributes sets the SearchAttributes value +func (o *Pv77BarChildOptions) WithSearchAttributes(sa map[string]any) *Pv77BarChildOptions { + o.searchAttributes = sa + return o +} + +// WithTaskTimeout sets the WorkflowTaskTimeout value +func (o *Pv77BarChildOptions) WithTaskTimeout(d time.Duration) *Pv77BarChildOptions { + o.taskTimeout = &d + return o +} + +// WithTaskQueue sets the TaskQueue value +func (o *Pv77BarChildOptions) WithTaskQueue(tq string) *Pv77BarChildOptions { + o.taskQueue = &tq + return o +} + +// WithWaitForCancellation sets the WaitForCancellation value +func (o *Pv77BarChildOptions) WithWaitForCancellation(wait bool) *Pv77BarChildOptions { + o.waitForCancellation = &wait + return o +} + +// Pv77BarChildRun describes a child Pv77Bar workflow run +type Pv77BarChildRun struct { + Future workflow.ChildWorkflowFuture +} + +// Get blocks until the workflow is completed, returning the response value +func (r *Pv77BarChildRun) Get(ctx workflow.Context) (*Pv77BarOutput, error) { + var resp Pv77BarOutput + if err := r.Future.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// Select adds this completion to the selector. Callback can be nil. +func (r *Pv77BarChildRun) Select(sel workflow.Selector, fn func(*Pv77BarChildRun)) workflow.Selector { + return sel.AddFuture(r.Future, func(workflow.Future) { + if fn != nil { + fn(r) + } + }) +} + +// SelectStart adds waiting for start to the selector. Callback can be nil. +func (r *Pv77BarChildRun) SelectStart(sel workflow.Selector, fn func(*Pv77BarChildRun)) workflow.Selector { + return sel.AddFuture(r.Future.GetChildWorkflowExecution(), func(workflow.Future) { + if fn != nil { + fn(r) + } + }) +} + +// WaitStart waits for the child workflow to start +func (r *Pv77BarChildRun) WaitStart(ctx workflow.Context) (*workflow.Execution, error) { + var exec workflow.Execution + if err := r.Future.GetChildWorkflowExecution().Get(ctx, &exec); err != nil { + return nil, err + } + return &exec, nil +} + +// Pv77BarServiceActivities describes available worker activities +type Pv77BarServiceActivities interface { + // test.patch.v1.Pv77BarService.Pv77Bar implements a(n) test.patch.v1.Pv77BarActivity activity definition + Pv77Bar(ctx context.Context, req *Pv77BarInput) (*Pv77BarOutput, error) +} + +// RegisterPv77BarServiceActivities registers activities with a worker +func RegisterPv77BarServiceActivities(r worker.ActivityRegistry, activities Pv77BarServiceActivities) { + RegisterPv77BarActivity(r, activities.Pv77Bar) +} + +// RegisterPv77BarActivity registers a test.patch.v1.Pv77BarActivity activity +func RegisterPv77BarActivity(r worker.ActivityRegistry, fn func(context.Context, *Pv77BarInput) (*Pv77BarOutput, error)) { + r.RegisterActivityWithOptions(fn, activity.RegisterOptions{ + Name: Pv77BarActivityName, + }) +} + +// Pv77BarFuture describes a(n) test.patch.v1.Pv77BarActivity activity execution +type Pv77BarFuture struct { + Future workflow.Future +} + +// Get blocks on the activity's completion, returning the response +func (f *Pv77BarFuture) Get(ctx workflow.Context) (*Pv77BarOutput, error) { + var resp Pv77BarOutput + if err := f.Future.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// Select adds the activity's completion to the selector, callback can be nil +func (f *Pv77BarFuture) Select(sel workflow.Selector, fn func(*Pv77BarFuture)) workflow.Selector { + return sel.AddFuture(f.Future, func(workflow.Future) { + if fn != nil { + fn(f) + } + }) +} + +// Pv77Bar executes a(n) test.patch.v1.Pv77BarActivity activity +func Pv77Bar(ctx workflow.Context, req *Pv77BarInput, options ...*Pv77BarActivityOptions) (*Pv77BarOutput, error) { + return Pv77BarAsync(ctx, req, options...).Get(ctx) +} + +// Pv77BarAsync executes a(n) test.patch.v1.Pv77BarActivity activity (asynchronously) +func Pv77BarAsync(ctx workflow.Context, req *Pv77BarInput, options ...*Pv77BarActivityOptions) *Pv77BarFuture { + var o *Pv77BarActivityOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77BarActivityOptions() + } + var err error + if ctx, err = o.Build(ctx); err != nil { + errF, errS := workflow.NewFuture(ctx) + errS.SetError(err) + return &Pv77BarFuture{Future: errF} + } + activity := Pv77BarActivityName + future := &Pv77BarFuture{Future: workflow.ExecuteActivity(ctx, activity, req)} + return future +} + +// Pv77BarLocal executes a(n) test.patch.v1.Pv77BarActivity activity (locally) +func Pv77BarLocal(ctx workflow.Context, req *Pv77BarInput, options ...*Pv77BarLocalActivityOptions) (*Pv77BarOutput, error) { + return Pv77BarLocalAsync(ctx, req, options...).Get(ctx) +} + +// Pv77BarLocalAsync executes a(n) test.patch.v1.Pv77BarActivity activity (asynchronously, locally) +func Pv77BarLocalAsync(ctx workflow.Context, req *Pv77BarInput, options ...*Pv77BarLocalActivityOptions) *Pv77BarFuture { + var o *Pv77BarLocalActivityOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77BarLocalActivityOptions() + } + var err error + if ctx, err = o.Build(ctx); err != nil { + errF, errS := workflow.NewFuture(ctx) + errS.SetError(err) + return &Pv77BarFuture{Future: errF} + } + var activity any + if o.fn != nil { + activity = o.fn + } else { + activity = Pv77BarActivityName + } + future := &Pv77BarFuture{Future: workflow.ExecuteLocalActivity(ctx, activity, req)} + return future +} + +// Pv77BarActivityOptions provides configuration for a(n) test.patch.v1.Pv77BarActivity activity +type Pv77BarActivityOptions struct { + options workflow.ActivityOptions + retryPolicy *temporal.RetryPolicy + scheduleToCloseTimeout *time.Duration + startToCloseTimeout *time.Duration + heartbeatTimeout *time.Duration + scheduleToStartTimeout *time.Duration + taskQueue *string + waitForCancellation *bool +} + +// NewPv77BarActivityOptions initializes a new Pv77BarActivityOptions value +func NewPv77BarActivityOptions() *Pv77BarActivityOptions { + return &Pv77BarActivityOptions{} +} + +// Build initializes a workflow.Context with appropriate ActivityOptions values derived from schema defaults and any user-defined overrides +func (o *Pv77BarActivityOptions) Build(ctx workflow.Context) (workflow.Context, error) { + opts := o.options + if v := o.heartbeatTimeout; v != nil { + opts.HeartbeatTimeout = *v + } + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.scheduleToCloseTimeout; v != nil { + opts.ScheduleToCloseTimeout = *v + } + if v := o.scheduleToStartTimeout; v != nil { + opts.ScheduleToStartTimeout = *v + } + if v := o.startToCloseTimeout; v != nil { + opts.StartToCloseTimeout = *v + } else if opts.StartToCloseTimeout == 0 { + opts.StartToCloseTimeout = 5000000000 // 5 seconds + } + if v := o.taskQueue; v != nil { + opts.TaskQueue = *v + } else if opts.TaskQueue == "" { + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if tq := patch.DefaultTaskQueue(ctx, Pv77BarServiceTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } + if v := o.waitForCancellation; v != nil { + opts.WaitForCancellation = *v + } + return workflow.WithActivityOptions(ctx, opts), nil +} + +// WithActivityOptions specifies an initial ActivityOptions value to which defaults will be applied +func (o *Pv77BarActivityOptions) WithActivityOptions(options workflow.ActivityOptions) *Pv77BarActivityOptions { + o.options = options + return o +} + +// WithHeartbeatTimeout sets the HeartbeatTimeout value +func (o *Pv77BarActivityOptions) WithHeartbeatTimeout(d time.Duration) *Pv77BarActivityOptions { + o.heartbeatTimeout = &d + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77BarActivityOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77BarActivityOptions { + o.retryPolicy = policy + return o +} + +// WithScheduleToCloseTimeout sets the ScheduleToCloseTimeout value +func (o *Pv77BarActivityOptions) WithScheduleToCloseTimeout(d time.Duration) *Pv77BarActivityOptions { + o.scheduleToCloseTimeout = &d + return o +} + +// WithScheduleToStartTimeout sets the ScheduleToStartTimeout value +func (o *Pv77BarActivityOptions) WithScheduleToStartTimeout(d time.Duration) *Pv77BarActivityOptions { + o.scheduleToStartTimeout = &d + return o +} + +// WithStartToCloseTimeout sets the StartToCloseTimeout value +func (o *Pv77BarActivityOptions) WithStartToCloseTimeout(d time.Duration) *Pv77BarActivityOptions { + o.startToCloseTimeout = &d + return o +} + +// WithTaskQueue sets the TaskQueue value +func (o *Pv77BarActivityOptions) WithTaskQueue(tq string) *Pv77BarActivityOptions { + o.taskQueue = &tq + return o +} + +// WithWaitForCancellation sets the WaitForCancellation value +func (o *Pv77BarActivityOptions) WithWaitForCancellation(wait bool) *Pv77BarActivityOptions { + o.waitForCancellation = &wait + return o +} + +// Pv77BarLocalActivityOptions provides configuration for a(n) test.patch.v1.Pv77BarActivity activity +type Pv77BarLocalActivityOptions struct { + options workflow.LocalActivityOptions + retryPolicy *temporal.RetryPolicy + scheduleToCloseTimeout *time.Duration + startToCloseTimeout *time.Duration + fn func(context.Context, *Pv77BarInput) (*Pv77BarOutput, error) +} + +// NewPv77BarLocalActivityOptions initializes a new Pv77BarLocalActivityOptions value +func NewPv77BarLocalActivityOptions() *Pv77BarLocalActivityOptions { + return &Pv77BarLocalActivityOptions{} +} + +// Build initializes a workflow.Context with appropriate LocalActivityOptions values derived from schema defaults and any user-defined overrides +func (o *Pv77BarLocalActivityOptions) Build(ctx workflow.Context) (workflow.Context, error) { + opts := o.options + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.scheduleToCloseTimeout; v != nil { + opts.ScheduleToCloseTimeout = *v + } + if v := o.startToCloseTimeout; v != nil { + opts.StartToCloseTimeout = *v + } else if opts.StartToCloseTimeout == 0 { + opts.StartToCloseTimeout = 5000000000 // 5 seconds + } + return workflow.WithLocalActivityOptions(ctx, opts), nil +} + +// Local specifies a custom test.patch.v1.Pv77BarActivity implementation +func (o *Pv77BarLocalActivityOptions) Local(fn func(context.Context, *Pv77BarInput) (*Pv77BarOutput, error)) *Pv77BarLocalActivityOptions { + o.fn = fn + return o +} + +// WithLocalActivityOptions specifies an initial LocalActivityOptions value to which defaults will be applied +func (o *Pv77BarLocalActivityOptions) WithLocalActivityOptions(options workflow.LocalActivityOptions) *Pv77BarLocalActivityOptions { + o.options = options + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77BarLocalActivityOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77BarLocalActivityOptions { + o.retryPolicy = policy + return o +} + +// WithScheduleToCloseTimeout sets the ScheduleToCloseTimeout value +func (o *Pv77BarLocalActivityOptions) WithScheduleToCloseTimeout(d time.Duration) *Pv77BarLocalActivityOptions { + o.scheduleToCloseTimeout = &d + return o +} + +// WithStartToCloseTimeout sets the StartToCloseTimeout value +func (o *Pv77BarLocalActivityOptions) WithStartToCloseTimeout(d time.Duration) *Pv77BarLocalActivityOptions { + o.startToCloseTimeout = &d + return o +} + +// TestClient provides a testsuite-compatible Client +type TestPv77BarServiceClient struct { + env *testsuite.TestWorkflowEnvironment + workflows Pv77BarServiceWorkflows +} + +var _ Pv77BarServiceClient = &TestPv77BarServiceClient{} + +// NewTestPv77BarServiceClient initializes a new TestPv77BarServiceClient value +func NewTestPv77BarServiceClient(env *testsuite.TestWorkflowEnvironment, workflows Pv77BarServiceWorkflows, activities Pv77BarServiceActivities) *TestPv77BarServiceClient { + if workflows != nil { + RegisterPv77BarServiceWorkflows(env, workflows) + } + if activities != nil { + RegisterPv77BarServiceActivities(env, activities) + } + return &TestPv77BarServiceClient{env, workflows} +} + +// Pv77Bar executes a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow in the test environment +func (c *TestPv77BarServiceClient) Pv77Bar(ctx context.Context, req *Pv77BarInput, opts ...*Pv77BarOptions) (*Pv77BarOutput, error) { + run, err := c.Pv77BarAsync(ctx, req, opts...) + if err != nil { + return nil, err + } + return run.Get(ctx) +} + +// Pv77BarAsync executes a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow in the test environment +func (c *TestPv77BarServiceClient) Pv77BarAsync(ctx context.Context, req *Pv77BarInput, options ...*Pv77BarOptions) (Pv77BarRun, error) { + var o *Pv77BarOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77BarOptions() + } + opts, err := o.Build(req.ProtoReflect()) + if err != nil { + return nil, fmt.Errorf("error initializing client.StartWorkflowOptions: %w", err) + } + return &testPv77BarRun{client: c, env: c.env, opts: &opts, req: req, workflows: c.workflows}, nil +} + +// GetPv77Bar is a noop +func (c *TestPv77BarServiceClient) GetPv77Bar(ctx context.Context, workflowID string, runID string) Pv77BarRun { + return &testPv77BarRun{env: c.env, workflows: c.workflows} +} + +// CancelWorkflow requests cancellation of an existing workflow execution +func (c *TestPv77BarServiceClient) CancelWorkflow(ctx context.Context, workflowID string, runID string) error { + c.env.CancelWorkflow() + return nil +} + +// TerminateWorkflow terminates an existing workflow execution +func (c *TestPv77BarServiceClient) TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error { + return c.CancelWorkflow(ctx, workflowID, runID) +} + +var _ Pv77BarRun = &testPv77BarRun{} + +// testPv77BarRun provides convenience methods for interacting with a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow in the test environment +type testPv77BarRun struct { + client *TestPv77BarServiceClient + env *testsuite.TestWorkflowEnvironment + opts *client.StartWorkflowOptions + req *Pv77BarInput + workflows Pv77BarServiceWorkflows +} + +// Cancel requests cancellation of a workflow in execution, returning an error if applicable +func (r *testPv77BarRun) Cancel(ctx context.Context) error { + return r.client.CancelWorkflow(ctx, r.ID(), r.RunID()) +} + +// Get retrieves a test test.patch.v1.Pv77BarService.Pv77Bar workflow result +func (r *testPv77BarRun) Get(context.Context) (*Pv77BarOutput, error) { + r.env.ExecuteWorkflow(Pv77BarWorkflowName, r.req) + if !r.env.IsWorkflowCompleted() { + return nil, errors.New("workflow in progress") + } + if err := r.env.GetWorkflowError(); err != nil { + return nil, err + } + var result Pv77BarOutput + if err := r.env.GetWorkflowResult(&result); err != nil { + return nil, err + } + return &result, nil +} + +// ID returns a test test.patch.v1.Pv77BarService.Pv77Bar workflow run's workflow ID +func (r *testPv77BarRun) ID() string { + if r.opts != nil { + return r.opts.ID + } + return "" +} + +// Run noop implementation +func (r *testPv77BarRun) Run() client.WorkflowRun { + return nil +} + +// RunID noop implementation +func (r *testPv77BarRun) RunID() string { + return "" +} + +// Terminate terminates a workflow in execution, returning an error if applicable +func (r *testPv77BarRun) Terminate(ctx context.Context, reason string, details ...interface{}) error { + return r.client.TerminateWorkflow(ctx, r.ID(), r.RunID(), reason, details...) +} + +// Pv77BarServiceCliOptions describes runtime configuration for test.patch.v1.Pv77BarService cli +type Pv77BarServiceCliOptions struct { + after func(*v2.Context) error + before func(*v2.Context) error + clientForCommand func(*v2.Context) (client.Client, error) + worker func(*v2.Context, client.Client) (worker.Worker, error) +} + +// NewPv77BarServiceCliOptions initializes a new Pv77BarServiceCliOptions value +func NewPv77BarServiceCliOptions() *Pv77BarServiceCliOptions { + return &Pv77BarServiceCliOptions{} +} + +// WithAfter injects a custom After hook to be run after any command invocation +func (opts *Pv77BarServiceCliOptions) WithAfter(fn func(*v2.Context) error) *Pv77BarServiceCliOptions { + opts.after = fn + return opts +} + +// WithBefore injects a custom Before hook to be run prior to any command invocation +func (opts *Pv77BarServiceCliOptions) WithBefore(fn func(*v2.Context) error) *Pv77BarServiceCliOptions { + opts.before = fn + return opts +} + +// WithClient provides a Temporal client factory for use by commands +func (opts *Pv77BarServiceCliOptions) WithClient(fn func(*v2.Context) (client.Client, error)) *Pv77BarServiceCliOptions { + opts.clientForCommand = fn + return opts +} + +// WithWorker provides an method for initializing a worker +func (opts *Pv77BarServiceCliOptions) WithWorker(fn func(*v2.Context, client.Client) (worker.Worker, error)) *Pv77BarServiceCliOptions { + opts.worker = fn + return opts +} + +// NewPv77BarServiceCli initializes a cli for a(n) test.patch.v1.Pv77BarService service +func NewPv77BarServiceCli(options ...*Pv77BarServiceCliOptions) (*v2.App, error) { + commands, err := newPv77BarServiceCommands(options...) + if err != nil { + return nil, fmt.Errorf("error initializing subcommands: %w", err) + } + return &v2.App{ + Name: "pv-77-bar-service", + Commands: commands, + }, nil +} + +// NewPv77BarServiceCliCommand initializes a cli command for a test.patch.v1.Pv77BarService service with subcommands for each query, signal, update, and workflow +func NewPv77BarServiceCliCommand(options ...*Pv77BarServiceCliOptions) (*v2.Command, error) { + subcommands, err := newPv77BarServiceCommands(options...) + if err != nil { + return nil, fmt.Errorf("error initializing subcommands: %w", err) + } + return &v2.Command{ + Name: "pv-77-bar-service", + Subcommands: subcommands, + }, nil +} + +// newPv77BarServiceCommands initializes (sub)commands for a test.patch.v1.Pv77BarService cli or command +func newPv77BarServiceCommands(options ...*Pv77BarServiceCliOptions) ([]*v2.Command, error) { + opts := &Pv77BarServiceCliOptions{} + if len(options) > 0 { + opts = options[0] + } + if opts.clientForCommand == nil { + opts.clientForCommand = func(*v2.Context) (client.Client, error) { + return client.Dial(client.Options{}) + } + } + commands := []*v2.Command{ + { + Name: "pv-77-bar", + Usage: "executes a(n) test.patch.v1.Pv77BarService.Pv77Bar workflow", + Category: "WORKFLOWS", + UseShortOptionHandling: true, + Before: opts.before, + After: opts.after, + Flags: []v2.Flag{ + &v2.BoolFlag{ + Name: "detach", + Usage: "run workflow in the background and print workflow and execution id", + Aliases: []string{"d"}, + }, + &v2.StringFlag{ + Name: "task-queue", + Usage: "task queue name", + Aliases: []string{"t"}, + EnvVars: []string{"TEMPORAL_TASK_QUEUE_NAME", "TEMPORAL_TASK_QUEUE", "TASK_QUEUE_NAME", "TASK_QUEUE"}, + Value: "pv77-v1", + }, + &v2.StringFlag{ + Name: "input-file", + Usage: "path to json-formatted input file", + Aliases: []string{"f"}, + }, + &v2.StringSliceFlag{ + Name: "next", + Usage: "set the value of the operation's \"Next\" parameter", + Category: "INPUT", + }, + }, + Action: func(cmd *v2.Context) error { + tc, err := opts.clientForCommand(cmd) + if err != nil { + return fmt.Errorf("error initializing client for command: %w", err) + } + defer tc.Close() + c := NewPv77BarServiceClient(tc) + req, err := UnmarshalCliFlagsToPv77BarInput(cmd) + if err != nil { + return fmt.Errorf("error unmarshalling request: %w", err) + } + opts := client.StartWorkflowOptions{} + if tq := cmd.String("task-queue"); tq != "" { + opts.TaskQueue = tq + } + run, err := c.Pv77BarAsync(cmd.Context, req, NewPv77BarOptions().WithStartWorkflowOptions(opts)) + if err != nil { + return fmt.Errorf("error starting %s workflow: %w", Pv77BarWorkflowName, err) + } + if cmd.Bool("detach") { + fmt.Println("success") + fmt.Printf("workflow id: %s\n", run.ID()) + fmt.Printf("run id: %s\n", run.RunID()) + return nil + } + if resp, err := run.Get(cmd.Context); err != nil { + return err + } else { + b, err := protojson.Marshal(resp) + if err != nil { + return fmt.Errorf("error serializing response json: %w", err) + } + var out bytes.Buffer + if err := json.Indent(&out, b, "", " "); err != nil { + return fmt.Errorf("error formatting json: %w", err) + } + fmt.Println(out.String()) + return nil + } + }, + }, + } + if opts.worker != nil { + commands = append(commands, []*v2.Command{ + { + Name: "worker", + Usage: "runs a test.patch.v1.Pv77BarService worker process", + UseShortOptionHandling: true, + Before: opts.before, + After: opts.after, + Action: func(cmd *v2.Context) error { + c, err := opts.clientForCommand(cmd) + if err != nil { + return fmt.Errorf("error initializing client for command: %w", err) + } + defer c.Close() + w, err := opts.worker(cmd, c) + if opts.worker != nil { + if err != nil { + return fmt.Errorf("error initializing worker: %w", err) + } + } + if err := w.Start(); err != nil { + return fmt.Errorf("error starting worker: %w", err) + } + defer w.Stop() + <-cmd.Context.Done() + return nil + }, + }, + }...) + } + sort.Slice(commands, func(i, j int) bool { + return commands[i].Name < commands[j].Name + }) + return commands, nil +} + +// UnmarshalCliFlagsToPv77BarInput unmarshals a Pv77BarInput from command line flags +func UnmarshalCliFlagsToPv77BarInput(cmd *v2.Context) (*Pv77BarInput, error) { + var result Pv77BarInput + var hasValues bool + if cmd.IsSet("input-file") { + inputFile, err := gohomedir.Expand(cmd.String("input-file")) + if err != nil { + inputFile = cmd.String("input-file") + } + b, err := os.ReadFile(inputFile) + if err != nil { + return nil, fmt.Errorf("error reading input-file: %w", err) + } + if err := protojson.Unmarshal(b, &result); err != nil { + return nil, fmt.Errorf("error parsing input-file json: %w", err) + } + hasValues = true + } + if cmd.IsSet("next") { + hasValues = true + var tmp Pv77BarInput + if err := protojson.Unmarshal([]byte(fmt.Sprintf("{\"next\":%s}", cmd.String("next"))), &tmp); err != nil { + return nil, fmt.Errorf("error unmarshalling \"next\" map flag: %w", err) + } + result.Next = tmp.Next + } + if !hasValues { + return nil, nil + } + return &result, nil +} + +// WithPv77BarServiceSchemeTypes registers all Pv77BarService protobuf types with the given scheme +func WithPv77BarServiceSchemeTypes() scheme.Option { + return func(s *scheme.Scheme) { + s.RegisterType(File_test_patch_v1_pv77_proto.Messages().ByName("Pv77BarInput")) + s.RegisterType(File_test_patch_v1_pv77_proto.Messages().ByName("Pv77BarOutput")) + s.RegisterType(File_test_patch_v1_pv77_proto.Messages().ByName("Pv77BarOutput").Messages().ByName("DefaultsEntry")) + } +} + +// Pv77BazServiceTaskQueue is the default task-queue for a test.patch.v1.Pv77BazService worker +const Pv77BazServiceTaskQueue = "pv77-v3" + +// test.patch.v1.Pv77BazService workflow names +const ( + Pv77BazWorkflowName = "test.patch.v1.Pv77BazService.Pv77Baz" +) + +// test.patch.v1.Pv77BazService activity names +const ( + Pv77BazActivityName = "test.patch.v1.Pv77BazActivity" +) + +// Pv77BazServiceClient describes a client for a(n) test.patch.v1.Pv77BazService worker +type Pv77BazServiceClient interface { + // Pv77Baz executes a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow and blocks until error or response received + Pv77Baz(ctx context.Context, req *Pv77BazInput, opts ...*Pv77BazOptions) (*Pv77BazOutput, error) + + // Pv77BazAsync starts a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow and returns a handle to the workflow run + Pv77BazAsync(ctx context.Context, req *Pv77BazInput, opts ...*Pv77BazOptions) (Pv77BazRun, error) + + // GetPv77Baz retrieves a handle to an existing test.patch.v1.Pv77BazService.Pv77Baz workflow execution + GetPv77Baz(ctx context.Context, workflowID string, runID string) Pv77BazRun + + // CancelWorkflow requests cancellation of an existing workflow execution + CancelWorkflow(ctx context.Context, workflowID string, runID string) error + + // TerminateWorkflow an existing workflow execution + TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error +} + +// pv77BazServiceClient implements a temporal client for a test.patch.v1.Pv77BazService service +type pv77BazServiceClient struct { + client client.Client + log *slog.Logger +} + +// NewPv77BazServiceClient initializes a new test.patch.v1.Pv77BazService client +func NewPv77BazServiceClient(c client.Client, options ...*pv77BazServiceClientOptions) Pv77BazServiceClient { + var cfg *pv77BazServiceClientOptions + if len(options) > 0 { + cfg = options[0] + } else { + cfg = NewPv77BazServiceClientOptions() + } + return &pv77BazServiceClient{ + client: c, + log: cfg.getLogger(), + } +} + +// NewPv77BazServiceClientWithOptions initializes a new Pv77BazService client with the given options +func NewPv77BazServiceClientWithOptions(c client.Client, opts client.Options, options ...*pv77BazServiceClientOptions) (Pv77BazServiceClient, error) { + var err error + c, err = client.NewClientFromExisting(c, opts) + if err != nil { + return nil, fmt.Errorf("error initializing client with options: %w", err) + } + var cfg *pv77BazServiceClientOptions + if len(options) > 0 { + cfg = options[0] + } else { + cfg = NewPv77BazServiceClientOptions() + } + return &pv77BazServiceClient{ + client: c, + log: cfg.getLogger(), + }, nil +} + +// pv77BazServiceClientOptions describes optional runtime configuration for a Pv77BazServiceClient +type pv77BazServiceClientOptions struct { + log *slog.Logger +} + +// NewPv77BazServiceClientOptions initializes a new pv77BazServiceClientOptions value +func NewPv77BazServiceClientOptions() *pv77BazServiceClientOptions { + return &pv77BazServiceClientOptions{} +} + +// WithLogger can be used to override the default logger +func (opts *pv77BazServiceClientOptions) WithLogger(l *slog.Logger) *pv77BazServiceClientOptions { + if l != nil { + opts.log = l + } + return opts +} + +// getLogger returns the configured logger, or the default logger +func (opts *pv77BazServiceClientOptions) getLogger() *slog.Logger { + if opts != nil && opts.log != nil { + return opts.log + } + return slog.Default() +} + +// test.patch.v1.Pv77BazService.Pv77Baz executes a test.patch.v1.Pv77BazService.Pv77Baz workflow and blocks until error or response received +func (c *pv77BazServiceClient) Pv77Baz(ctx context.Context, req *Pv77BazInput, options ...*Pv77BazOptions) (*Pv77BazOutput, error) { + run, err := c.Pv77BazAsync(ctx, req, options...) + if err != nil { + return nil, err + } + return run.Get(ctx) +} + +// Pv77BazAsync starts a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow and returns a handle to the workflow run +func (c *pv77BazServiceClient) Pv77BazAsync(ctx context.Context, req *Pv77BazInput, options ...*Pv77BazOptions) (Pv77BazRun, error) { + var o *Pv77BazOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77BazOptions() + } + opts, err := o.Build(req.ProtoReflect()) + if err != nil { + return nil, fmt.Errorf("error initializing client.StartWorkflowOptions: %w", err) + } + run, err := c.client.ExecuteWorkflow(ctx, opts, Pv77BazWorkflowName, req) + if err != nil { + return nil, err + } + if run == nil { + return nil, errors.New("execute workflow returned nil run") + } + return &pv77BazRun{ + client: c, + run: run, + }, nil +} + +// GetPv77Baz fetches an existing test.patch.v1.Pv77BazService.Pv77Baz execution +func (c *pv77BazServiceClient) GetPv77Baz(ctx context.Context, workflowID string, runID string) Pv77BazRun { + return &pv77BazRun{ + client: c, + run: c.client.GetWorkflow(ctx, workflowID, runID), + } +} + +// CancelWorkflow requests cancellation of an existing workflow execution +func (c *pv77BazServiceClient) CancelWorkflow(ctx context.Context, workflowID string, runID string) error { + return c.client.CancelWorkflow(ctx, workflowID, runID) +} + +// TerminateWorkflow terminates an existing workflow execution +func (c *pv77BazServiceClient) TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error { + return c.client.TerminateWorkflow(ctx, workflowID, runID, reason, details...) +} + +// Pv77BazOptions provides configuration for a test.patch.v1.Pv77BazService.Pv77Baz workflow operation +type Pv77BazOptions struct { + options client.StartWorkflowOptions + executionTimeout *time.Duration + id *string + idReusePolicy enumsv1.WorkflowIdReusePolicy + retryPolicy *temporal.RetryPolicy + runTimeout *time.Duration + searchAttributes map[string]any + taskQueue *string + taskTimeout *time.Duration +} + +// NewPv77BazOptions initializes a new Pv77BazOptions value +func NewPv77BazOptions() *Pv77BazOptions { + return &Pv77BazOptions{} +} + +// Build initializes a new go.temporal.io/sdk/client.StartWorkflowOptions value with defaults and overrides applied +func (o *Pv77BazOptions) Build(req protoreflect.Message) (client.StartWorkflowOptions, error) { + opts := o.options + if v := o.id; v != nil { + opts.ID = *v + } + if v := o.idReusePolicy; v != enumsv1.WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED { + opts.WorkflowIDReusePolicy = v + } + if v := o.taskQueue; v != nil { + opts.TaskQueue = *v + } else if opts.TaskQueue == "" { + opts.TaskQueue = Pv77BazServiceTaskQueue + } + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.searchAttributes; v != nil { + opts.SearchAttributes = o.searchAttributes + } + if v := o.executionTimeout; v != nil { + opts.WorkflowExecutionTimeout = *v + } + if v := o.runTimeout; v != nil { + opts.WorkflowRunTimeout = *v + } + if v := o.taskTimeout; v != nil { + opts.WorkflowTaskTimeout = *v + } + return opts, nil +} + +// WithStartWorkflowOptions sets the initial go.temporal.io/sdk/client.StartWorkflowOptions +func (o *Pv77BazOptions) WithStartWorkflowOptions(options client.StartWorkflowOptions) *Pv77BazOptions { + o.options = options + return o +} + +// WithExecutionTimeout sets the WorkflowExecutionTimeout value +func (o *Pv77BazOptions) WithExecutionTimeout(d time.Duration) *Pv77BazOptions { + o.executionTimeout = &d + return o +} + +// WithID sets the ID value +func (o *Pv77BazOptions) WithID(id string) *Pv77BazOptions { + o.id = &id + return o +} + +// WithIDReusePolicy sets the WorkflowIDReusePolicy value +func (o *Pv77BazOptions) WithIDReusePolicy(policy enumsv1.WorkflowIdReusePolicy) *Pv77BazOptions { + o.idReusePolicy = policy + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77BazOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77BazOptions { + o.retryPolicy = policy + return o +} + +// WithRunTimeout sets the WorkflowRunTimeout value +func (o *Pv77BazOptions) WithRunTimeout(d time.Duration) *Pv77BazOptions { + o.runTimeout = &d + return o +} + +// WithSearchAttributes sets the SearchAttributes value +func (o *Pv77BazOptions) WithSearchAttributes(sa map[string]any) *Pv77BazOptions { + o.searchAttributes = sa + return o +} + +// WithTaskTimeout sets the WorkflowTaskTimeout value +func (o *Pv77BazOptions) WithTaskTimeout(d time.Duration) *Pv77BazOptions { + o.taskTimeout = &d + return o +} + +// WithTaskQueue sets the TaskQueue value +func (o *Pv77BazOptions) WithTaskQueue(tq string) *Pv77BazOptions { + o.taskQueue = &tq + return o +} + +// Pv77BazRun describes a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow run +type Pv77BazRun interface { + // ID returns the workflow ID + ID() string + + // RunID returns the workflow instance ID + RunID() string + + // Run returns the inner client.WorkflowRun + Run() client.WorkflowRun + + // Get blocks until the workflow is complete and returns the result + Get(ctx context.Context) (*Pv77BazOutput, error) + + // Cancel requests cancellation of a workflow in execution, returning an error if applicable + Cancel(ctx context.Context) error + + // Terminate terminates a workflow in execution, returning an error if applicable + Terminate(ctx context.Context, reason string, details ...interface{}) error +} + +// pv77BazRun provides an internal implementation of a(n) Pv77BazRunRun +type pv77BazRun struct { + client *pv77BazServiceClient + run client.WorkflowRun +} + +// ID returns the workflow ID +func (r *pv77BazRun) ID() string { + return r.run.GetID() +} + +// Run returns the inner client.WorkflowRun +func (r *pv77BazRun) Run() client.WorkflowRun { + return r.run +} + +// RunID returns the execution ID +func (r *pv77BazRun) RunID() string { + return r.run.GetRunID() +} + +// Cancel requests cancellation of a workflow in execution, returning an error if applicable +func (r *pv77BazRun) Cancel(ctx context.Context) error { + return r.client.CancelWorkflow(ctx, r.ID(), r.RunID()) +} + +// Get blocks until the workflow is complete, returning the result if applicable +func (r *pv77BazRun) Get(ctx context.Context) (*Pv77BazOutput, error) { + var resp Pv77BazOutput + if err := r.run.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// Terminate terminates a workflow in execution, returning an error if applicable +func (r *pv77BazRun) Terminate(ctx context.Context, reason string, details ...interface{}) error { + return r.client.TerminateWorkflow(ctx, r.ID(), r.RunID(), reason, details...) +} + +// Reference to generated workflow functions +var ( + // Pv77BazFunction implements a "test.patch.v1.Pv77BazService.Pv77Baz" workflow + Pv77BazFunction func(workflow.Context, *Pv77BazInput) (*Pv77BazOutput, error) +) + +// Pv77BazServiceWorkflowFunctions describes a mockable dependency for inlining workflows within other workflows +type ( + // Pv77BazServiceWorkflowFunctions describes a mockable dependency for inlining workflows within other workflows + Pv77BazServiceWorkflowFunctions interface { + // Pv77Baz executes a "test.patch.v1.Pv77BazService.Pv77Baz" workflow inline + Pv77Baz(workflow.Context, *Pv77BazInput) (*Pv77BazOutput, error) + } + // pv77BazServiceWorkflowFunctions provides an internal Pv77BazServiceWorkflowFunctions implementation + pv77BazServiceWorkflowFunctions struct{} +) + +func NewPv77BazServiceWorkflowFunctions() Pv77BazServiceWorkflowFunctions { + return &pv77BazServiceWorkflowFunctions{} +} + +// Pv77Baz executes a "test.patch.v1.Pv77BazService.Pv77Baz" workflow inline +func (f *pv77BazServiceWorkflowFunctions) Pv77Baz(ctx workflow.Context, req *Pv77BazInput) (*Pv77BazOutput, error) { + if Pv77BazFunction == nil { + return nil, errors.New("Pv77Baz requires workflow registration via RegisterPv77BazServiceWorkflows or RegisterPv77BazWorkflow") + } + return Pv77BazFunction(ctx, req) +} + +// Pv77BazServiceWorkflows provides methods for initializing new test.patch.v1.Pv77BazService workflow values +type Pv77BazServiceWorkflows interface { + // Pv77Baz initializes a new a(n) Pv77BazWorkflow implementation + Pv77Baz(ctx workflow.Context, input *Pv77BazWorkflowInput) (Pv77BazWorkflow, error) +} + +// RegisterPv77BazServiceWorkflows registers test.patch.v1.Pv77BazService workflows with the given worker +func RegisterPv77BazServiceWorkflows(r worker.WorkflowRegistry, workflows Pv77BazServiceWorkflows) { + RegisterPv77BazWorkflow(r, workflows.Pv77Baz) +} + +// RegisterPv77BazWorkflow registers a test.patch.v1.Pv77BazService.Pv77Baz workflow with the given worker +func RegisterPv77BazWorkflow(r worker.WorkflowRegistry, wf func(workflow.Context, *Pv77BazWorkflowInput) (Pv77BazWorkflow, error)) { + Pv77BazFunction = buildPv77Baz(wf) + r.RegisterWorkflowWithOptions(Pv77BazFunction, workflow.RegisterOptions{Name: Pv77BazWorkflowName}) +} + +// buildPv77Baz converts a Pv77Baz workflow struct into a valid workflow function +func buildPv77Baz(ctor func(workflow.Context, *Pv77BazWorkflowInput) (Pv77BazWorkflow, error)) func(workflow.Context, *Pv77BazInput) (*Pv77BazOutput, error) { + return func(ctx workflow.Context, req *Pv77BazInput) (*Pv77BazOutput, error) { + input := &Pv77BazWorkflowInput{ + Req: req, + } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, Pv77BazServiceTaskQueue, workflow.GetInfo(ctx).TaskQueueName) + wf, err := ctor(ctx, input) + if err != nil { + return nil, err + } + if initializable, ok := wf.(helpers.Initializable); ok { + if err := initializable.Initialize(ctx); err != nil { + return nil, err + } + } + return wf.Execute(ctx) + } +} + +// Pv77BazWorkflowInput describes the input to a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow constructor +type Pv77BazWorkflowInput struct { + Req *Pv77BazInput +} + +// Pv77BazWorkflow describes a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow implementation +type Pv77BazWorkflow interface { + // Execute defines the entrypoint to a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow + Execute(ctx workflow.Context) (*Pv77BazOutput, error) +} + +// Pv77BazChild executes a child test.patch.v1.Pv77BazService.Pv77Baz workflow and blocks until error or response received +func Pv77BazChild(ctx workflow.Context, req *Pv77BazInput, options ...*Pv77BazChildOptions) (*Pv77BazOutput, error) { + childRun, err := Pv77BazChildAsync(ctx, req, options...) + if err != nil { + return nil, err + } + return childRun.Get(ctx) +} + +// Pv77BazChildAsync starts a child test.patch.v1.Pv77BazService.Pv77Baz workflow and returns a handle to the child workflow run +func Pv77BazChildAsync(ctx workflow.Context, req *Pv77BazInput, options ...*Pv77BazChildOptions) (*Pv77BazChildRun, error) { + var o *Pv77BazChildOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77BazChildOptions() + } + opts, err := o.Build(ctx, req.ProtoReflect()) + if err != nil { + return nil, fmt.Errorf("error initializing workflow.ChildWorkflowOptions: %w", err) + } + ctx = workflow.WithChildOptions(ctx, opts) + return &Pv77BazChildRun{Future: workflow.ExecuteChildWorkflow(ctx, Pv77BazWorkflowName, req)}, nil +} + +// Pv77BazChildOptions provides configuration for a child test.patch.v1.Pv77BazService.Pv77Baz workflow operation +type Pv77BazChildOptions struct { + options workflow.ChildWorkflowOptions + executionTimeout *time.Duration + id *string + idReusePolicy enumsv1.WorkflowIdReusePolicy + retryPolicy *temporal.RetryPolicy + runTimeout *time.Duration + searchAttributes map[string]any + taskQueue *string + taskTimeout *time.Duration + parentClosePolicy enumsv1.ParentClosePolicy + waitForCancellation *bool +} + +// NewPv77BazChildOptions initializes a new Pv77BazChildOptions value +func NewPv77BazChildOptions() *Pv77BazChildOptions { + return &Pv77BazChildOptions{} +} + +// Build initializes a new go.temporal.io/sdk/workflow.ChildWorkflowOptions value with defaults and overrides applied +func (o *Pv77BazChildOptions) Build(ctx workflow.Context, req protoreflect.Message) (workflow.ChildWorkflowOptions, error) { + opts := o.options + if v := o.id; v != nil { + opts.WorkflowID = *v + } + if v := o.idReusePolicy; v != enumsv1.WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED { + opts.WorkflowIDReusePolicy = v + } + if v := o.taskQueue; v != nil { + opts.TaskQueue = *v + } else if opts.TaskQueue == "" { + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if tq := patch.DefaultTaskQueue(ctx, Pv77BazServiceTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.searchAttributes; v != nil { + opts.SearchAttributes = o.searchAttributes + } + if v := o.executionTimeout; v != nil { + opts.WorkflowExecutionTimeout = *v + } + if v := o.runTimeout; v != nil { + opts.WorkflowRunTimeout = *v + } + if v := o.taskTimeout; v != nil { + opts.WorkflowTaskTimeout = *v + } + if v := o.parentClosePolicy; v != enumsv1.PARENT_CLOSE_POLICY_UNSPECIFIED { + opts.ParentClosePolicy = v + } + if v := o.waitForCancellation; v != nil { + opts.WaitForCancellation = *v + } + return opts, nil +} + +// WithChildWorkflowOptions sets the initial go.temporal.io/sdk/workflow.ChildWorkflowOptions +func (o *Pv77BazChildOptions) WithChildWorkflowOptions(options workflow.ChildWorkflowOptions) *Pv77BazChildOptions { + o.options = options + return o +} + +// WithExecutionTimeout sets the WorkflowExecutionTimeout value +func (o *Pv77BazChildOptions) WithExecutionTimeout(d time.Duration) *Pv77BazChildOptions { + o.executionTimeout = &d + return o +} + +// WithID sets the WorkflowID value +func (o *Pv77BazChildOptions) WithID(id string) *Pv77BazChildOptions { + o.id = &id + return o +} + +// WithIDReusePolicy sets the WorkflowIDReusePolicy value +func (o *Pv77BazChildOptions) WithIDReusePolicy(policy enumsv1.WorkflowIdReusePolicy) *Pv77BazChildOptions { + o.idReusePolicy = policy + return o +} + +// WithParentClosePolicy sets the WorkflowIDReusePolicy value +func (o *Pv77BazChildOptions) WithParentClosePolicy(policy enumsv1.ParentClosePolicy) *Pv77BazChildOptions { + o.parentClosePolicy = policy + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77BazChildOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77BazChildOptions { + o.retryPolicy = policy + return o +} + +// WithRunTimeout sets the WorkflowRunTimeout value +func (o *Pv77BazChildOptions) WithRunTimeout(d time.Duration) *Pv77BazChildOptions { + o.runTimeout = &d + return o +} + +// WithSearchAttributes sets the SearchAttributes value +func (o *Pv77BazChildOptions) WithSearchAttributes(sa map[string]any) *Pv77BazChildOptions { + o.searchAttributes = sa + return o +} + +// WithTaskTimeout sets the WorkflowTaskTimeout value +func (o *Pv77BazChildOptions) WithTaskTimeout(d time.Duration) *Pv77BazChildOptions { + o.taskTimeout = &d + return o +} + +// WithTaskQueue sets the TaskQueue value +func (o *Pv77BazChildOptions) WithTaskQueue(tq string) *Pv77BazChildOptions { + o.taskQueue = &tq + return o +} + +// WithWaitForCancellation sets the WaitForCancellation value +func (o *Pv77BazChildOptions) WithWaitForCancellation(wait bool) *Pv77BazChildOptions { + o.waitForCancellation = &wait + return o +} + +// Pv77BazChildRun describes a child Pv77Baz workflow run +type Pv77BazChildRun struct { + Future workflow.ChildWorkflowFuture +} + +// Get blocks until the workflow is completed, returning the response value +func (r *Pv77BazChildRun) Get(ctx workflow.Context) (*Pv77BazOutput, error) { + var resp Pv77BazOutput + if err := r.Future.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// Select adds this completion to the selector. Callback can be nil. +func (r *Pv77BazChildRun) Select(sel workflow.Selector, fn func(*Pv77BazChildRun)) workflow.Selector { + return sel.AddFuture(r.Future, func(workflow.Future) { + if fn != nil { + fn(r) + } + }) +} + +// SelectStart adds waiting for start to the selector. Callback can be nil. +func (r *Pv77BazChildRun) SelectStart(sel workflow.Selector, fn func(*Pv77BazChildRun)) workflow.Selector { + return sel.AddFuture(r.Future.GetChildWorkflowExecution(), func(workflow.Future) { + if fn != nil { + fn(r) + } + }) +} + +// WaitStart waits for the child workflow to start +func (r *Pv77BazChildRun) WaitStart(ctx workflow.Context) (*workflow.Execution, error) { + var exec workflow.Execution + if err := r.Future.GetChildWorkflowExecution().Get(ctx, &exec); err != nil { + return nil, err + } + return &exec, nil +} + +// Pv77BazServiceActivities describes available worker activities +type Pv77BazServiceActivities interface { + // test.patch.v1.Pv77BazService.Pv77Baz implements a(n) test.patch.v1.Pv77BazActivity activity definition + Pv77Baz(ctx context.Context, req *Pv77BazInput) (*Pv77BazOutput, error) +} + +// RegisterPv77BazServiceActivities registers activities with a worker +func RegisterPv77BazServiceActivities(r worker.ActivityRegistry, activities Pv77BazServiceActivities) { + RegisterPv77BazActivity(r, activities.Pv77Baz) +} + +// RegisterPv77BazActivity registers a test.patch.v1.Pv77BazActivity activity +func RegisterPv77BazActivity(r worker.ActivityRegistry, fn func(context.Context, *Pv77BazInput) (*Pv77BazOutput, error)) { + r.RegisterActivityWithOptions(fn, activity.RegisterOptions{ + Name: Pv77BazActivityName, + }) +} + +// Pv77BazFuture describes a(n) test.patch.v1.Pv77BazActivity activity execution +type Pv77BazFuture struct { + Future workflow.Future +} + +// Get blocks on the activity's completion, returning the response +func (f *Pv77BazFuture) Get(ctx workflow.Context) (*Pv77BazOutput, error) { + var resp Pv77BazOutput + if err := f.Future.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// Select adds the activity's completion to the selector, callback can be nil +func (f *Pv77BazFuture) Select(sel workflow.Selector, fn func(*Pv77BazFuture)) workflow.Selector { + return sel.AddFuture(f.Future, func(workflow.Future) { + if fn != nil { + fn(f) + } + }) +} + +// Pv77Baz executes a(n) test.patch.v1.Pv77BazActivity activity +func Pv77Baz(ctx workflow.Context, req *Pv77BazInput, options ...*Pv77BazActivityOptions) (*Pv77BazOutput, error) { + return Pv77BazAsync(ctx, req, options...).Get(ctx) +} + +// Pv77BazAsync executes a(n) test.patch.v1.Pv77BazActivity activity (asynchronously) +func Pv77BazAsync(ctx workflow.Context, req *Pv77BazInput, options ...*Pv77BazActivityOptions) *Pv77BazFuture { + var o *Pv77BazActivityOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77BazActivityOptions() + } + var err error + if ctx, err = o.Build(ctx); err != nil { + errF, errS := workflow.NewFuture(ctx) + errS.SetError(err) + return &Pv77BazFuture{Future: errF} + } + activity := Pv77BazActivityName + future := &Pv77BazFuture{Future: workflow.ExecuteActivity(ctx, activity, req)} + return future +} + +// Pv77BazLocal executes a(n) test.patch.v1.Pv77BazActivity activity (locally) +func Pv77BazLocal(ctx workflow.Context, req *Pv77BazInput, options ...*Pv77BazLocalActivityOptions) (*Pv77BazOutput, error) { + return Pv77BazLocalAsync(ctx, req, options...).Get(ctx) +} + +// Pv77BazLocalAsync executes a(n) test.patch.v1.Pv77BazActivity activity (asynchronously, locally) +func Pv77BazLocalAsync(ctx workflow.Context, req *Pv77BazInput, options ...*Pv77BazLocalActivityOptions) *Pv77BazFuture { + var o *Pv77BazLocalActivityOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77BazLocalActivityOptions() + } + var err error + if ctx, err = o.Build(ctx); err != nil { + errF, errS := workflow.NewFuture(ctx) + errS.SetError(err) + return &Pv77BazFuture{Future: errF} + } + var activity any + if o.fn != nil { + activity = o.fn + } else { + activity = Pv77BazActivityName + } + future := &Pv77BazFuture{Future: workflow.ExecuteLocalActivity(ctx, activity, req)} + return future +} + +// Pv77BazActivityOptions provides configuration for a(n) test.patch.v1.Pv77BazActivity activity +type Pv77BazActivityOptions struct { + options workflow.ActivityOptions + retryPolicy *temporal.RetryPolicy + scheduleToCloseTimeout *time.Duration + startToCloseTimeout *time.Duration + heartbeatTimeout *time.Duration + scheduleToStartTimeout *time.Duration + taskQueue *string + waitForCancellation *bool +} + +// NewPv77BazActivityOptions initializes a new Pv77BazActivityOptions value +func NewPv77BazActivityOptions() *Pv77BazActivityOptions { + return &Pv77BazActivityOptions{} +} + +// Build initializes a workflow.Context with appropriate ActivityOptions values derived from schema defaults and any user-defined overrides +func (o *Pv77BazActivityOptions) Build(ctx workflow.Context) (workflow.Context, error) { + opts := o.options + if v := o.heartbeatTimeout; v != nil { + opts.HeartbeatTimeout = *v + } + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.scheduleToCloseTimeout; v != nil { + opts.ScheduleToCloseTimeout = *v + } + if v := o.scheduleToStartTimeout; v != nil { + opts.ScheduleToStartTimeout = *v + } + if v := o.startToCloseTimeout; v != nil { + opts.StartToCloseTimeout = *v + } else if opts.StartToCloseTimeout == 0 { + opts.StartToCloseTimeout = 5000000000 // 5 seconds + } + if v := o.taskQueue; v != nil { + opts.TaskQueue = *v + } else if opts.TaskQueue == "" { + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if tq := patch.DefaultTaskQueue(ctx, Pv77BazServiceTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } + if v := o.waitForCancellation; v != nil { + opts.WaitForCancellation = *v + } + return workflow.WithActivityOptions(ctx, opts), nil +} + +// WithActivityOptions specifies an initial ActivityOptions value to which defaults will be applied +func (o *Pv77BazActivityOptions) WithActivityOptions(options workflow.ActivityOptions) *Pv77BazActivityOptions { + o.options = options + return o +} + +// WithHeartbeatTimeout sets the HeartbeatTimeout value +func (o *Pv77BazActivityOptions) WithHeartbeatTimeout(d time.Duration) *Pv77BazActivityOptions { + o.heartbeatTimeout = &d + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77BazActivityOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77BazActivityOptions { + o.retryPolicy = policy + return o +} + +// WithScheduleToCloseTimeout sets the ScheduleToCloseTimeout value +func (o *Pv77BazActivityOptions) WithScheduleToCloseTimeout(d time.Duration) *Pv77BazActivityOptions { + o.scheduleToCloseTimeout = &d + return o +} + +// WithScheduleToStartTimeout sets the ScheduleToStartTimeout value +func (o *Pv77BazActivityOptions) WithScheduleToStartTimeout(d time.Duration) *Pv77BazActivityOptions { + o.scheduleToStartTimeout = &d + return o +} + +// WithStartToCloseTimeout sets the StartToCloseTimeout value +func (o *Pv77BazActivityOptions) WithStartToCloseTimeout(d time.Duration) *Pv77BazActivityOptions { + o.startToCloseTimeout = &d + return o +} + +// WithTaskQueue sets the TaskQueue value +func (o *Pv77BazActivityOptions) WithTaskQueue(tq string) *Pv77BazActivityOptions { + o.taskQueue = &tq + return o +} + +// WithWaitForCancellation sets the WaitForCancellation value +func (o *Pv77BazActivityOptions) WithWaitForCancellation(wait bool) *Pv77BazActivityOptions { + o.waitForCancellation = &wait + return o +} + +// Pv77BazLocalActivityOptions provides configuration for a(n) test.patch.v1.Pv77BazActivity activity +type Pv77BazLocalActivityOptions struct { + options workflow.LocalActivityOptions + retryPolicy *temporal.RetryPolicy + scheduleToCloseTimeout *time.Duration + startToCloseTimeout *time.Duration + fn func(context.Context, *Pv77BazInput) (*Pv77BazOutput, error) +} + +// NewPv77BazLocalActivityOptions initializes a new Pv77BazLocalActivityOptions value +func NewPv77BazLocalActivityOptions() *Pv77BazLocalActivityOptions { + return &Pv77BazLocalActivityOptions{} +} + +// Build initializes a workflow.Context with appropriate LocalActivityOptions values derived from schema defaults and any user-defined overrides +func (o *Pv77BazLocalActivityOptions) Build(ctx workflow.Context) (workflow.Context, error) { + opts := o.options + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.scheduleToCloseTimeout; v != nil { + opts.ScheduleToCloseTimeout = *v + } + if v := o.startToCloseTimeout; v != nil { + opts.StartToCloseTimeout = *v + } else if opts.StartToCloseTimeout == 0 { + opts.StartToCloseTimeout = 5000000000 // 5 seconds + } + return workflow.WithLocalActivityOptions(ctx, opts), nil +} + +// Local specifies a custom test.patch.v1.Pv77BazActivity implementation +func (o *Pv77BazLocalActivityOptions) Local(fn func(context.Context, *Pv77BazInput) (*Pv77BazOutput, error)) *Pv77BazLocalActivityOptions { + o.fn = fn + return o +} + +// WithLocalActivityOptions specifies an initial LocalActivityOptions value to which defaults will be applied +func (o *Pv77BazLocalActivityOptions) WithLocalActivityOptions(options workflow.LocalActivityOptions) *Pv77BazLocalActivityOptions { + o.options = options + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77BazLocalActivityOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77BazLocalActivityOptions { + o.retryPolicy = policy + return o +} + +// WithScheduleToCloseTimeout sets the ScheduleToCloseTimeout value +func (o *Pv77BazLocalActivityOptions) WithScheduleToCloseTimeout(d time.Duration) *Pv77BazLocalActivityOptions { + o.scheduleToCloseTimeout = &d + return o +} + +// WithStartToCloseTimeout sets the StartToCloseTimeout value +func (o *Pv77BazLocalActivityOptions) WithStartToCloseTimeout(d time.Duration) *Pv77BazLocalActivityOptions { + o.startToCloseTimeout = &d + return o +} + +// TestClient provides a testsuite-compatible Client +type TestPv77BazServiceClient struct { + env *testsuite.TestWorkflowEnvironment + workflows Pv77BazServiceWorkflows +} + +var _ Pv77BazServiceClient = &TestPv77BazServiceClient{} + +// NewTestPv77BazServiceClient initializes a new TestPv77BazServiceClient value +func NewTestPv77BazServiceClient(env *testsuite.TestWorkflowEnvironment, workflows Pv77BazServiceWorkflows, activities Pv77BazServiceActivities) *TestPv77BazServiceClient { + if workflows != nil { + RegisterPv77BazServiceWorkflows(env, workflows) + } + if activities != nil { + RegisterPv77BazServiceActivities(env, activities) + } + return &TestPv77BazServiceClient{env, workflows} +} + +// Pv77Baz executes a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow in the test environment +func (c *TestPv77BazServiceClient) Pv77Baz(ctx context.Context, req *Pv77BazInput, opts ...*Pv77BazOptions) (*Pv77BazOutput, error) { + run, err := c.Pv77BazAsync(ctx, req, opts...) + if err != nil { + return nil, err + } + return run.Get(ctx) +} + +// Pv77BazAsync executes a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow in the test environment +func (c *TestPv77BazServiceClient) Pv77BazAsync(ctx context.Context, req *Pv77BazInput, options ...*Pv77BazOptions) (Pv77BazRun, error) { + var o *Pv77BazOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77BazOptions() + } + opts, err := o.Build(req.ProtoReflect()) + if err != nil { + return nil, fmt.Errorf("error initializing client.StartWorkflowOptions: %w", err) + } + return &testPv77BazRun{client: c, env: c.env, opts: &opts, req: req, workflows: c.workflows}, nil +} + +// GetPv77Baz is a noop +func (c *TestPv77BazServiceClient) GetPv77Baz(ctx context.Context, workflowID string, runID string) Pv77BazRun { + return &testPv77BazRun{env: c.env, workflows: c.workflows} +} + +// CancelWorkflow requests cancellation of an existing workflow execution +func (c *TestPv77BazServiceClient) CancelWorkflow(ctx context.Context, workflowID string, runID string) error { + c.env.CancelWorkflow() + return nil +} + +// TerminateWorkflow terminates an existing workflow execution +func (c *TestPv77BazServiceClient) TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error { + return c.CancelWorkflow(ctx, workflowID, runID) +} + +var _ Pv77BazRun = &testPv77BazRun{} + +// testPv77BazRun provides convenience methods for interacting with a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow in the test environment +type testPv77BazRun struct { + client *TestPv77BazServiceClient + env *testsuite.TestWorkflowEnvironment + opts *client.StartWorkflowOptions + req *Pv77BazInput + workflows Pv77BazServiceWorkflows +} + +// Cancel requests cancellation of a workflow in execution, returning an error if applicable +func (r *testPv77BazRun) Cancel(ctx context.Context) error { + return r.client.CancelWorkflow(ctx, r.ID(), r.RunID()) +} + +// Get retrieves a test test.patch.v1.Pv77BazService.Pv77Baz workflow result +func (r *testPv77BazRun) Get(context.Context) (*Pv77BazOutput, error) { + r.env.ExecuteWorkflow(Pv77BazWorkflowName, r.req) + if !r.env.IsWorkflowCompleted() { + return nil, errors.New("workflow in progress") + } + if err := r.env.GetWorkflowError(); err != nil { + return nil, err + } + var result Pv77BazOutput + if err := r.env.GetWorkflowResult(&result); err != nil { + return nil, err + } + return &result, nil +} + +// ID returns a test test.patch.v1.Pv77BazService.Pv77Baz workflow run's workflow ID +func (r *testPv77BazRun) ID() string { + if r.opts != nil { + return r.opts.ID + } + return "" +} + +// Run noop implementation +func (r *testPv77BazRun) Run() client.WorkflowRun { + return nil +} + +// RunID noop implementation +func (r *testPv77BazRun) RunID() string { + return "" +} + +// Terminate terminates a workflow in execution, returning an error if applicable +func (r *testPv77BazRun) Terminate(ctx context.Context, reason string, details ...interface{}) error { + return r.client.TerminateWorkflow(ctx, r.ID(), r.RunID(), reason, details...) +} + +// Pv77BazServiceCliOptions describes runtime configuration for test.patch.v1.Pv77BazService cli +type Pv77BazServiceCliOptions struct { + after func(*v2.Context) error + before func(*v2.Context) error + clientForCommand func(*v2.Context) (client.Client, error) + worker func(*v2.Context, client.Client) (worker.Worker, error) +} + +// NewPv77BazServiceCliOptions initializes a new Pv77BazServiceCliOptions value +func NewPv77BazServiceCliOptions() *Pv77BazServiceCliOptions { + return &Pv77BazServiceCliOptions{} +} + +// WithAfter injects a custom After hook to be run after any command invocation +func (opts *Pv77BazServiceCliOptions) WithAfter(fn func(*v2.Context) error) *Pv77BazServiceCliOptions { + opts.after = fn + return opts +} + +// WithBefore injects a custom Before hook to be run prior to any command invocation +func (opts *Pv77BazServiceCliOptions) WithBefore(fn func(*v2.Context) error) *Pv77BazServiceCliOptions { + opts.before = fn + return opts +} + +// WithClient provides a Temporal client factory for use by commands +func (opts *Pv77BazServiceCliOptions) WithClient(fn func(*v2.Context) (client.Client, error)) *Pv77BazServiceCliOptions { + opts.clientForCommand = fn + return opts +} + +// WithWorker provides an method for initializing a worker +func (opts *Pv77BazServiceCliOptions) WithWorker(fn func(*v2.Context, client.Client) (worker.Worker, error)) *Pv77BazServiceCliOptions { + opts.worker = fn + return opts +} + +// NewPv77BazServiceCli initializes a cli for a(n) test.patch.v1.Pv77BazService service +func NewPv77BazServiceCli(options ...*Pv77BazServiceCliOptions) (*v2.App, error) { + commands, err := newPv77BazServiceCommands(options...) + if err != nil { + return nil, fmt.Errorf("error initializing subcommands: %w", err) + } + return &v2.App{ + Name: "pv-77-baz-service", + Commands: commands, + }, nil +} + +// NewPv77BazServiceCliCommand initializes a cli command for a test.patch.v1.Pv77BazService service with subcommands for each query, signal, update, and workflow +func NewPv77BazServiceCliCommand(options ...*Pv77BazServiceCliOptions) (*v2.Command, error) { + subcommands, err := newPv77BazServiceCommands(options...) + if err != nil { + return nil, fmt.Errorf("error initializing subcommands: %w", err) + } + return &v2.Command{ + Name: "pv-77-baz-service", + Subcommands: subcommands, + }, nil +} + +// newPv77BazServiceCommands initializes (sub)commands for a test.patch.v1.Pv77BazService cli or command +func newPv77BazServiceCommands(options ...*Pv77BazServiceCliOptions) ([]*v2.Command, error) { + opts := &Pv77BazServiceCliOptions{} + if len(options) > 0 { + opts = options[0] + } + if opts.clientForCommand == nil { + opts.clientForCommand = func(*v2.Context) (client.Client, error) { + return client.Dial(client.Options{}) + } + } + commands := []*v2.Command{ + { + Name: "pv-77-baz", + Usage: "executes a(n) test.patch.v1.Pv77BazService.Pv77Baz workflow", + Category: "WORKFLOWS", + UseShortOptionHandling: true, + Before: opts.before, + After: opts.after, + Flags: []v2.Flag{ + &v2.BoolFlag{ + Name: "detach", + Usage: "run workflow in the background and print workflow and execution id", + Aliases: []string{"d"}, + }, + &v2.StringFlag{ + Name: "task-queue", + Usage: "task queue name", + Aliases: []string{"t"}, + EnvVars: []string{"TEMPORAL_TASK_QUEUE_NAME", "TEMPORAL_TASK_QUEUE", "TASK_QUEUE_NAME", "TASK_QUEUE"}, + Value: "pv77-v3", + }, + &v2.StringFlag{ + Name: "input-file", + Usage: "path to json-formatted input file", + Aliases: []string{"f"}, + }, + &v2.StringSliceFlag{ + Name: "next", + Usage: "set the value of the operation's \"Next\" parameter", + Category: "INPUT", + }, + }, + Action: func(cmd *v2.Context) error { + tc, err := opts.clientForCommand(cmd) + if err != nil { + return fmt.Errorf("error initializing client for command: %w", err) + } + defer tc.Close() + c := NewPv77BazServiceClient(tc) + req, err := UnmarshalCliFlagsToPv77BazInput(cmd) + if err != nil { + return fmt.Errorf("error unmarshalling request: %w", err) + } + opts := client.StartWorkflowOptions{} + if tq := cmd.String("task-queue"); tq != "" { + opts.TaskQueue = tq + } + run, err := c.Pv77BazAsync(cmd.Context, req, NewPv77BazOptions().WithStartWorkflowOptions(opts)) + if err != nil { + return fmt.Errorf("error starting %s workflow: %w", Pv77BazWorkflowName, err) + } + if cmd.Bool("detach") { + fmt.Println("success") + fmt.Printf("workflow id: %s\n", run.ID()) + fmt.Printf("run id: %s\n", run.RunID()) + return nil + } + if resp, err := run.Get(cmd.Context); err != nil { + return err + } else { + b, err := protojson.Marshal(resp) + if err != nil { + return fmt.Errorf("error serializing response json: %w", err) + } + var out bytes.Buffer + if err := json.Indent(&out, b, "", " "); err != nil { + return fmt.Errorf("error formatting json: %w", err) + } + fmt.Println(out.String()) + return nil + } + }, + }, + } + if opts.worker != nil { + commands = append(commands, []*v2.Command{ + { + Name: "worker", + Usage: "runs a test.patch.v1.Pv77BazService worker process", + UseShortOptionHandling: true, + Before: opts.before, + After: opts.after, + Action: func(cmd *v2.Context) error { + c, err := opts.clientForCommand(cmd) + if err != nil { + return fmt.Errorf("error initializing client for command: %w", err) + } + defer c.Close() + w, err := opts.worker(cmd, c) + if opts.worker != nil { + if err != nil { + return fmt.Errorf("error initializing worker: %w", err) + } + } + if err := w.Start(); err != nil { + return fmt.Errorf("error starting worker: %w", err) + } + defer w.Stop() + <-cmd.Context.Done() + return nil + }, + }, + }...) + } + sort.Slice(commands, func(i, j int) bool { + return commands[i].Name < commands[j].Name + }) + return commands, nil +} + +// UnmarshalCliFlagsToPv77BazInput unmarshals a Pv77BazInput from command line flags +func UnmarshalCliFlagsToPv77BazInput(cmd *v2.Context) (*Pv77BazInput, error) { + var result Pv77BazInput + var hasValues bool + if cmd.IsSet("input-file") { + inputFile, err := gohomedir.Expand(cmd.String("input-file")) + if err != nil { + inputFile = cmd.String("input-file") + } + b, err := os.ReadFile(inputFile) + if err != nil { + return nil, fmt.Errorf("error reading input-file: %w", err) + } + if err := protojson.Unmarshal(b, &result); err != nil { + return nil, fmt.Errorf("error parsing input-file json: %w", err) + } + hasValues = true + } + if cmd.IsSet("next") { + hasValues = true + var tmp Pv77BazInput + if err := protojson.Unmarshal([]byte(fmt.Sprintf("{\"next\":%s}", cmd.String("next"))), &tmp); err != nil { + return nil, fmt.Errorf("error unmarshalling \"next\" map flag: %w", err) + } + result.Next = tmp.Next + } + if !hasValues { + return nil, nil + } + return &result, nil +} + +// WithPv77BazServiceSchemeTypes registers all Pv77BazService protobuf types with the given scheme +func WithPv77BazServiceSchemeTypes() scheme.Option { + return func(s *scheme.Scheme) { + s.RegisterType(File_test_patch_v1_pv77_proto.Messages().ByName("Pv77BazInput")) + s.RegisterType(File_test_patch_v1_pv77_proto.Messages().ByName("Pv77BazOutput")) + s.RegisterType(File_test_patch_v1_pv77_proto.Messages().ByName("Pv77BazOutput").Messages().ByName("DefaultsEntry")) + } +} + +// Pv77QuxServiceTaskQueue is the default task-queue for a test.patch.v1.Pv77QuxService worker +const Pv77QuxServiceTaskQueue = "pv77-v2" + +// test.patch.v1.Pv77QuxService workflow names +const ( + Pv77QuxWorkflowName = "test.patch.v1.Pv77QuxService.Pv77Qux" +) + +// test.patch.v1.Pv77QuxService activity names +const ( + Pv77QuxActivityName = "test.patch.v1.Pv77QuxActivity" +) + +// Pv77QuxServiceClient describes a client for a(n) test.patch.v1.Pv77QuxService worker +type Pv77QuxServiceClient interface { + // Pv77Qux executes a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow and blocks until error or response received + Pv77Qux(ctx context.Context, req *Pv77QuxInput, opts ...*Pv77QuxOptions) (*Pv77QuxOutput, error) + + // Pv77QuxAsync starts a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow and returns a handle to the workflow run + Pv77QuxAsync(ctx context.Context, req *Pv77QuxInput, opts ...*Pv77QuxOptions) (Pv77QuxRun, error) + + // GetPv77Qux retrieves a handle to an existing test.patch.v1.Pv77QuxService.Pv77Qux workflow execution + GetPv77Qux(ctx context.Context, workflowID string, runID string) Pv77QuxRun + + // CancelWorkflow requests cancellation of an existing workflow execution + CancelWorkflow(ctx context.Context, workflowID string, runID string) error + + // TerminateWorkflow an existing workflow execution + TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error +} + +// pv77QuxServiceClient implements a temporal client for a test.patch.v1.Pv77QuxService service +type pv77QuxServiceClient struct { + client client.Client + log *slog.Logger +} + +// NewPv77QuxServiceClient initializes a new test.patch.v1.Pv77QuxService client +func NewPv77QuxServiceClient(c client.Client, options ...*pv77QuxServiceClientOptions) Pv77QuxServiceClient { + var cfg *pv77QuxServiceClientOptions + if len(options) > 0 { + cfg = options[0] + } else { + cfg = NewPv77QuxServiceClientOptions() + } + return &pv77QuxServiceClient{ + client: c, + log: cfg.getLogger(), + } +} + +// NewPv77QuxServiceClientWithOptions initializes a new Pv77QuxService client with the given options +func NewPv77QuxServiceClientWithOptions(c client.Client, opts client.Options, options ...*pv77QuxServiceClientOptions) (Pv77QuxServiceClient, error) { + var err error + c, err = client.NewClientFromExisting(c, opts) + if err != nil { + return nil, fmt.Errorf("error initializing client with options: %w", err) + } + var cfg *pv77QuxServiceClientOptions + if len(options) > 0 { + cfg = options[0] + } else { + cfg = NewPv77QuxServiceClientOptions() + } + return &pv77QuxServiceClient{ + client: c, + log: cfg.getLogger(), + }, nil +} + +// pv77QuxServiceClientOptions describes optional runtime configuration for a Pv77QuxServiceClient +type pv77QuxServiceClientOptions struct { + log *slog.Logger +} + +// NewPv77QuxServiceClientOptions initializes a new pv77QuxServiceClientOptions value +func NewPv77QuxServiceClientOptions() *pv77QuxServiceClientOptions { + return &pv77QuxServiceClientOptions{} +} + +// WithLogger can be used to override the default logger +func (opts *pv77QuxServiceClientOptions) WithLogger(l *slog.Logger) *pv77QuxServiceClientOptions { + if l != nil { + opts.log = l + } + return opts +} + +// getLogger returns the configured logger, or the default logger +func (opts *pv77QuxServiceClientOptions) getLogger() *slog.Logger { + if opts != nil && opts.log != nil { + return opts.log + } + return slog.Default() +} + +// test.patch.v1.Pv77QuxService.Pv77Qux executes a test.patch.v1.Pv77QuxService.Pv77Qux workflow and blocks until error or response received +func (c *pv77QuxServiceClient) Pv77Qux(ctx context.Context, req *Pv77QuxInput, options ...*Pv77QuxOptions) (*Pv77QuxOutput, error) { + run, err := c.Pv77QuxAsync(ctx, req, options...) + if err != nil { + return nil, err + } + return run.Get(ctx) +} + +// Pv77QuxAsync starts a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow and returns a handle to the workflow run +func (c *pv77QuxServiceClient) Pv77QuxAsync(ctx context.Context, req *Pv77QuxInput, options ...*Pv77QuxOptions) (Pv77QuxRun, error) { + var o *Pv77QuxOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77QuxOptions() + } + opts, err := o.Build(req.ProtoReflect()) + if err != nil { + return nil, fmt.Errorf("error initializing client.StartWorkflowOptions: %w", err) + } + run, err := c.client.ExecuteWorkflow(ctx, opts, Pv77QuxWorkflowName, req) + if err != nil { + return nil, err + } + if run == nil { + return nil, errors.New("execute workflow returned nil run") + } + return &pv77QuxRun{ + client: c, + run: run, + }, nil +} + +// GetPv77Qux fetches an existing test.patch.v1.Pv77QuxService.Pv77Qux execution +func (c *pv77QuxServiceClient) GetPv77Qux(ctx context.Context, workflowID string, runID string) Pv77QuxRun { + return &pv77QuxRun{ + client: c, + run: c.client.GetWorkflow(ctx, workflowID, runID), + } +} + +// CancelWorkflow requests cancellation of an existing workflow execution +func (c *pv77QuxServiceClient) CancelWorkflow(ctx context.Context, workflowID string, runID string) error { + return c.client.CancelWorkflow(ctx, workflowID, runID) +} + +// TerminateWorkflow terminates an existing workflow execution +func (c *pv77QuxServiceClient) TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error { + return c.client.TerminateWorkflow(ctx, workflowID, runID, reason, details...) +} + +// Pv77QuxOptions provides configuration for a test.patch.v1.Pv77QuxService.Pv77Qux workflow operation +type Pv77QuxOptions struct { + options client.StartWorkflowOptions + executionTimeout *time.Duration + id *string + idReusePolicy enumsv1.WorkflowIdReusePolicy + retryPolicy *temporal.RetryPolicy + runTimeout *time.Duration + searchAttributes map[string]any + taskQueue *string + taskTimeout *time.Duration +} + +// NewPv77QuxOptions initializes a new Pv77QuxOptions value +func NewPv77QuxOptions() *Pv77QuxOptions { + return &Pv77QuxOptions{} +} + +// Build initializes a new go.temporal.io/sdk/client.StartWorkflowOptions value with defaults and overrides applied +func (o *Pv77QuxOptions) Build(req protoreflect.Message) (client.StartWorkflowOptions, error) { + opts := o.options + if v := o.id; v != nil { + opts.ID = *v + } + if v := o.idReusePolicy; v != enumsv1.WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED { + opts.WorkflowIDReusePolicy = v + } + if v := o.taskQueue; v != nil { + opts.TaskQueue = *v + } else if opts.TaskQueue == "" { + opts.TaskQueue = Pv77QuxServiceTaskQueue + } + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.searchAttributes; v != nil { + opts.SearchAttributes = o.searchAttributes + } + if v := o.executionTimeout; v != nil { + opts.WorkflowExecutionTimeout = *v + } + if v := o.runTimeout; v != nil { + opts.WorkflowRunTimeout = *v + } + if v := o.taskTimeout; v != nil { + opts.WorkflowTaskTimeout = *v + } + return opts, nil +} + +// WithStartWorkflowOptions sets the initial go.temporal.io/sdk/client.StartWorkflowOptions +func (o *Pv77QuxOptions) WithStartWorkflowOptions(options client.StartWorkflowOptions) *Pv77QuxOptions { + o.options = options + return o +} + +// WithExecutionTimeout sets the WorkflowExecutionTimeout value +func (o *Pv77QuxOptions) WithExecutionTimeout(d time.Duration) *Pv77QuxOptions { + o.executionTimeout = &d + return o +} + +// WithID sets the ID value +func (o *Pv77QuxOptions) WithID(id string) *Pv77QuxOptions { + o.id = &id + return o +} + +// WithIDReusePolicy sets the WorkflowIDReusePolicy value +func (o *Pv77QuxOptions) WithIDReusePolicy(policy enumsv1.WorkflowIdReusePolicy) *Pv77QuxOptions { + o.idReusePolicy = policy + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77QuxOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77QuxOptions { + o.retryPolicy = policy + return o +} + +// WithRunTimeout sets the WorkflowRunTimeout value +func (o *Pv77QuxOptions) WithRunTimeout(d time.Duration) *Pv77QuxOptions { + o.runTimeout = &d + return o +} + +// WithSearchAttributes sets the SearchAttributes value +func (o *Pv77QuxOptions) WithSearchAttributes(sa map[string]any) *Pv77QuxOptions { + o.searchAttributes = sa + return o +} + +// WithTaskTimeout sets the WorkflowTaskTimeout value +func (o *Pv77QuxOptions) WithTaskTimeout(d time.Duration) *Pv77QuxOptions { + o.taskTimeout = &d + return o +} + +// WithTaskQueue sets the TaskQueue value +func (o *Pv77QuxOptions) WithTaskQueue(tq string) *Pv77QuxOptions { + o.taskQueue = &tq + return o +} + +// Pv77QuxRun describes a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow run +type Pv77QuxRun interface { + // ID returns the workflow ID + ID() string + + // RunID returns the workflow instance ID + RunID() string + + // Run returns the inner client.WorkflowRun + Run() client.WorkflowRun + + // Get blocks until the workflow is complete and returns the result + Get(ctx context.Context) (*Pv77QuxOutput, error) + + // Cancel requests cancellation of a workflow in execution, returning an error if applicable + Cancel(ctx context.Context) error + + // Terminate terminates a workflow in execution, returning an error if applicable + Terminate(ctx context.Context, reason string, details ...interface{}) error +} + +// pv77QuxRun provides an internal implementation of a(n) Pv77QuxRunRun +type pv77QuxRun struct { + client *pv77QuxServiceClient + run client.WorkflowRun +} + +// ID returns the workflow ID +func (r *pv77QuxRun) ID() string { + return r.run.GetID() +} + +// Run returns the inner client.WorkflowRun +func (r *pv77QuxRun) Run() client.WorkflowRun { + return r.run +} + +// RunID returns the execution ID +func (r *pv77QuxRun) RunID() string { + return r.run.GetRunID() +} + +// Cancel requests cancellation of a workflow in execution, returning an error if applicable +func (r *pv77QuxRun) Cancel(ctx context.Context) error { + return r.client.CancelWorkflow(ctx, r.ID(), r.RunID()) +} + +// Get blocks until the workflow is complete, returning the result if applicable +func (r *pv77QuxRun) Get(ctx context.Context) (*Pv77QuxOutput, error) { + var resp Pv77QuxOutput + if err := r.run.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// Terminate terminates a workflow in execution, returning an error if applicable +func (r *pv77QuxRun) Terminate(ctx context.Context, reason string, details ...interface{}) error { + return r.client.TerminateWorkflow(ctx, r.ID(), r.RunID(), reason, details...) +} + +// Reference to generated workflow functions +var ( + // Pv77QuxFunction implements a "test.patch.v1.Pv77QuxService.Pv77Qux" workflow + Pv77QuxFunction func(workflow.Context, *Pv77QuxInput) (*Pv77QuxOutput, error) +) + +// Pv77QuxServiceWorkflowFunctions describes a mockable dependency for inlining workflows within other workflows +type ( + // Pv77QuxServiceWorkflowFunctions describes a mockable dependency for inlining workflows within other workflows + Pv77QuxServiceWorkflowFunctions interface { + // Pv77Qux executes a "test.patch.v1.Pv77QuxService.Pv77Qux" workflow inline + Pv77Qux(workflow.Context, *Pv77QuxInput) (*Pv77QuxOutput, error) + } + // pv77QuxServiceWorkflowFunctions provides an internal Pv77QuxServiceWorkflowFunctions implementation + pv77QuxServiceWorkflowFunctions struct{} +) + +func NewPv77QuxServiceWorkflowFunctions() Pv77QuxServiceWorkflowFunctions { + return &pv77QuxServiceWorkflowFunctions{} +} + +// Pv77Qux executes a "test.patch.v1.Pv77QuxService.Pv77Qux" workflow inline +func (f *pv77QuxServiceWorkflowFunctions) Pv77Qux(ctx workflow.Context, req *Pv77QuxInput) (*Pv77QuxOutput, error) { + if Pv77QuxFunction == nil { + return nil, errors.New("Pv77Qux requires workflow registration via RegisterPv77QuxServiceWorkflows or RegisterPv77QuxWorkflow") + } + return Pv77QuxFunction(ctx, req) +} + +// Pv77QuxServiceWorkflows provides methods for initializing new test.patch.v1.Pv77QuxService workflow values +type Pv77QuxServiceWorkflows interface { + // Pv77Qux initializes a new a(n) Pv77QuxWorkflow implementation + Pv77Qux(ctx workflow.Context, input *Pv77QuxWorkflowInput) (Pv77QuxWorkflow, error) +} + +// RegisterPv77QuxServiceWorkflows registers test.patch.v1.Pv77QuxService workflows with the given worker +func RegisterPv77QuxServiceWorkflows(r worker.WorkflowRegistry, workflows Pv77QuxServiceWorkflows) { + RegisterPv77QuxWorkflow(r, workflows.Pv77Qux) +} + +// RegisterPv77QuxWorkflow registers a test.patch.v1.Pv77QuxService.Pv77Qux workflow with the given worker +func RegisterPv77QuxWorkflow(r worker.WorkflowRegistry, wf func(workflow.Context, *Pv77QuxWorkflowInput) (Pv77QuxWorkflow, error)) { + Pv77QuxFunction = buildPv77Qux(wf) + r.RegisterWorkflowWithOptions(Pv77QuxFunction, workflow.RegisterOptions{Name: Pv77QuxWorkflowName}) +} + +// buildPv77Qux converts a Pv77Qux workflow struct into a valid workflow function +func buildPv77Qux(ctor func(workflow.Context, *Pv77QuxWorkflowInput) (Pv77QuxWorkflow, error)) func(workflow.Context, *Pv77QuxInput) (*Pv77QuxOutput, error) { + return func(ctx workflow.Context, req *Pv77QuxInput) (*Pv77QuxOutput, error) { + input := &Pv77QuxWorkflowInput{ + Req: req, + } + wf, err := ctor(ctx, input) + if err != nil { + return nil, err + } + if initializable, ok := wf.(helpers.Initializable); ok { + if err := initializable.Initialize(ctx); err != nil { + return nil, err + } + } + return wf.Execute(ctx) + } +} + +// Pv77QuxWorkflowInput describes the input to a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow constructor +type Pv77QuxWorkflowInput struct { + Req *Pv77QuxInput +} + +// Pv77QuxWorkflow describes a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow implementation +type Pv77QuxWorkflow interface { + // Execute defines the entrypoint to a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow + Execute(ctx workflow.Context) (*Pv77QuxOutput, error) +} + +// Pv77QuxChild executes a child test.patch.v1.Pv77QuxService.Pv77Qux workflow and blocks until error or response received +func Pv77QuxChild(ctx workflow.Context, req *Pv77QuxInput, options ...*Pv77QuxChildOptions) (*Pv77QuxOutput, error) { + childRun, err := Pv77QuxChildAsync(ctx, req, options...) + if err != nil { + return nil, err + } + return childRun.Get(ctx) +} + +// Pv77QuxChildAsync starts a child test.patch.v1.Pv77QuxService.Pv77Qux workflow and returns a handle to the child workflow run +func Pv77QuxChildAsync(ctx workflow.Context, req *Pv77QuxInput, options ...*Pv77QuxChildOptions) (*Pv77QuxChildRun, error) { + var o *Pv77QuxChildOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77QuxChildOptions() + } + opts, err := o.Build(ctx, req.ProtoReflect()) + if err != nil { + return nil, fmt.Errorf("error initializing workflow.ChildWorkflowOptions: %w", err) + } + ctx = workflow.WithChildOptions(ctx, opts) + return &Pv77QuxChildRun{Future: workflow.ExecuteChildWorkflow(ctx, Pv77QuxWorkflowName, req)}, nil +} + +// Pv77QuxChildOptions provides configuration for a child test.patch.v1.Pv77QuxService.Pv77Qux workflow operation +type Pv77QuxChildOptions struct { + options workflow.ChildWorkflowOptions + executionTimeout *time.Duration + id *string + idReusePolicy enumsv1.WorkflowIdReusePolicy + retryPolicy *temporal.RetryPolicy + runTimeout *time.Duration + searchAttributes map[string]any + taskQueue *string + taskTimeout *time.Duration + parentClosePolicy enumsv1.ParentClosePolicy + waitForCancellation *bool +} + +// NewPv77QuxChildOptions initializes a new Pv77QuxChildOptions value +func NewPv77QuxChildOptions() *Pv77QuxChildOptions { + return &Pv77QuxChildOptions{} +} + +// Build initializes a new go.temporal.io/sdk/workflow.ChildWorkflowOptions value with defaults and overrides applied +func (o *Pv77QuxChildOptions) Build(ctx workflow.Context, req protoreflect.Message) (workflow.ChildWorkflowOptions, error) { + opts := o.options + if v := o.id; v != nil { + opts.WorkflowID = *v + } + if v := o.idReusePolicy; v != enumsv1.WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED { + opts.WorkflowIDReusePolicy = v + } + if v := o.taskQueue; v != nil { + opts.TaskQueue = *v + } else if opts.TaskQueue == "" { + opts.TaskQueue = Pv77QuxServiceTaskQueue + } + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.searchAttributes; v != nil { + opts.SearchAttributes = o.searchAttributes + } + if v := o.executionTimeout; v != nil { + opts.WorkflowExecutionTimeout = *v + } + if v := o.runTimeout; v != nil { + opts.WorkflowRunTimeout = *v + } + if v := o.taskTimeout; v != nil { + opts.WorkflowTaskTimeout = *v + } + if v := o.parentClosePolicy; v != enumsv1.PARENT_CLOSE_POLICY_UNSPECIFIED { + opts.ParentClosePolicy = v + } + if v := o.waitForCancellation; v != nil { + opts.WaitForCancellation = *v + } + return opts, nil +} + +// WithChildWorkflowOptions sets the initial go.temporal.io/sdk/workflow.ChildWorkflowOptions +func (o *Pv77QuxChildOptions) WithChildWorkflowOptions(options workflow.ChildWorkflowOptions) *Pv77QuxChildOptions { + o.options = options + return o +} + +// WithExecutionTimeout sets the WorkflowExecutionTimeout value +func (o *Pv77QuxChildOptions) WithExecutionTimeout(d time.Duration) *Pv77QuxChildOptions { + o.executionTimeout = &d + return o +} + +// WithID sets the WorkflowID value +func (o *Pv77QuxChildOptions) WithID(id string) *Pv77QuxChildOptions { + o.id = &id + return o +} + +// WithIDReusePolicy sets the WorkflowIDReusePolicy value +func (o *Pv77QuxChildOptions) WithIDReusePolicy(policy enumsv1.WorkflowIdReusePolicy) *Pv77QuxChildOptions { + o.idReusePolicy = policy + return o +} + +// WithParentClosePolicy sets the WorkflowIDReusePolicy value +func (o *Pv77QuxChildOptions) WithParentClosePolicy(policy enumsv1.ParentClosePolicy) *Pv77QuxChildOptions { + o.parentClosePolicy = policy + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77QuxChildOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77QuxChildOptions { + o.retryPolicy = policy + return o +} + +// WithRunTimeout sets the WorkflowRunTimeout value +func (o *Pv77QuxChildOptions) WithRunTimeout(d time.Duration) *Pv77QuxChildOptions { + o.runTimeout = &d + return o +} + +// WithSearchAttributes sets the SearchAttributes value +func (o *Pv77QuxChildOptions) WithSearchAttributes(sa map[string]any) *Pv77QuxChildOptions { + o.searchAttributes = sa + return o +} + +// WithTaskTimeout sets the WorkflowTaskTimeout value +func (o *Pv77QuxChildOptions) WithTaskTimeout(d time.Duration) *Pv77QuxChildOptions { + o.taskTimeout = &d + return o +} + +// WithTaskQueue sets the TaskQueue value +func (o *Pv77QuxChildOptions) WithTaskQueue(tq string) *Pv77QuxChildOptions { + o.taskQueue = &tq + return o +} + +// WithWaitForCancellation sets the WaitForCancellation value +func (o *Pv77QuxChildOptions) WithWaitForCancellation(wait bool) *Pv77QuxChildOptions { + o.waitForCancellation = &wait + return o +} + +// Pv77QuxChildRun describes a child Pv77Qux workflow run +type Pv77QuxChildRun struct { + Future workflow.ChildWorkflowFuture +} + +// Get blocks until the workflow is completed, returning the response value +func (r *Pv77QuxChildRun) Get(ctx workflow.Context) (*Pv77QuxOutput, error) { + var resp Pv77QuxOutput + if err := r.Future.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// Select adds this completion to the selector. Callback can be nil. +func (r *Pv77QuxChildRun) Select(sel workflow.Selector, fn func(*Pv77QuxChildRun)) workflow.Selector { + return sel.AddFuture(r.Future, func(workflow.Future) { + if fn != nil { + fn(r) + } + }) +} + +// SelectStart adds waiting for start to the selector. Callback can be nil. +func (r *Pv77QuxChildRun) SelectStart(sel workflow.Selector, fn func(*Pv77QuxChildRun)) workflow.Selector { + return sel.AddFuture(r.Future.GetChildWorkflowExecution(), func(workflow.Future) { + if fn != nil { + fn(r) + } + }) +} + +// WaitStart waits for the child workflow to start +func (r *Pv77QuxChildRun) WaitStart(ctx workflow.Context) (*workflow.Execution, error) { + var exec workflow.Execution + if err := r.Future.GetChildWorkflowExecution().Get(ctx, &exec); err != nil { + return nil, err + } + return &exec, nil +} + +// Pv77QuxServiceActivities describes available worker activities +type Pv77QuxServiceActivities interface { + // test.patch.v1.Pv77QuxService.Pv77Qux implements a(n) test.patch.v1.Pv77QuxActivity activity definition + Pv77Qux(ctx context.Context, req *Pv77QuxInput) (*Pv77QuxOutput, error) +} + +// RegisterPv77QuxServiceActivities registers activities with a worker +func RegisterPv77QuxServiceActivities(r worker.ActivityRegistry, activities Pv77QuxServiceActivities) { + RegisterPv77QuxActivity(r, activities.Pv77Qux) +} + +// RegisterPv77QuxActivity registers a test.patch.v1.Pv77QuxActivity activity +func RegisterPv77QuxActivity(r worker.ActivityRegistry, fn func(context.Context, *Pv77QuxInput) (*Pv77QuxOutput, error)) { + r.RegisterActivityWithOptions(fn, activity.RegisterOptions{ + Name: Pv77QuxActivityName, + }) +} + +// Pv77QuxFuture describes a(n) test.patch.v1.Pv77QuxActivity activity execution +type Pv77QuxFuture struct { + Future workflow.Future +} + +// Get blocks on the activity's completion, returning the response +func (f *Pv77QuxFuture) Get(ctx workflow.Context) (*Pv77QuxOutput, error) { + var resp Pv77QuxOutput + if err := f.Future.Get(ctx, &resp); err != nil { + return nil, err + } + return &resp, nil +} + +// Select adds the activity's completion to the selector, callback can be nil +func (f *Pv77QuxFuture) Select(sel workflow.Selector, fn func(*Pv77QuxFuture)) workflow.Selector { + return sel.AddFuture(f.Future, func(workflow.Future) { + if fn != nil { + fn(f) + } + }) +} + +// Pv77Qux executes a(n) test.patch.v1.Pv77QuxActivity activity +func Pv77Qux(ctx workflow.Context, req *Pv77QuxInput, options ...*Pv77QuxActivityOptions) (*Pv77QuxOutput, error) { + return Pv77QuxAsync(ctx, req, options...).Get(ctx) +} + +// Pv77QuxAsync executes a(n) test.patch.v1.Pv77QuxActivity activity (asynchronously) +func Pv77QuxAsync(ctx workflow.Context, req *Pv77QuxInput, options ...*Pv77QuxActivityOptions) *Pv77QuxFuture { + var o *Pv77QuxActivityOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77QuxActivityOptions() + } + var err error + if ctx, err = o.Build(ctx); err != nil { + errF, errS := workflow.NewFuture(ctx) + errS.SetError(err) + return &Pv77QuxFuture{Future: errF} + } + activity := Pv77QuxActivityName + future := &Pv77QuxFuture{Future: workflow.ExecuteActivity(ctx, activity, req)} + return future +} + +// Pv77QuxLocal executes a(n) test.patch.v1.Pv77QuxActivity activity (locally) +func Pv77QuxLocal(ctx workflow.Context, req *Pv77QuxInput, options ...*Pv77QuxLocalActivityOptions) (*Pv77QuxOutput, error) { + return Pv77QuxLocalAsync(ctx, req, options...).Get(ctx) +} + +// Pv77QuxLocalAsync executes a(n) test.patch.v1.Pv77QuxActivity activity (asynchronously, locally) +func Pv77QuxLocalAsync(ctx workflow.Context, req *Pv77QuxInput, options ...*Pv77QuxLocalActivityOptions) *Pv77QuxFuture { + var o *Pv77QuxLocalActivityOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77QuxLocalActivityOptions() + } + var err error + if ctx, err = o.Build(ctx); err != nil { + errF, errS := workflow.NewFuture(ctx) + errS.SetError(err) + return &Pv77QuxFuture{Future: errF} + } + var activity any + if o.fn != nil { + activity = o.fn + } else { + activity = Pv77QuxActivityName + } + future := &Pv77QuxFuture{Future: workflow.ExecuteLocalActivity(ctx, activity, req)} + return future +} + +// Pv77QuxActivityOptions provides configuration for a(n) test.patch.v1.Pv77QuxActivity activity +type Pv77QuxActivityOptions struct { + options workflow.ActivityOptions + retryPolicy *temporal.RetryPolicy + scheduleToCloseTimeout *time.Duration + startToCloseTimeout *time.Duration + heartbeatTimeout *time.Duration + scheduleToStartTimeout *time.Duration + taskQueue *string + waitForCancellation *bool +} + +// NewPv77QuxActivityOptions initializes a new Pv77QuxActivityOptions value +func NewPv77QuxActivityOptions() *Pv77QuxActivityOptions { + return &Pv77QuxActivityOptions{} +} + +// Build initializes a workflow.Context with appropriate ActivityOptions values derived from schema defaults and any user-defined overrides +func (o *Pv77QuxActivityOptions) Build(ctx workflow.Context) (workflow.Context, error) { + opts := o.options + if v := o.heartbeatTimeout; v != nil { + opts.HeartbeatTimeout = *v + } + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.scheduleToCloseTimeout; v != nil { + opts.ScheduleToCloseTimeout = *v + } + if v := o.scheduleToStartTimeout; v != nil { + opts.ScheduleToStartTimeout = *v + } + if v := o.startToCloseTimeout; v != nil { + opts.StartToCloseTimeout = *v + } else if opts.StartToCloseTimeout == 0 { + opts.StartToCloseTimeout = 5000000000 // 5 seconds + } + if v := o.taskQueue; v != nil { + opts.TaskQueue = *v + } else if opts.TaskQueue == "" { + opts.TaskQueue = Pv77QuxServiceTaskQueue + } + if v := o.waitForCancellation; v != nil { + opts.WaitForCancellation = *v + } + return workflow.WithActivityOptions(ctx, opts), nil +} + +// WithActivityOptions specifies an initial ActivityOptions value to which defaults will be applied +func (o *Pv77QuxActivityOptions) WithActivityOptions(options workflow.ActivityOptions) *Pv77QuxActivityOptions { + o.options = options + return o +} + +// WithHeartbeatTimeout sets the HeartbeatTimeout value +func (o *Pv77QuxActivityOptions) WithHeartbeatTimeout(d time.Duration) *Pv77QuxActivityOptions { + o.heartbeatTimeout = &d + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77QuxActivityOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77QuxActivityOptions { + o.retryPolicy = policy + return o +} + +// WithScheduleToCloseTimeout sets the ScheduleToCloseTimeout value +func (o *Pv77QuxActivityOptions) WithScheduleToCloseTimeout(d time.Duration) *Pv77QuxActivityOptions { + o.scheduleToCloseTimeout = &d + return o +} + +// WithScheduleToStartTimeout sets the ScheduleToStartTimeout value +func (o *Pv77QuxActivityOptions) WithScheduleToStartTimeout(d time.Duration) *Pv77QuxActivityOptions { + o.scheduleToStartTimeout = &d + return o +} + +// WithStartToCloseTimeout sets the StartToCloseTimeout value +func (o *Pv77QuxActivityOptions) WithStartToCloseTimeout(d time.Duration) *Pv77QuxActivityOptions { + o.startToCloseTimeout = &d + return o +} + +// WithTaskQueue sets the TaskQueue value +func (o *Pv77QuxActivityOptions) WithTaskQueue(tq string) *Pv77QuxActivityOptions { + o.taskQueue = &tq + return o +} + +// WithWaitForCancellation sets the WaitForCancellation value +func (o *Pv77QuxActivityOptions) WithWaitForCancellation(wait bool) *Pv77QuxActivityOptions { + o.waitForCancellation = &wait + return o +} + +// Pv77QuxLocalActivityOptions provides configuration for a(n) test.patch.v1.Pv77QuxActivity activity +type Pv77QuxLocalActivityOptions struct { + options workflow.LocalActivityOptions + retryPolicy *temporal.RetryPolicy + scheduleToCloseTimeout *time.Duration + startToCloseTimeout *time.Duration + fn func(context.Context, *Pv77QuxInput) (*Pv77QuxOutput, error) +} + +// NewPv77QuxLocalActivityOptions initializes a new Pv77QuxLocalActivityOptions value +func NewPv77QuxLocalActivityOptions() *Pv77QuxLocalActivityOptions { + return &Pv77QuxLocalActivityOptions{} +} + +// Build initializes a workflow.Context with appropriate LocalActivityOptions values derived from schema defaults and any user-defined overrides +func (o *Pv77QuxLocalActivityOptions) Build(ctx workflow.Context) (workflow.Context, error) { + opts := o.options + if v := o.retryPolicy; v != nil { + opts.RetryPolicy = v + } + if v := o.scheduleToCloseTimeout; v != nil { + opts.ScheduleToCloseTimeout = *v + } + if v := o.startToCloseTimeout; v != nil { + opts.StartToCloseTimeout = *v + } else if opts.StartToCloseTimeout == 0 { + opts.StartToCloseTimeout = 5000000000 // 5 seconds + } + return workflow.WithLocalActivityOptions(ctx, opts), nil +} + +// Local specifies a custom test.patch.v1.Pv77QuxActivity implementation +func (o *Pv77QuxLocalActivityOptions) Local(fn func(context.Context, *Pv77QuxInput) (*Pv77QuxOutput, error)) *Pv77QuxLocalActivityOptions { + o.fn = fn + return o +} + +// WithLocalActivityOptions specifies an initial LocalActivityOptions value to which defaults will be applied +func (o *Pv77QuxLocalActivityOptions) WithLocalActivityOptions(options workflow.LocalActivityOptions) *Pv77QuxLocalActivityOptions { + o.options = options + return o +} + +// WithRetryPolicy sets the RetryPolicy value +func (o *Pv77QuxLocalActivityOptions) WithRetryPolicy(policy *temporal.RetryPolicy) *Pv77QuxLocalActivityOptions { + o.retryPolicy = policy + return o +} + +// WithScheduleToCloseTimeout sets the ScheduleToCloseTimeout value +func (o *Pv77QuxLocalActivityOptions) WithScheduleToCloseTimeout(d time.Duration) *Pv77QuxLocalActivityOptions { + o.scheduleToCloseTimeout = &d + return o +} + +// WithStartToCloseTimeout sets the StartToCloseTimeout value +func (o *Pv77QuxLocalActivityOptions) WithStartToCloseTimeout(d time.Duration) *Pv77QuxLocalActivityOptions { + o.startToCloseTimeout = &d + return o +} + +// TestClient provides a testsuite-compatible Client +type TestPv77QuxServiceClient struct { + env *testsuite.TestWorkflowEnvironment + workflows Pv77QuxServiceWorkflows +} + +var _ Pv77QuxServiceClient = &TestPv77QuxServiceClient{} + +// NewTestPv77QuxServiceClient initializes a new TestPv77QuxServiceClient value +func NewTestPv77QuxServiceClient(env *testsuite.TestWorkflowEnvironment, workflows Pv77QuxServiceWorkflows, activities Pv77QuxServiceActivities) *TestPv77QuxServiceClient { + if workflows != nil { + RegisterPv77QuxServiceWorkflows(env, workflows) + } + if activities != nil { + RegisterPv77QuxServiceActivities(env, activities) + } + return &TestPv77QuxServiceClient{env, workflows} +} + +// Pv77Qux executes a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow in the test environment +func (c *TestPv77QuxServiceClient) Pv77Qux(ctx context.Context, req *Pv77QuxInput, opts ...*Pv77QuxOptions) (*Pv77QuxOutput, error) { + run, err := c.Pv77QuxAsync(ctx, req, opts...) + if err != nil { + return nil, err + } + return run.Get(ctx) +} + +// Pv77QuxAsync executes a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow in the test environment +func (c *TestPv77QuxServiceClient) Pv77QuxAsync(ctx context.Context, req *Pv77QuxInput, options ...*Pv77QuxOptions) (Pv77QuxRun, error) { + var o *Pv77QuxOptions + if len(options) > 0 && options[0] != nil { + o = options[0] + } else { + o = NewPv77QuxOptions() + } + opts, err := o.Build(req.ProtoReflect()) + if err != nil { + return nil, fmt.Errorf("error initializing client.StartWorkflowOptions: %w", err) + } + return &testPv77QuxRun{client: c, env: c.env, opts: &opts, req: req, workflows: c.workflows}, nil +} + +// GetPv77Qux is a noop +func (c *TestPv77QuxServiceClient) GetPv77Qux(ctx context.Context, workflowID string, runID string) Pv77QuxRun { + return &testPv77QuxRun{env: c.env, workflows: c.workflows} +} + +// CancelWorkflow requests cancellation of an existing workflow execution +func (c *TestPv77QuxServiceClient) CancelWorkflow(ctx context.Context, workflowID string, runID string) error { + c.env.CancelWorkflow() + return nil +} + +// TerminateWorkflow terminates an existing workflow execution +func (c *TestPv77QuxServiceClient) TerminateWorkflow(ctx context.Context, workflowID string, runID string, reason string, details ...interface{}) error { + return c.CancelWorkflow(ctx, workflowID, runID) +} + +var _ Pv77QuxRun = &testPv77QuxRun{} + +// testPv77QuxRun provides convenience methods for interacting with a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow in the test environment +type testPv77QuxRun struct { + client *TestPv77QuxServiceClient + env *testsuite.TestWorkflowEnvironment + opts *client.StartWorkflowOptions + req *Pv77QuxInput + workflows Pv77QuxServiceWorkflows +} + +// Cancel requests cancellation of a workflow in execution, returning an error if applicable +func (r *testPv77QuxRun) Cancel(ctx context.Context) error { + return r.client.CancelWorkflow(ctx, r.ID(), r.RunID()) +} + +// Get retrieves a test test.patch.v1.Pv77QuxService.Pv77Qux workflow result +func (r *testPv77QuxRun) Get(context.Context) (*Pv77QuxOutput, error) { + r.env.ExecuteWorkflow(Pv77QuxWorkflowName, r.req) + if !r.env.IsWorkflowCompleted() { + return nil, errors.New("workflow in progress") + } + if err := r.env.GetWorkflowError(); err != nil { + return nil, err + } + var result Pv77QuxOutput + if err := r.env.GetWorkflowResult(&result); err != nil { + return nil, err + } + return &result, nil +} + +// ID returns a test test.patch.v1.Pv77QuxService.Pv77Qux workflow run's workflow ID +func (r *testPv77QuxRun) ID() string { + if r.opts != nil { + return r.opts.ID + } + return "" +} + +// Run noop implementation +func (r *testPv77QuxRun) Run() client.WorkflowRun { + return nil +} + +// RunID noop implementation +func (r *testPv77QuxRun) RunID() string { + return "" +} + +// Terminate terminates a workflow in execution, returning an error if applicable +func (r *testPv77QuxRun) Terminate(ctx context.Context, reason string, details ...interface{}) error { + return r.client.TerminateWorkflow(ctx, r.ID(), r.RunID(), reason, details...) +} + +// Pv77QuxServiceCliOptions describes runtime configuration for test.patch.v1.Pv77QuxService cli +type Pv77QuxServiceCliOptions struct { + after func(*v2.Context) error + before func(*v2.Context) error + clientForCommand func(*v2.Context) (client.Client, error) + worker func(*v2.Context, client.Client) (worker.Worker, error) +} + +// NewPv77QuxServiceCliOptions initializes a new Pv77QuxServiceCliOptions value +func NewPv77QuxServiceCliOptions() *Pv77QuxServiceCliOptions { + return &Pv77QuxServiceCliOptions{} +} + +// WithAfter injects a custom After hook to be run after any command invocation +func (opts *Pv77QuxServiceCliOptions) WithAfter(fn func(*v2.Context) error) *Pv77QuxServiceCliOptions { + opts.after = fn + return opts +} + +// WithBefore injects a custom Before hook to be run prior to any command invocation +func (opts *Pv77QuxServiceCliOptions) WithBefore(fn func(*v2.Context) error) *Pv77QuxServiceCliOptions { + opts.before = fn + return opts +} + +// WithClient provides a Temporal client factory for use by commands +func (opts *Pv77QuxServiceCliOptions) WithClient(fn func(*v2.Context) (client.Client, error)) *Pv77QuxServiceCliOptions { + opts.clientForCommand = fn + return opts +} + +// WithWorker provides an method for initializing a worker +func (opts *Pv77QuxServiceCliOptions) WithWorker(fn func(*v2.Context, client.Client) (worker.Worker, error)) *Pv77QuxServiceCliOptions { + opts.worker = fn + return opts +} + +// NewPv77QuxServiceCli initializes a cli for a(n) test.patch.v1.Pv77QuxService service +func NewPv77QuxServiceCli(options ...*Pv77QuxServiceCliOptions) (*v2.App, error) { + commands, err := newPv77QuxServiceCommands(options...) + if err != nil { + return nil, fmt.Errorf("error initializing subcommands: %w", err) + } + return &v2.App{ + Name: "pv-77-qux-service", + Commands: commands, + }, nil +} + +// NewPv77QuxServiceCliCommand initializes a cli command for a test.patch.v1.Pv77QuxService service with subcommands for each query, signal, update, and workflow +func NewPv77QuxServiceCliCommand(options ...*Pv77QuxServiceCliOptions) (*v2.Command, error) { + subcommands, err := newPv77QuxServiceCommands(options...) + if err != nil { + return nil, fmt.Errorf("error initializing subcommands: %w", err) + } + return &v2.Command{ + Name: "pv-77-qux-service", + Subcommands: subcommands, + }, nil +} + +// newPv77QuxServiceCommands initializes (sub)commands for a test.patch.v1.Pv77QuxService cli or command +func newPv77QuxServiceCommands(options ...*Pv77QuxServiceCliOptions) ([]*v2.Command, error) { + opts := &Pv77QuxServiceCliOptions{} + if len(options) > 0 { + opts = options[0] + } + if opts.clientForCommand == nil { + opts.clientForCommand = func(*v2.Context) (client.Client, error) { + return client.Dial(client.Options{}) + } + } + commands := []*v2.Command{ + { + Name: "pv-77-qux", + Usage: "executes a(n) test.patch.v1.Pv77QuxService.Pv77Qux workflow", + Category: "WORKFLOWS", + UseShortOptionHandling: true, + Before: opts.before, + After: opts.after, + Flags: []v2.Flag{ + &v2.BoolFlag{ + Name: "detach", + Usage: "run workflow in the background and print workflow and execution id", + Aliases: []string{"d"}, + }, + &v2.StringFlag{ + Name: "task-queue", + Usage: "task queue name", + Aliases: []string{"t"}, + EnvVars: []string{"TEMPORAL_TASK_QUEUE_NAME", "TEMPORAL_TASK_QUEUE", "TASK_QUEUE_NAME", "TASK_QUEUE"}, + Value: "pv77-v2", + }, + &v2.StringFlag{ + Name: "input-file", + Usage: "path to json-formatted input file", + Aliases: []string{"f"}, + }, + &v2.StringSliceFlag{ + Name: "next", + Usage: "set the value of the operation's \"Next\" parameter", + Category: "INPUT", + }, + }, + Action: func(cmd *v2.Context) error { + tc, err := opts.clientForCommand(cmd) + if err != nil { + return fmt.Errorf("error initializing client for command: %w", err) + } + defer tc.Close() + c := NewPv77QuxServiceClient(tc) + req, err := UnmarshalCliFlagsToPv77QuxInput(cmd) + if err != nil { + return fmt.Errorf("error unmarshalling request: %w", err) + } + opts := client.StartWorkflowOptions{} + if tq := cmd.String("task-queue"); tq != "" { + opts.TaskQueue = tq + } + run, err := c.Pv77QuxAsync(cmd.Context, req, NewPv77QuxOptions().WithStartWorkflowOptions(opts)) + if err != nil { + return fmt.Errorf("error starting %s workflow: %w", Pv77QuxWorkflowName, err) + } + if cmd.Bool("detach") { + fmt.Println("success") + fmt.Printf("workflow id: %s\n", run.ID()) + fmt.Printf("run id: %s\n", run.RunID()) + return nil + } + if resp, err := run.Get(cmd.Context); err != nil { + return err + } else { + b, err := protojson.Marshal(resp) + if err != nil { + return fmt.Errorf("error serializing response json: %w", err) + } + var out bytes.Buffer + if err := json.Indent(&out, b, "", " "); err != nil { + return fmt.Errorf("error formatting json: %w", err) + } + fmt.Println(out.String()) + return nil + } + }, + }, + } + if opts.worker != nil { + commands = append(commands, []*v2.Command{ + { + Name: "worker", + Usage: "runs a test.patch.v1.Pv77QuxService worker process", + UseShortOptionHandling: true, + Before: opts.before, + After: opts.after, + Action: func(cmd *v2.Context) error { + c, err := opts.clientForCommand(cmd) + if err != nil { + return fmt.Errorf("error initializing client for command: %w", err) + } + defer c.Close() + w, err := opts.worker(cmd, c) + if opts.worker != nil { + if err != nil { + return fmt.Errorf("error initializing worker: %w", err) + } + } + if err := w.Start(); err != nil { + return fmt.Errorf("error starting worker: %w", err) + } + defer w.Stop() + <-cmd.Context.Done() + return nil + }, + }, + }...) + } + sort.Slice(commands, func(i, j int) bool { + return commands[i].Name < commands[j].Name + }) + return commands, nil +} + +// UnmarshalCliFlagsToPv77QuxInput unmarshals a Pv77QuxInput from command line flags +func UnmarshalCliFlagsToPv77QuxInput(cmd *v2.Context) (*Pv77QuxInput, error) { + var result Pv77QuxInput + var hasValues bool + if cmd.IsSet("input-file") { + inputFile, err := gohomedir.Expand(cmd.String("input-file")) + if err != nil { + inputFile = cmd.String("input-file") + } + b, err := os.ReadFile(inputFile) + if err != nil { + return nil, fmt.Errorf("error reading input-file: %w", err) + } + if err := protojson.Unmarshal(b, &result); err != nil { + return nil, fmt.Errorf("error parsing input-file json: %w", err) + } + hasValues = true + } + if cmd.IsSet("next") { + hasValues = true + var tmp Pv77QuxInput + if err := protojson.Unmarshal([]byte(fmt.Sprintf("{\"next\":%s}", cmd.String("next"))), &tmp); err != nil { + return nil, fmt.Errorf("error unmarshalling \"next\" map flag: %w", err) + } + result.Next = tmp.Next + } + if !hasValues { + return nil, nil + } + return &result, nil +} + +// WithPv77QuxServiceSchemeTypes registers all Pv77QuxService protobuf types with the given scheme +func WithPv77QuxServiceSchemeTypes() scheme.Option { + return func(s *scheme.Scheme) { + s.RegisterType(File_test_patch_v1_pv77_proto.Messages().ByName("Pv77QuxInput")) + s.RegisterType(File_test_patch_v1_pv77_proto.Messages().ByName("Pv77QuxOutput")) + s.RegisterType(File_test_patch_v1_pv77_proto.Messages().ByName("Pv77QuxOutput").Messages().ByName("DefaultsEntry")) + } +} diff --git a/gen/test/simple/v1/simple_temporal.pb.go b/gen/test/simple/v1/simple_temporal.pb.go index 518d54c4..0cfb4835 100644 --- a/gen/test/simple/v1/simple_temporal.pb.go +++ b/gen/test/simple/v1/simple_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // @@ -18,6 +18,7 @@ import ( v1 "github.com/cludden/protoc-gen-go-temporal/gen/test/simple/common/v1" expression "github.com/cludden/protoc-gen-go-temporal/pkg/expression" helpers "github.com/cludden/protoc-gen-go-temporal/pkg/helpers" + patch "github.com/cludden/protoc-gen-go-temporal/pkg/patch" scheme "github.com/cludden/protoc-gen-go-temporal/pkg/scheme" testutil "github.com/cludden/protoc-gen-go-temporal/pkg/testutil" gohomedir "github.com/mitchellh/go-homedir" @@ -1576,6 +1577,8 @@ func buildSomeWorkflow1(ctor func(workflow.Context, *SomeWorkflow1WorkflowInput) Channel: workflow.GetSignalChannel(ctx, SomeSignal2SignalName), }, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, SimpleTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return nil, err @@ -1695,7 +1698,15 @@ func (o *SomeWorkflow1ChildOptions) Build(ctx workflow.Context, req protoreflect if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = SimpleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, SimpleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = SimpleTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -1862,6 +1873,8 @@ func buildSomeWorkflow2(ctor func(workflow.Context, *SomeWorkflow2WorkflowInput) Channel: workflow.GetSignalChannel(ctx, SomeSignal1SignalName), }, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, SimpleTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return err @@ -1969,7 +1982,15 @@ func (o *SomeWorkflow2ChildOptions) Build(ctx workflow.Context, req protoreflect if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = SimpleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, SimpleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = SimpleTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -2126,6 +2147,8 @@ func buildSomeWorkflow3(ctor func(workflow.Context, *SomeWorkflow3WorkflowInput) Channel: workflow.GetSignalChannel(ctx, SomeSignal2SignalName), }, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, "my-task-queue-2", workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return err @@ -2223,7 +2246,15 @@ func (o *SomeWorkflow3ChildOptions) Build(ctx workflow.Context, req protoreflect if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = "my-task-queue-2" + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, "my-task-queue-2"); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = "my-task-queue-2" + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -2383,6 +2414,8 @@ func buildSomeWorkflow4(ctor func(workflow.Context, *SomeWorkflow4WorkflowInput) input := &SomeWorkflow4WorkflowInput{ Req: req, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, SimpleTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return nil, err @@ -2488,7 +2521,15 @@ func (o *SomeWorkflow4ChildOptions) Build(ctx workflow.Context, req protoreflect if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = SimpleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, SimpleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = SimpleTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -2944,7 +2985,15 @@ func (o *SomeActivity1ActivityOptions) Build(ctx workflow.Context) (workflow.Con if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = SimpleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, SimpleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = SimpleTaskQueue + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v @@ -3180,7 +3229,15 @@ func (o *SomeActivity2ActivityOptions) Build(ctx workflow.Context) (workflow.Con if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = SimpleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, SimpleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = SimpleTaskQueue + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v @@ -3426,7 +3483,15 @@ func (o *SomeActivity3ActivityOptions) Build(ctx workflow.Context) (workflow.Con if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = "some-other-task-queue" + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, "some-other-task-queue"); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = "some-other-task-queue" + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v @@ -3672,7 +3737,15 @@ func (o *SomeActivity4ActivityOptions) Build(ctx workflow.Context) (workflow.Con if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = "some-other-task-queue" + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, "some-other-task-queue"); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = "some-other-task-queue" + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v @@ -3914,7 +3987,15 @@ func (o *SomeSignal1ActivityOptions) Build(ctx workflow.Context) (workflow.Conte if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = SimpleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, SimpleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = SimpleTaskQueue + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v @@ -4150,7 +4231,15 @@ func (o *SomeSignal2ActivityOptions) Build(ctx workflow.Context) (workflow.Conte if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = SimpleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, SimpleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = SimpleTaskQueue + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v @@ -4390,7 +4479,15 @@ func (o *SomeSignal3ActivityOptions) Build(ctx workflow.Context) (workflow.Conte if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = SimpleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, SimpleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = SimpleTaskQueue + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v @@ -4634,7 +4731,15 @@ func (o *SomeUpdate1ActivityOptions) Build(ctx workflow.Context) (workflow.Conte if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = SimpleTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, SimpleTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = SimpleTaskQueue + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v @@ -6943,6 +7048,8 @@ func buildOtherWorkflow(ctor func(workflow.Context, *OtherWorkflowWorkflowInput) input := &OtherWorkflowWorkflowInput{ Req: req, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, OtherTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return nil, err @@ -7039,7 +7146,15 @@ func (o *OtherWorkflowChildOptions) Build(ctx workflow.Context, req protoreflect if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = OtherTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, OtherTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = OtherTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -7364,7 +7479,15 @@ func (o *OtherWorkflowActivityOptions) Build(ctx workflow.Context) (workflow.Con if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = OtherTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, OtherTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = OtherTaskQueue + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v @@ -8787,7 +8910,12 @@ func (o *WhatChildOptions) Build(ctx workflow.Context, req protoreflect.Message) if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = workflow.GetInfo(ctx).TaskQueueName + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + } else { + opts.TaskQueue = workflow.GetInfo(ctx).TaskQueueName + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -9286,7 +9414,12 @@ func (o *LonelyActivity1ActivityOptions) Build(ctx workflow.Context) (workflow.C if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = workflow.GetInfo(ctx).TaskQueueName + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + } else { + opts.TaskQueue = workflow.GetInfo(ctx).TaskQueueName + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v @@ -10974,7 +11107,12 @@ func (o *SomeDeprecatedWorkflow1ChildOptions) Build(ctx workflow.Context, req pr if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = workflow.GetInfo(ctx).TaskQueueName + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + } else { + opts.TaskQueue = workflow.GetInfo(ctx).TaskQueueName + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -11243,7 +11381,12 @@ func (o *SomeDeprecatedWorkflow2ChildOptions) Build(ctx workflow.Context, req pr if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = workflow.GetInfo(ctx).TaskQueueName + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + } else { + opts.TaskQueue = workflow.GetInfo(ctx).TaskQueueName + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -11664,7 +11807,12 @@ func (o *SomeDeprecatedActivity1ActivityOptions) Build(ctx workflow.Context) (wo if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = workflow.GetInfo(ctx).TaskQueueName + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + } else { + opts.TaskQueue = workflow.GetInfo(ctx).TaskQueueName + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v @@ -11916,7 +12064,12 @@ func (o *SomeDeprecatedActivity2ActivityOptions) Build(ctx workflow.Context) (wo if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = workflow.GetInfo(ctx).TaskQueueName + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + } else { + opts.TaskQueue = workflow.GetInfo(ctx).TaskQueueName + } } if v := o.waitForCancellation; v != nil { opts.WaitForCancellation = *v diff --git a/gen/test/simple/v1/v1xns/simple_xns_temporal.pb.go b/gen/test/simple/v1/v1xns/simple_xns_temporal.pb.go index f92b52f9..dc1f34fa 100644 --- a/gen/test/simple/v1/v1xns/simple_xns_temporal.pb.go +++ b/gen/test/simple/v1/v1xns/simple_xns_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // diff --git a/gen/test/xnserr/v1/xnserr_temporal.pb.go b/gen/test/xnserr/v1/xnserr_temporal.pb.go index 298f44fe..b03a06d8 100644 --- a/gen/test/xnserr/v1/xnserr_temporal.pb.go +++ b/gen/test/xnserr/v1/xnserr_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // @@ -14,6 +14,7 @@ import ( "fmt" xnsv1 "github.com/cludden/protoc-gen-go-temporal/gen/temporal/xns/v1" helpers "github.com/cludden/protoc-gen-go-temporal/pkg/helpers" + patch "github.com/cludden/protoc-gen-go-temporal/pkg/patch" scheme "github.com/cludden/protoc-gen-go-temporal/pkg/scheme" gohomedir "github.com/mitchellh/go-homedir" v2 "github.com/urfave/cli/v2" @@ -390,6 +391,8 @@ func buildSleep(ctor func(workflow.Context, *SleepWorkflowInput) (SleepWorkflow, input := &SleepWorkflowInput{ Req: req, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, ServerTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return err @@ -473,7 +476,15 @@ func (o *SleepChildOptions) Build(ctx workflow.Context, req protoreflect.Message if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = ServerTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, ServerTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = ServerTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v @@ -1304,6 +1315,8 @@ func buildCallSleep(ctor func(workflow.Context, *CallSleepWorkflowInput) (CallSl input := &CallSleepWorkflowInput{ Req: req, } + // inject default task queue and override into workflow context + ctx = patch.WithDefaultTaskQueue(workflow.WithValue, ctx, ClientTaskQueue, workflow.GetInfo(ctx).TaskQueueName) wf, err := ctor(ctx, input) if err != nil { return err @@ -1385,7 +1398,15 @@ func (o *CallSleepChildOptions) Build(ctx workflow.Context, req protoreflect.Mes if v := o.taskQueue; v != nil { opts.TaskQueue = *v } else if opts.TaskQueue == "" { - opts.TaskQueue = ClientTaskQueue + // use parent workflow task queue for child workflows and activities + // more info: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue + if workflow.GetVersion(ctx, "cludden_protoc-gen-go-temporal_77_use-parent-task-queue", workflow.DefaultVersion, 1) == 1 { + if tq := patch.DefaultTaskQueue(ctx, ClientTaskQueue); tq != "" && tq != workflow.GetInfo(ctx).TaskQueueName { + opts.TaskQueue = tq + } + } else { + opts.TaskQueue = ClientTaskQueue + } } if v := o.retryPolicy; v != nil { opts.RetryPolicy = v diff --git a/gen/test/xnserr/v1/xnserrv1xns/xnserr_xns_temporal.pb.go b/gen/test/xnserr/v1/xnserrv1xns/xnserr_xns_temporal.pb.go index 8bd6dd0f..c31d18c2 100644 --- a/gen/test/xnserr/v1/xnserrv1xns/xnserr_xns_temporal.pb.go +++ b/gen/test/xnserr/v1/xnserrv1xns/xnserr_xns_temporal.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go_temporal. DO NOT EDIT. // versions: // -// protoc-gen-go_temporal 1.14.3-next (974fdc3d78b6359d0e967899ac581d33b6a0bc71) +// protoc-gen-go_temporal 1.14.4-next (e82835bad5227fc67a146f370ba42ab3f41c10cf) // go go1.22.2 // protoc (unknown) // diff --git a/internal/plugin/activities.go b/internal/plugin/activities.go index 9d848906..ec3a1388 100644 --- a/internal/plugin/activities.go +++ b/internal/plugin/activities.go @@ -6,6 +6,7 @@ import ( "strconv" "strings" + temporalv1 "github.com/cludden/protoc-gen-go-temporal/gen/temporal/v1" g "github.com/dave/jennifer/jen" "github.com/hako/durafmt" "google.golang.org/protobuf/reflect/protoreflect" @@ -476,25 +477,59 @@ func (svc *Manifest) genActivityOptions(f *g.File, activity protoreflect.FullNam // set TaskQueue if !local { - fn.If(g.Id("v").Op(":=").Id("o").Dot("taskQueue"), g.Id("v").Op("!=").Nil()). + var defaultTaskQueue g.Code + if tq := opts.GetTaskQueue(); tq != "" { + defaultTaskQueue = g.Lit(tq) + } else if tq := svc.opts.GetTaskQueue(); tq != "" { + defaultTaskQueue = g.Id(svc.toCamel("%sTaskQueue", svc.GoName)) + } + origFn := func(b *g.Group) { + if defaultTaskQueue != nil { + b.Id("opts").Dot("TaskQueue").Op("=").Add(defaultTaskQueue) + } else { + b.Id("opts").Dot("TaskQueue").Op("=").Qual(workflowPkg, "GetInfo").Call(g.Id("ctx")).Dot("TaskQueueName") + } + } + fixFn := func(b *g.Group) { + if defaultTaskQueue != nil { + b. + IfFunc(func(b *g.Group) { + b.Id("tq").Op(":=").Qual(patchPkg, "DefaultTaskQueue").Call(g.Id("ctx"), defaultTaskQueue) + b.Id("tq").Op("!=").Lit("").Op("&&").Id("tq").Op("!=").Qual(workflowPkg, "GetInfo").Call(g.Id("ctx")).Dot("TaskQueueName") + }). + BlockFunc(func(b *g.Group) { + b.Id("opts").Dot("TaskQueue").Op("=").Id("tq") + }) + } + } + + fn. + If(g.Id("v").Op(":=").Id("o").Dot("taskQueue"), g.Id("v").Op("!=").Nil()). Block( g.Id("opts").Dot("TaskQueue").Op("=").Op("*").Id("v"), - ).Else(). - If(g.Id("opts").Dot("TaskQueue").Op("==").Lit("")). + ). + Else().If(g.Id("opts").Dot("TaskQueue").Op("==").Lit("")). BlockFunc(func(bl *g.Group) { - var taskQueue g.Code - if tq := opts.GetTaskQueue(); tq != "" { - taskQueue = g.Lit(tq) - } - if tq := svc.opts.GetTaskQueue(); taskQueue == nil && tq != "" { - taskQueue = g.Id(svc.toCamel("%sTaskQueue", svc.GoName)) - } - if taskQueue != nil { - bl.Id("opts").Dot("TaskQueue").Op("=").Add(taskQueue) - } else { - bl.Id("opts").Dot("TaskQueue").Op("=").Qual(workflowPkg, "GetInfo").Call(g.Id("ctx")).Dot("TaskQueueName") + switch pvm := svc.patchMode(temporalv1.Patch_PV_77, activity); pvm { + case temporalv1.Patch_PVM_DISABLED: + origFn(bl) + case temporalv1.Patch_PVM_ENABLED: + patchComment(bl, temporalv1.Patch_PV_77) + bl. + If(g.Add(patchVersion(temporalv1.Patch_PV_77, pvm)).Op("==").Lit(1)). + BlockFunc(fixFn). + Else(). + BlockFunc(origFn) + case temporalv1.Patch_PVM_MARKER: + patchComment(bl, temporalv1.Patch_PV_77) + patchVersion(temporalv1.Patch_PV_77, pvm) + fixFn(bl) + case temporalv1.Patch_PVM_REMOVED: + patchComment(bl, temporalv1.Patch_PV_77) + fixFn(bl) } }) + } // set WaitForCancellation diff --git a/internal/plugin/client.go b/internal/plugin/client.go index 8ee4047f..c672e727 100644 --- a/internal/plugin/client.go +++ b/internal/plugin/client.go @@ -1468,23 +1468,60 @@ func (svc *Manifest) genWorkflowOptions(f *g.File, workflow protoreflect.FullNam } // set TaskQueue - fn.If(g.Id("v").Op(":=").Id("o").Dot("taskQueue"), g.Id("v").Op("!=").Nil()).Block( - g.Id("opts").Dot("TaskQueue").Op("=").Op("*").Id("v"), - ).Else().If(g.Id("opts").Dot("TaskQueue").Op("==").Lit("")).BlockFunc(func(bl *g.Group) { - var taskQueueVar g.Code + { + var defaultTaskQueue g.Code if tq := opts.GetTaskQueue(); tq != "" { - taskQueueVar = g.Lit(tq) + defaultTaskQueue = g.Lit(tq) } else if tq = svc.opts.GetTaskQueue(); tq != "" { - taskQueueVar = g.Id(svc.toCamel("%sTaskQueue", svc.Service.GoName)) + defaultTaskQueue = g.Id(svc.toCamel("%sTaskQueue", svc.Service.GoName)) } - if taskQueueVar != nil { - bl.Id("opts").Dot("TaskQueue").Op("=").Add(taskQueueVar) - } else if child { - bl.Id("opts").Dot("TaskQueue").Op("=").Qual(workflowPkg, "GetInfo").Call(g.Id("ctx")).Dot("TaskQueueName") - } else { - bl.Return(g.Id("opts"), g.Qual("errors", "New").Call(g.Lit("TaskQueue is required"))) + origFn := func(b *g.Group) { + if defaultTaskQueue != nil { // use default if defined + b.Id("opts").Dot("TaskQueue").Op("=").Add(defaultTaskQueue) + } else if child { // otherwise, fallback to parent if child + b.Id("opts").Dot("TaskQueue").Op("=").Qual(workflowPkg, "GetInfo").Call(g.Id("ctx")).Dot("TaskQueueName") + } else { // otherwise error + b.Return(g.Id("opts"), g.Qual("errors", "New").Call(g.Lit("TaskQueue is required"))) + } } - }) + fixFn := func(b *g.Group) { + if defaultTaskQueue != nil { + b. + IfFunc(func(b *g.Group) { + b.Id("tq").Op(":=").Qual(patchPkg, "DefaultTaskQueue").Call(g.Id("ctx"), defaultTaskQueue) + b.Id("tq").Op("!=").Lit("").Op("&&").Id("tq").Op("!=").Qual(workflowPkg, "GetInfo").Call(g.Id("ctx")).Dot("TaskQueueName") + }). + BlockFunc(func(b *g.Group) { + b.Id("opts").Dot("TaskQueue").Op("=").Id("tq") + }) + } + } + + fn. + If(g.Id("v").Op(":=").Id("o").Dot("taskQueue"), g.Id("v").Op("!=").Nil()). + Block( + g.Id("opts").Dot("TaskQueue").Op("=").Op("*").Id("v"), + ).Else().If(g.Id("opts").Dot("TaskQueue").Op("==").Lit("")).BlockFunc(func(b *g.Group) { + switch pvm := svc.patchMode(temporalv1.Patch_PV_77, workflow); true { + case !child || pvm == temporalv1.Patch_PVM_DISABLED: + origFn(b) + case pvm == temporalv1.Patch_PVM_ENABLED: + patchComment(b, temporalv1.Patch_PV_77) + b. + If(g.Add(patchVersion(temporalv1.Patch_PV_77, pvm)).Op("==").Lit(1)). + BlockFunc(fixFn). + Else(). + BlockFunc(origFn) + case pvm == temporalv1.Patch_PVM_MARKER: + patchComment(b, temporalv1.Patch_PV_77) + patchVersion(temporalv1.Patch_PV_77, pvm) + fixFn(b) + case pvm == temporalv1.Patch_PVM_REMOVED: + patchComment(b, temporalv1.Patch_PV_77) + fixFn(b) + } + }) + } // set RetryPolicy retryPolicy := fn.If(g.Id("v").Op(":=").Id("o").Dot("retryPolicy"), g.Id("v").Op("!=").Nil()).Block( diff --git a/internal/plugin/parse.go b/internal/plugin/parse.go index 3b5d7c98..96812171 100644 --- a/internal/plugin/parse.go +++ b/internal/plugin/parse.go @@ -26,6 +26,7 @@ const ( enumsPkg = "go.temporal.io/api/enums/v1" expressionPkg = "github.com/cludden/protoc-gen-go-temporal/pkg/expression" helpersPkg = "github.com/cludden/protoc-gen-go-temporal/pkg/helpers" + patchPkg = "github.com/cludden/protoc-gen-go-temporal/pkg/patch" protoreflectPkg = "google.golang.org/protobuf/reflect/protoreflect" serviceerrorPkg = "go.temporal.io/api/serviceerror" temporalPkg = "go.temporal.io/sdk/temporal" diff --git a/internal/plugin/patch.go b/internal/plugin/patch.go index daa96303..5b0ff966 100644 --- a/internal/plugin/patch.go +++ b/internal/plugin/patch.go @@ -23,6 +23,11 @@ var patches = map[temporalv1.Patch_Version]patchDetail{ comment: "wrap expression evaluation in local activity", link: "https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_64-expression-evaluation-local-activity", }, + temporalv1.Patch_PV_77: { + id: patch.PV_77_UseParentTaskQueue, + comment: "use parent workflow task queue for child workflows and activities", + link: "https://cludden.github.io/protoc-gen-go-temporal/docs/guides/patches#pv_77-use-parent-task-queue", + }, } func patchComment(b *g.Group, pv temporalv1.Patch_Version) { diff --git a/internal/plugin/worker.go b/internal/plugin/worker.go index ffb90356..d11253ee 100644 --- a/internal/plugin/worker.go +++ b/internal/plugin/worker.go @@ -5,6 +5,7 @@ import ( "sort" "strings" + temporalv1 "github.com/cludden/protoc-gen-go-temporal/gen/temporal/v1" g "github.com/dave/jennifer/jen" "google.golang.org/protobuf/reflect/protoreflect" ) @@ -55,7 +56,7 @@ func (svc *Manifest) genWorkerBuilderFunction(f *g.File, workflow protoreflect.F ). Block( g.Return( - //g.Parens(g.Op("&").Id(workerName).Values(g.Id("wf"))).Dot(method.GoName), + // g.Parens(g.Op("&").Id(workerName).Values(g.Id("wf"))).Dot(method.GoName), // generate method for worker struct g.Func(). ParamsFunc(func(args *g.Group) { @@ -90,6 +91,20 @@ func (svc *Manifest) genWorkerBuilderFunction(f *g.File, workflow protoreflect.F } }) + if pvm := svc.patchMode(temporalv1.Patch_PV_77, workflow); pvm != temporalv1.Patch_PVM_DISABLED { + var taskQueueVar g.Code + if tq := opts.GetTaskQueue(); tq != "" { + taskQueueVar = g.Lit(tq) + } + if taskQueueVar == nil && svc.opts.GetTaskQueue() != "" { + taskQueueVar = g.Id(svc.toCamel("%sTaskQueue", svc.GoName)) + } + if taskQueueVar != nil { + fn.Comment("inject default task queue and override into workflow context") + fn.Id("ctx").Op("=").Qual(patchPkg, "WithDefaultTaskQueue").Call(g.Qual(workflowPkg, "WithValue"), g.Id("ctx"), taskQueueVar, g.Qual(workflowPkg, "GetInfo").Call(g.Id("ctx")).Dot("TaskQueueName")) + } + } + // call constructor to get workflow implementation fn.List(g.Id("wf"), g.Err()).Op(":=").Id("ctor").Call( g.Id("ctx"), g.Id("input"), diff --git a/justfile b/justfile index e6207c1e..9afbb197 100644 --- a/justfile +++ b/justfile @@ -48,12 +48,24 @@ install: goreleaser build --clean --single-target --snapshot if [ "{{ os() }}" = "macos" ]; then if [ "{{ arch() }}" = "aarch64" ]; then - sudo cp ./dist/protoc-gen-go_temporal_darwin_arm64/protoc-gen-go_temporal /usr/local/bin + if [ -w /usr/local/bin ]; then + cp ./dist/protoc-gen-go_temporal_darwin_arm64/protoc-gen-go_temporal /usr/local/bin/ + else + sudo cp ./dist/protoc-gen-go_temporal_darwin_arm64/protoc-gen-go_temporal /usr/local/bin/ + fi else - sudo cp ./dist/protoc-gen-go_temporal_darwin_amd64_v1/protoc-gen-go_temporal /usr/local/bin/ + if [ -w /usr/local/bin ]; then + cp ./dist/protoc-gen-go_temporal_darwin_amd64_v1/protoc-gen-go_temporal /usr/local/bin/ + else + sudo cp ./dist/protoc-gen-go_temporal_darwin_amd64_v1/protoc-gen-go_temporal /usr/local/bin/ + fi fi else - sudo cp ./dist/protoc-gen-go_temporal_linux_amd64_v1/protoc-gen-go_temporal /usr/local/bin/ + if [ -w /usr/local/bin ]; then + cp ./dist/protoc-gen-go_temporal_linux_amd64_v1/protoc-gen-go_temporal /usr/local/bin/ + else + sudo cp ./dist/protoc-gen-go_temporal_linux_amd64_v1/protoc-gen-go_temporal /usr/local/bin/ + fi fi # launch local temporal server diff --git a/mocks/github.com/cludden/protoc-gen-go-temporal/gen/example/v1/mock_CreateFooRun.go b/mocks/github.com/cludden/protoc-gen-go-temporal/gen/example/v1/mock_CreateFooRun.go index e8b48111..6afadbee 100644 --- a/mocks/github.com/cludden/protoc-gen-go-temporal/gen/example/v1/mock_CreateFooRun.go +++ b/mocks/github.com/cludden/protoc-gen-go-temporal/gen/example/v1/mock_CreateFooRun.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.44.2. DO NOT EDIT. package examplev1 diff --git a/mocks/github.com/cludden/protoc-gen-go-temporal/gen/example/v1/mock_ExampleClient.go b/mocks/github.com/cludden/protoc-gen-go-temporal/gen/example/v1/mock_ExampleClient.go index ca94b1ac..52c60aac 100644 --- a/mocks/github.com/cludden/protoc-gen-go-temporal/gen/example/v1/mock_ExampleClient.go +++ b/mocks/github.com/cludden/protoc-gen-go-temporal/gen/example/v1/mock_ExampleClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.44.2. DO NOT EDIT. package examplev1 diff --git a/mocks/github.com/cludden/protoc-gen-go-temporal/gen/example/v1/mock_UpdateFooProgressHandle.go b/mocks/github.com/cludden/protoc-gen-go-temporal/gen/example/v1/mock_UpdateFooProgressHandle.go index aa874a75..5dbad20a 100644 --- a/mocks/github.com/cludden/protoc-gen-go-temporal/gen/example/v1/mock_UpdateFooProgressHandle.go +++ b/mocks/github.com/cludden/protoc-gen-go-temporal/gen/example/v1/mock_UpdateFooProgressHandle.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.44.2. DO NOT EDIT. package examplev1 diff --git a/mocks/github.com/cludden/protoc-gen-go-temporal/gen/test/simple/v1/mock_SimpleWorkflowFunctions.go b/mocks/github.com/cludden/protoc-gen-go-temporal/gen/test/simple/v1/mock_SimpleWorkflowFunctions.go index 33af9d9a..ad0d47b0 100644 --- a/mocks/github.com/cludden/protoc-gen-go-temporal/gen/test/simple/v1/mock_SimpleWorkflowFunctions.go +++ b/mocks/github.com/cludden/protoc-gen-go-temporal/gen/test/simple/v1/mock_SimpleWorkflowFunctions.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.44.2. DO NOT EDIT. package v1 diff --git a/mocks/github.com/cludden/protoc-gen-go-temporal/gen/test/xnserr/v1/mock_ServerClient.go b/mocks/github.com/cludden/protoc-gen-go-temporal/gen/test/xnserr/v1/mock_ServerClient.go index 276e2ff4..8a10c988 100644 --- a/mocks/github.com/cludden/protoc-gen-go-temporal/gen/test/xnserr/v1/mock_ServerClient.go +++ b/mocks/github.com/cludden/protoc-gen-go-temporal/gen/test/xnserr/v1/mock_ServerClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.44.2. DO NOT EDIT. package xnserrv1mocks diff --git a/mocks/github.com/cludden/protoc-gen-go-temporal/gen/test/xnserr/v1/mock_SleepRun.go b/mocks/github.com/cludden/protoc-gen-go-temporal/gen/test/xnserr/v1/mock_SleepRun.go index 9d0d5313..2c0983ae 100644 --- a/mocks/github.com/cludden/protoc-gen-go-temporal/gen/test/xnserr/v1/mock_SleepRun.go +++ b/mocks/github.com/cludden/protoc-gen-go-temporal/gen/test/xnserr/v1/mock_SleepRun.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.44.2. DO NOT EDIT. package xnserrv1mocks diff --git a/mocks/go.temporal.io/sdk/client/mock_Client.go b/mocks/go.temporal.io/sdk/client/mock_Client.go index fa0424c1..140dd970 100644 --- a/mocks/go.temporal.io/sdk/client/mock_Client.go +++ b/mocks/go.temporal.io/sdk/client/mock_Client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.44.2. DO NOT EDIT. package client diff --git a/mocks/go.temporal.io/sdk/clientutils/mock_WorkflowRun.go b/mocks/go.temporal.io/sdk/clientutils/mock_WorkflowRun.go index e74ebcb5..7b1645b3 100644 --- a/mocks/go.temporal.io/sdk/clientutils/mock_WorkflowRun.go +++ b/mocks/go.temporal.io/sdk/clientutils/mock_WorkflowRun.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.44.2. DO NOT EDIT. package clientutils diff --git a/pkg/ctxkey/ctxkey.go b/pkg/ctxkey/ctxkey.go new file mode 100644 index 00000000..27f976c2 --- /dev/null +++ b/pkg/ctxkey/ctxkey.go @@ -0,0 +1,51 @@ +package ctxkey + +import ( + "reflect" +) + +type ( + Context interface { + Value(any) any + } + + key struct { + name string + serializable bool + t reflect.Type + } + + Option func(*key) +) + +func Key[T any](name string, serializable bool) *key { + return &key{name, serializable, reflect.TypeFor[T]()} +} + +func (k *key) Value() (val reflect.Value) { + switch k.t.Kind() { + case reflect.Slice: + val = reflect.New(reflect.SliceOf(k.t.Elem())).Elem() + case reflect.Map: + val = reflect.New(reflect.MapOf(k.t.Key(), k.t.Elem())).Elem() + case reflect.Ptr: + val = reflect.New(k.t.Elem()) + default: + val = reflect.New(k.t).Elem() + } + return val +} + +func (k *key) Serializable() bool { + return k.serializable +} + +func (k *key) String() string { + return k.name +} + +func Serializable(s bool) Option { + return func(k *key) { + k.serializable = s + } +} diff --git a/pkg/ctxpropagation/ctxpropagation.go b/pkg/ctxpropagation/ctxpropagation.go new file mode 100644 index 00000000..1abee544 --- /dev/null +++ b/pkg/ctxpropagation/ctxpropagation.go @@ -0,0 +1,125 @@ +package ctxpropagation + +import ( + "context" + "fmt" + "reflect" + + "github.com/cludden/protoc-gen-go-temporal/pkg/ctxkey" + "go.temporal.io/sdk/converter" + "go.temporal.io/sdk/workflow" +) + +type ( + Key interface { + Value() reflect.Value + Serializable() bool + String() string + } + + propagator struct { + dc converter.DataConverter + keys []Key + } + + Option func(*propagator) +) + +func New(opts ...Option) workflow.ContextPropagator { + p := &propagator{} + for _, opt := range opts { + opt(p) + } + if p.dc == nil { + p.dc = converter.GetDefaultDataConverter() + } + return p +} + +func (p *propagator) Extract(ctx context.Context, r workflow.HeaderReader) (context.Context, error) { + for _, k := range p.keys { + if k.Serializable() { + payload, ok := r.Get(k.String()) + if !ok { + continue + } + + val := k.Value() + var canAddr bool + if val.CanAddr() { + val, canAddr = val.Addr(), true + } + if err := p.dc.FromPayload(payload, val.Interface()); err != nil { + return ctx, fmt.Errorf("error decoding payload to value of type %s", val.Type().String()) + } + + v := val.Interface() + if canAddr { + v = val.Elem().Interface() + } + ctx = context.WithValue(ctx, k, v) + } + } + return ctx, nil +} + +func (p *propagator) ExtractToWorkflow(ctx workflow.Context, r workflow.HeaderReader) (workflow.Context, error) { + for _, k := range p.keys { + if k.Serializable() { + payload, ok := r.Get(k.String()) + if !ok { + continue + } + + val := k.Value() + var canAddr bool + if val.CanAddr() { + val, canAddr = val.Addr(), true + } + + if err := p.dc.FromPayload(payload, val.Interface()); err != nil { + return ctx, fmt.Errorf("error decoding payload to value of type %s", val.Type().String()) + } + + v := val.Interface() + if canAddr { + v = val.Elem().Interface() + } + ctx = workflow.WithValue(ctx, k, v) + } + } + return ctx, nil +} + +func (p *propagator) Inject(ctx context.Context, w workflow.HeaderWriter) error { + return p.inject(ctx, w) +} + +func (p *propagator) InjectFromWorkflow(ctx workflow.Context, w workflow.HeaderWriter) error { + return p.inject(ctx, w) +} + +func WithDataConverter(dc converter.DataConverter) Option { + return func(p *propagator) { + p.dc = dc + } +} + +func WithKeys(keys ...Key) Option { + return func(p *propagator) { + p.keys = append(p.keys, keys...) + } +} + +func (p *propagator) inject(ctx ctxkey.Context, w workflow.HeaderWriter) error { + for _, k := range p.keys { + if k.Serializable() { + payload, err := p.dc.ToPayload(ctx.Value(k)) + if err != nil { + return err + } + w.Set(k.String(), payload) + } + } + return nil +} diff --git a/pkg/patch/patch.go b/pkg/patch/patch.go index 22f4210c..ba8a5bc5 100644 --- a/pkg/patch/patch.go +++ b/pkg/patch/patch.go @@ -1,5 +1,67 @@ package patch +import ( + "github.com/cludden/protoc-gen-go-temporal/pkg/ctxkey" + "github.com/cludden/protoc-gen-go-temporal/pkg/ctxpropagation" + "go.temporal.io/sdk/workflow" +) + const ( PV_64_ExpressionEvaluationLocalActivity = "cludden_protoc-gen-go-temporal_64_expression-evaluation-local-activity" + PV_77_UseParentTaskQueue = "cludden_protoc-gen-go-temporal_77_use-parent-task-queue" +) + +var Keys = []ctxpropagation.Key{ + defaultTaskQueues, +} + +var ( + defaultTaskQueues = ctxkey.Key[map[string]string]("github.com/cludden/protoc-gen-go-temporal#DefaultTaskQueues", true) ) + +func NewContextPropagator() workflow.ContextPropagator { + return ctxpropagation.New(ctxpropagation.WithKeys(Keys...)) +} + +func DefaultTaskQueue(ctx ctxkey.Context, tq string) string { + v := DefaultTaskQueues(ctx) + if vv, ok := v[tq]; !ok { + return tq + } else if vv == "" { + return tq + } else { + return vv + } +} + +func DefaultTaskQueues(ctx ctxkey.Context) map[string]string { + v, _ := ctx.Value(defaultTaskQueues).(map[string]string) + if v == nil { + v = map[string]string{} + } + return v +} + +func WithDefaultTaskQueue[K ctxkey.Context, Setter func(K, any, any) K](set Setter, ctx K, taskQueues ...string) K { + if len(taskQueues) == 0 { + return ctx + } + tq := taskQueues[0] + var override string + if len(taskQueues) == 2 && taskQueues[1] != tq { + override = taskQueues[1] + } + v, _ := ctx.Value(defaultTaskQueues).(map[string]string) + if v == nil { + v = map[string]string{} + } + if _, ok := v[tq]; !ok { + v[tq] = override + if override != "" { + if _, ok = v[override]; !ok { + v[override] = "" + } + } + } + return set(ctx, defaultTaskQueues, v) +} diff --git a/pkg/patch/patch_test.go b/pkg/patch/patch_test.go new file mode 100644 index 00000000..04b719f2 --- /dev/null +++ b/pkg/patch/patch_test.go @@ -0,0 +1,35 @@ +package patch + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestDefaultTaskQueue(t *testing.T) { + r, ctx := require.New(t), context.Background() + + r.Equal("foo", DefaultTaskQueue(ctx, "foo")) + ctx = WithDefaultTaskQueue(context.WithValue, ctx, "foo") + r.Equal("foo", DefaultTaskQueue(ctx, "foo")) + ctx = WithDefaultTaskQueue(context.WithValue, ctx, "foo", "bar") + r.Equal("foo", DefaultTaskQueue(ctx, "foo")) + + r.Equal("bar", DefaultTaskQueue(ctx, "bar")) + ctx = WithDefaultTaskQueue(context.WithValue, ctx, "bar", "baz") + r.Equal("baz", DefaultTaskQueue(ctx, "bar")) + ctx = WithDefaultTaskQueue(context.WithValue, ctx, "foo", "qux") + r.Equal("baz", DefaultTaskQueue(ctx, "bar")) + r.Equal("foo", DefaultTaskQueue(ctx, "foo")) + + r.Equal("baz", DefaultTaskQueue(ctx, "baz")) + ctx = WithDefaultTaskQueue(context.WithValue, ctx, "baz", "baz") + r.Equal("baz", DefaultTaskQueue(ctx, "baz"), "baz") + v, _ := ctx.Value(defaultTaskQueues).(map[string]string) + r.Equal(map[string]string{ + "foo": "", + "bar": "baz", + "baz": "", + }, v) +} diff --git a/proto/README.md b/proto/README.md index 6fb50010..127c51e4 100644 --- a/proto/README.md +++ b/proto/README.md @@ -207,6 +207,41 @@ - [test.option.v1.ActivityWithInputResponse](#test-option-v1-activitywithinputresponse) - [test.option.v1.UpdateWithInputRequest](#test-option-v1-updatewithinputrequest) - [test.option.v1.WorkflowWithInputRequest](#test-option-v1-workflowwithinputrequest) +- [test.patch.v1](#test-patch-v1) + - Services + - [test.patch.v1.Pv77FooService](#test-patch-v1-pv77fooservice) + - [Workflows](#test-patch-v1-pv77fooservice-workflows) + - [test.patch.v1.Pv77FooService.Pv77Foo](#test-patch-v1-pv77fooservice-pv77foo-workflow) + - [Activities](#test-patch-v1-pv77fooservice-activities) + - [test.patch.v1.Pv77FooActivity](#test-patch-v1-pv77fooactivity-activity) + - [test.patch.v1.Pv77BarService](#test-patch-v1-pv77barservice) + - [Workflows](#test-patch-v1-pv77barservice-workflows) + - [test.patch.v1.Pv77BarService.Pv77Bar](#test-patch-v1-pv77barservice-pv77bar-workflow) + - [Activities](#test-patch-v1-pv77barservice-activities) + - [test.patch.v1.Pv77BarActivity](#test-patch-v1-pv77baractivity-activity) + - [test.patch.v1.Pv77BazService](#test-patch-v1-pv77bazservice) + - [Workflows](#test-patch-v1-pv77bazservice-workflows) + - [test.patch.v1.Pv77BazService.Pv77Baz](#test-patch-v1-pv77bazservice-pv77baz-workflow) + - [Activities](#test-patch-v1-pv77bazservice-activities) + - [test.patch.v1.Pv77BazActivity](#test-patch-v1-pv77bazactivity-activity) + - [test.patch.v1.Pv77QuxService](#test-patch-v1-pv77quxservice) + - [Workflows](#test-patch-v1-pv77quxservice-workflows) + - [test.patch.v1.Pv77QuxService.Pv77Qux](#test-patch-v1-pv77quxservice-pv77qux-workflow) + - [Activities](#test-patch-v1-pv77quxservice-activities) + - [test.patch.v1.Pv77QuxActivity](#test-patch-v1-pv77quxactivity-activity) + - Messages + - [test.patch.v1.Pv77BarInput](#test-patch-v1-pv77barinput) + - [test.patch.v1.Pv77BarOutput](#test-patch-v1-pv77baroutput) + - [test.patch.v1.Pv77BarOutput.DefaultsEntry](#test-patch-v1-pv77baroutput-defaultsentry) + - [test.patch.v1.Pv77BazInput](#test-patch-v1-pv77bazinput) + - [test.patch.v1.Pv77BazOutput](#test-patch-v1-pv77bazoutput) + - [test.patch.v1.Pv77BazOutput.DefaultsEntry](#test-patch-v1-pv77bazoutput-defaultsentry) + - [test.patch.v1.Pv77FooInput](#test-patch-v1-pv77fooinput) + - [test.patch.v1.Pv77FooOutput](#test-patch-v1-pv77foooutput) + - [test.patch.v1.Pv77FooOutput.DefaultsEntry](#test-patch-v1-pv77foooutput-defaultsentry) + - [test.patch.v1.Pv77QuxInput](#test-patch-v1-pv77quxinput) + - [test.patch.v1.Pv77QuxOutput](#test-patch-v1-pv77quxoutput) + - [test.patch.v1.Pv77QuxOutput.DefaultsEntry](#test-patch-v1-pv77quxoutput-defaultsentry) - [test.xnserr.v1](#test-xnserr-v1) - Services - [test.xnserr.v1.Server](#test-xnserr-v1-server) @@ -4405,6 +4440,755 @@ go_name: Name + +# test.patch.v1 + + +## Services + + +## test.patch.v1.Pv77FooService + + +### Workflows + +--- + +### test.patch.v1.Pv77FooService.Pv77Foo + +**Input:** [test.patch.v1.Pv77FooInput](#test-patch-v1-pv77fooinput) + + + + + + + + + + + + +
AttributeTypeDescription
nextstring
+json_name: next
+go_name: Next
+ +**Output:** [test.patch.v1.Pv77FooOutput](#test-patch-v1-pv77foooutput) + + + + + + + + + + + + + + + + +
AttributeTypeDescription
defaultstest.patch.v1.Pv77FooOutput.DefaultsEntry
+json_name: defaults
+go_name: Defaults
task_queuesstring
+json_name: taskQueues
+go_name: TaskQueues
+ +**Defaults:** + + + + +
NameValue
id_reuse_policy
WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED
+ + +### Activities + +--- + +### test.patch.v1.Pv77FooActivity + + + +**Input:** [test.patch.v1.Pv77FooInput](#test-patch-v1-pv77fooinput) + + + + + + + + + + + + +
AttributeTypeDescription
nextstring
+json_name: next
+go_name: Next
+ +**Output:** [test.patch.v1.Pv77FooOutput](#test-patch-v1-pv77foooutput) + + + + + + + + + + + + + + + + +
AttributeTypeDescription
defaultstest.patch.v1.Pv77FooOutput.DefaultsEntry
+json_name: defaults
+go_name: Defaults
task_queuesstring
+json_name: taskQueues
+go_name: TaskQueues
+ +**Defaults:** + + + + +
NameValue
start_to_close_timeout5 seconds
+ + +## test.patch.v1.Pv77BarService + + +### Workflows + +--- + +### test.patch.v1.Pv77BarService.Pv77Bar + +**Input:** [test.patch.v1.Pv77BarInput](#test-patch-v1-pv77barinput) + + + + + + + + + + + + +
AttributeTypeDescription
nextstring
+json_name: next
+go_name: Next
+ +**Output:** [test.patch.v1.Pv77BarOutput](#test-patch-v1-pv77baroutput) + + + + + + + + + + + + + + + + +
AttributeTypeDescription
defaultstest.patch.v1.Pv77BarOutput.DefaultsEntry
+json_name: defaults
+go_name: Defaults
task_queuesstring
+json_name: taskQueues
+go_name: TaskQueues
+ +**Defaults:** + + + + +
NameValue
id_reuse_policy
WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED
+ + +### Activities + +--- + +### test.patch.v1.Pv77BarActivity + + + +**Input:** [test.patch.v1.Pv77BarInput](#test-patch-v1-pv77barinput) + + + + + + + + + + + + +
AttributeTypeDescription
nextstring
+json_name: next
+go_name: Next
+ +**Output:** [test.patch.v1.Pv77BarOutput](#test-patch-v1-pv77baroutput) + + + + + + + + + + + + + + + + +
AttributeTypeDescription
defaultstest.patch.v1.Pv77BarOutput.DefaultsEntry
+json_name: defaults
+go_name: Defaults
task_queuesstring
+json_name: taskQueues
+go_name: TaskQueues
+ +**Defaults:** + + + + +
NameValue
start_to_close_timeout5 seconds
+ + +## test.patch.v1.Pv77BazService + + +### Workflows + +--- + +### test.patch.v1.Pv77BazService.Pv77Baz + +**Input:** [test.patch.v1.Pv77BazInput](#test-patch-v1-pv77bazinput) + + + + + + + + + + + + +
AttributeTypeDescription
nextstring
+json_name: next
+go_name: Next
+ +**Output:** [test.patch.v1.Pv77BazOutput](#test-patch-v1-pv77bazoutput) + + + + + + + + + + + + + + + + +
AttributeTypeDescription
defaultstest.patch.v1.Pv77BazOutput.DefaultsEntry
+json_name: defaults
+go_name: Defaults
task_queuesstring
+json_name: taskQueues
+go_name: TaskQueues
+ +**Defaults:** + + + + +
NameValue
id_reuse_policy
WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED
+ + +### Activities + +--- + +### test.patch.v1.Pv77BazActivity + + + +**Input:** [test.patch.v1.Pv77BazInput](#test-patch-v1-pv77bazinput) + + + + + + + + + + + + +
AttributeTypeDescription
nextstring
+json_name: next
+go_name: Next
+ +**Output:** [test.patch.v1.Pv77BazOutput](#test-patch-v1-pv77bazoutput) + + + + + + + + + + + + + + + + +
AttributeTypeDescription
defaultstest.patch.v1.Pv77BazOutput.DefaultsEntry
+json_name: defaults
+go_name: Defaults
task_queuesstring
+json_name: taskQueues
+go_name: TaskQueues
+ +**Defaults:** + + + + +
NameValue
start_to_close_timeout5 seconds
+ + +## test.patch.v1.Pv77QuxService + + +### Workflows + +--- + +### test.patch.v1.Pv77QuxService.Pv77Qux + +**Input:** [test.patch.v1.Pv77QuxInput](#test-patch-v1-pv77quxinput) + + + + + + + + + + + + +
AttributeTypeDescription
nextstring
+json_name: next
+go_name: Next
+ +**Output:** [test.patch.v1.Pv77QuxOutput](#test-patch-v1-pv77quxoutput) + + + + + + + + + + + + + + + + +
AttributeTypeDescription
defaultstest.patch.v1.Pv77QuxOutput.DefaultsEntry
+json_name: defaults
+go_name: Defaults
task_queuesstring
+json_name: taskQueues
+go_name: TaskQueues
+ +**Defaults:** + + + + +
NameValue
id_reuse_policy
WORKFLOW_ID_REUSE_POLICY_UNSPECIFIED
+ + +### Activities + +--- + +### test.patch.v1.Pv77QuxActivity + + + +**Input:** [test.patch.v1.Pv77QuxInput](#test-patch-v1-pv77quxinput) + + + + + + + + + + + + +
AttributeTypeDescription
nextstring
+json_name: next
+go_name: Next
+ +**Output:** [test.patch.v1.Pv77QuxOutput](#test-patch-v1-pv77quxoutput) + + + + + + + + + + + + + + + + +
AttributeTypeDescription
defaultstest.patch.v1.Pv77QuxOutput.DefaultsEntry
+json_name: defaults
+go_name: Defaults
task_queuesstring
+json_name: taskQueues
+go_name: TaskQueues
+ +**Defaults:** + + + + +
NameValue
start_to_close_timeout5 seconds
+ + +## Messages + + +### test.patch.v1.Pv77BarInput + + + + + + + + + + + + +
AttributeTypeDescription
nextstring
+json_name: next
+go_name: Next
+ + + + +### test.patch.v1.Pv77BarOutput + + + + + + + + + + + + + + + + +
AttributeTypeDescription
defaultstest.patch.v1.Pv77BarOutput.DefaultsEntry
+json_name: defaults
+go_name: Defaults
task_queuesstring
+json_name: taskQueues
+go_name: TaskQueues
+ + + + +### test.patch.v1.Pv77BarOutput.DefaultsEntry + + + + + + + + + + + + + + + + +
AttributeTypeDescription
keystring
+json_name: key
+go_name: Key
valuestring
+json_name: value
+go_name: Value
+ + + + +### test.patch.v1.Pv77BazInput + + + + + + + + + + + + +
AttributeTypeDescription
nextstring
+json_name: next
+go_name: Next
+ + + + +### test.patch.v1.Pv77BazOutput + + + + + + + + + + + + + + + + +
AttributeTypeDescription
defaultstest.patch.v1.Pv77BazOutput.DefaultsEntry
+json_name: defaults
+go_name: Defaults
task_queuesstring
+json_name: taskQueues
+go_name: TaskQueues
+ + + + +### test.patch.v1.Pv77BazOutput.DefaultsEntry + + + + + + + + + + + + + + + + +
AttributeTypeDescription
keystring
+json_name: key
+go_name: Key
valuestring
+json_name: value
+go_name: Value
+ + + + +### test.patch.v1.Pv77FooInput + + + + + + + + + + + + +
AttributeTypeDescription
nextstring
+json_name: next
+go_name: Next
+ + + + +### test.patch.v1.Pv77FooOutput + + + + + + + + + + + + + + + + +
AttributeTypeDescription
defaultstest.patch.v1.Pv77FooOutput.DefaultsEntry
+json_name: defaults
+go_name: Defaults
task_queuesstring
+json_name: taskQueues
+go_name: TaskQueues
+ + + + +### test.patch.v1.Pv77FooOutput.DefaultsEntry + + + + + + + + + + + + + + + + +
AttributeTypeDescription
keystring
+json_name: key
+go_name: Key
valuestring
+json_name: value
+go_name: Value
+ + + + +### test.patch.v1.Pv77QuxInput + + + + + + + + + + + + +
AttributeTypeDescription
nextstring
+json_name: next
+go_name: Next
+ + + + +### test.patch.v1.Pv77QuxOutput + + + + + + + + + + + + + + + + +
AttributeTypeDescription
defaultstest.patch.v1.Pv77QuxOutput.DefaultsEntry
+json_name: defaults
+go_name: Defaults
task_queuesstring
+json_name: taskQueues
+go_name: TaskQueues
+ + + + +### test.patch.v1.Pv77QuxOutput.DefaultsEntry + + + + + + + + + + + + + + + + +
AttributeTypeDescription
keystring
+json_name: key
+go_name: Key
valuestring
+json_name: value
+go_name: Value
+ + + # test.xnserr.v1 diff --git a/proto/temporal/v1/temporal.proto b/proto/temporal/v1/temporal.proto index 773c0f34..132b8844 100644 --- a/proto/temporal/v1/temporal.proto +++ b/proto/temporal/v1/temporal.proto @@ -49,6 +49,9 @@ message ActivityOptions { // Specifies how to retry an Activity if an error occurs RetryPolicy retry_policy = 6; + + // Configure patches, by default, patches are introduced in enabled mode + repeated Patch patches = 9; } // CLIFeature enumerates cli feature statuses @@ -110,6 +113,10 @@ message Patch { // wraps expression evaluation in local activities within workflow contexts // details: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/fix-versions#fix_version_64_expression_evaluation_local_activity PV_64 = 1; + + // uses parent workflow task queue for child workflows, instead of service default + // details: https://cludden.github.io/protoc-gen-go-temporal/docs/guides/fix-versions#fix_version_77_use_parent_task_queue + PV_77 = 2; } // enumerates all supported patch configurations diff --git a/test/option/main.go b/test/option/main.go index a7a6b34a..fc3fc672 100644 --- a/test/option/main.go +++ b/test/option/main.go @@ -8,16 +8,16 @@ import ( ) type ( - Workflows struct{} + TestWorkflows struct{} - Activities struct{} + TestActivities struct{} WorkflowWithInputWorkflow struct { *optionv1.WorkflowWithInputWorkflowInput } ) -func (w *Workflows) WorkflowWithInput(ctx workflow.Context, input *optionv1.WorkflowWithInputWorkflowInput) (optionv1.WorkflowWithInputWorkflow, error) { +func (w *TestWorkflows) WorkflowWithInput(ctx workflow.Context, input *optionv1.WorkflowWithInputWorkflowInput) (optionv1.WorkflowWithInputWorkflow, error) { return &WorkflowWithInputWorkflow{input}, nil } @@ -29,6 +29,6 @@ func (w *WorkflowWithInputWorkflow) UpdateWithInput(ctx workflow.Context, input return nil } -func (a *Activities) ActivityWithInput(ctx context.Context, input *optionv1.ActivityWithInputRequest) (*optionv1.ActivityWithInputResponse, error) { +func (a *TestActivities) ActivityWithInput(ctx context.Context, input *optionv1.ActivityWithInputRequest) (*optionv1.ActivityWithInputResponse, error) { return nil, nil } diff --git a/test/option/main_test.go b/test/option/main_test.go index fdb46451..7b418783 100644 --- a/test/option/main_test.go +++ b/test/option/main_test.go @@ -23,12 +23,13 @@ type OptionSuite struct { } func TestOptionSuite(t *testing.T) { + t.Setenv("TEMPORAL_DEBUG", "true") suite.Run(t, new(OptionSuite)) } func (s *OptionSuite) SetupTest() { s.env = s.NewTestWorkflowEnvironment() - s.client = optionv1.NewTestTestClient(s.env, &Workflows{}, &Activities{}) + s.client = optionv1.NewTestTestClient(s.env, &TestWorkflows{}, &TestActivities{}) } func (s *OptionSuite) SetupSubTest() { diff --git a/test/option/proto/test/option/v1/option.proto b/test/option/proto/test/option/v1/option.proto index c733c2e1..f814980f 100644 --- a/test/option/proto/test/option/v1/option.proto +++ b/test/option/proto/test/option/v1/option.proto @@ -6,7 +6,9 @@ import "google/protobuf/empty.proto"; import "temporal/v1/temporal.proto"; service Test { - option (temporal.v1.service).task_queue = "option-v1"; + option (temporal.v1.service) = { + task_queue: "option-v1" + }; rpc ActivityWithInput(ActivityWithInputRequest) returns (ActivityWithInputResponse) { option (temporal.v1.activity) = { diff --git a/test/patch/proto/test/patch/v1/pv77.proto b/test/patch/proto/test/patch/v1/pv77.proto new file mode 100644 index 00000000..32008e24 --- /dev/null +++ b/test/patch/proto/test/patch/v1/pv77.proto @@ -0,0 +1,119 @@ +syntax = "proto3"; + +package test.patch.v1; + +import "temporal/v1/temporal.proto"; + +service Pv77FooService { + option (temporal.v1.service) = { + task_queue: "pv77-v1" + patches: [ + { version: PV_77, mode: PVM_ENABLED } + ] + }; + + rpc Pv77Foo(Pv77FooInput) returns (Pv77FooOutput) { + option (temporal.v1.workflow) = {}; + option (temporal.v1.activity) = { + name: "test.patch.v1.Pv77FooActivity" + start_to_close_timeout: { seconds: 5 } + }; + } +} + +service Pv77BarService { + option (temporal.v1.service) = { + task_queue: "pv77-v1" + patches: [ + { version: PV_77, mode: PVM_MARKER } + ] + }; + + rpc Pv77Bar(Pv77BarInput) returns (Pv77BarOutput) { + option (temporal.v1.workflow) = {}; + option (temporal.v1.activity) = { + name: "test.patch.v1.Pv77BarActivity" + start_to_close_timeout: { seconds: 5 } + }; + } +} + +service Pv77BazService { + option (temporal.v1.service) = { + task_queue: "pv77-v3" + patches: [ + { version: PV_77, mode: PVM_REMOVED } + ] + }; + + rpc Pv77Baz(Pv77BazInput) returns (Pv77BazOutput) { + option (temporal.v1.workflow) = {}; + option (temporal.v1.activity) = { + name: "test.patch.v1.Pv77BazActivity" + start_to_close_timeout: { seconds: 5 } + }; + } +} + +service Pv77QuxService { + option (temporal.v1.service) = { + task_queue: "pv77-v2" + patches: [ + { version: PV_77, mode: PVM_DISABLED } + ] + }; + + rpc Pv77Qux(Pv77QuxInput) returns (Pv77QuxOutput) { + option (temporal.v1.workflow) = {}; + option (temporal.v1.activity) = { + name: "test.patch.v1.Pv77QuxActivity" + start_to_close_timeout: { seconds: 5 } + }; + } +} + + +message Pv77Input { + repeated string next = 1; +} + +message Pv77Output { + repeated string task_queues = 1; + map defaults = 2; +} + +message Pv77FooInput { + repeated string next = 1; +} + +message Pv77FooOutput { + repeated string task_queues = 1; + map defaults = 2; +} + +message Pv77BarInput { + repeated string next = 1; +} + +message Pv77BarOutput { + repeated string task_queues = 1; + map defaults = 2; +} + +message Pv77BazInput { + repeated string next = 1; +} + +message Pv77BazOutput { + repeated string task_queues = 1; + map defaults = 2; +} + +message Pv77QuxInput { + repeated string next = 1; +} + +message Pv77QuxOutput { + repeated string task_queues = 1; + map defaults = 2; +} diff --git a/test/patch/pv77.go b/test/patch/pv77.go new file mode 100644 index 00000000..9fb4f533 --- /dev/null +++ b/test/patch/pv77.go @@ -0,0 +1,139 @@ +package main + +import ( + "context" + "fmt" + + patchv1 "github.com/cludden/protoc-gen-go-temporal/gen/test/patch/v1" + "github.com/cludden/protoc-gen-go-temporal/pkg/patch" + "go.temporal.io/sdk/activity" + "go.temporal.io/sdk/workflow" +) + +type ( + Pv77Workflows struct{} + + Pv77Activities struct{} + + Pv77FooWorkflow struct { + *Pv77Workflows + *patchv1.Pv77FooWorkflowInput + } + + Pv77BarWorkflow struct { + *Pv77Workflows + *patchv1.Pv77BarWorkflowInput + } + + Pv77BazWorkflow struct { + *Pv77Workflows + *patchv1.Pv77BazWorkflowInput + } + + Pv77QuxWorkflow struct { + *Pv77Workflows + *patchv1.Pv77QuxWorkflowInput + } +) + +func (w *Pv77Workflows) Pv77Foo(ctx workflow.Context, input *patchv1.Pv77FooWorkflowInput) (patchv1.Pv77FooWorkflow, error) { + return &Pv77FooWorkflow{w, input}, nil +} + +func (w *Pv77FooWorkflow) Execute(ctx workflow.Context) (*patchv1.Pv77FooOutput, error) { + out, err := w.execute(ctx, &patchv1.Pv77Input{Next: w.Req.GetNext()}) + return &patchv1.Pv77FooOutput{TaskQueues: out.GetTaskQueues(), Defaults: out.GetDefaults()}, err +} + +func (w *Pv77Workflows) Pv77Bar(ctx workflow.Context, input *patchv1.Pv77BarWorkflowInput) (patchv1.Pv77BarWorkflow, error) { + return &Pv77BarWorkflow{w, input}, nil +} + +func (w *Pv77BarWorkflow) Execute(ctx workflow.Context) (*patchv1.Pv77BarOutput, error) { + out, err := w.execute(ctx, &patchv1.Pv77Input{Next: w.Req.GetNext()}) + return &patchv1.Pv77BarOutput{TaskQueues: out.GetTaskQueues(), Defaults: out.GetDefaults()}, err +} + +func (w *Pv77Workflows) Pv77Baz(ctx workflow.Context, input *patchv1.Pv77BazWorkflowInput) (patchv1.Pv77BazWorkflow, error) { + return &Pv77BazWorkflow{w, input}, nil +} + +func (w *Pv77BazWorkflow) Execute(ctx workflow.Context) (*patchv1.Pv77BazOutput, error) { + out, err := w.execute(ctx, &patchv1.Pv77Input{Next: w.Req.GetNext()}) + return &patchv1.Pv77BazOutput{TaskQueues: out.GetTaskQueues(), Defaults: out.GetDefaults()}, err +} + +func (w *Pv77Workflows) Pv77Qux(ctx workflow.Context, input *patchv1.Pv77QuxWorkflowInput) (patchv1.Pv77QuxWorkflow, error) { + return &Pv77QuxWorkflow{w, input}, nil +} + +func (w *Pv77QuxWorkflow) Execute(ctx workflow.Context) (*patchv1.Pv77QuxOutput, error) { + out, err := w.execute(ctx, &patchv1.Pv77Input{Next: w.Req.GetNext()}) + return &patchv1.Pv77QuxOutput{TaskQueues: out.GetTaskQueues(), Defaults: out.GetDefaults()}, err +} + +func (a *Pv77Activities) Pv77Foo(ctx context.Context, input *patchv1.Pv77FooInput) (*patchv1.Pv77FooOutput, error) { + return &patchv1.Pv77FooOutput{TaskQueues: []string{activity.GetInfo(ctx).TaskQueue}}, nil +} + +func (a *Pv77Activities) Pv77Bar(ctx context.Context, input *patchv1.Pv77BarInput) (*patchv1.Pv77BarOutput, error) { + return &patchv1.Pv77BarOutput{TaskQueues: []string{activity.GetInfo(ctx).TaskQueue}}, nil +} + +func (a *Pv77Activities) Pv77Baz(ctx context.Context, input *patchv1.Pv77BazInput) (*patchv1.Pv77BazOutput, error) { + return &patchv1.Pv77BazOutput{TaskQueues: []string{activity.GetInfo(ctx).TaskQueue}}, nil +} + +func (a *Pv77Activities) Pv77Qux(ctx context.Context, input *patchv1.Pv77QuxInput) (*patchv1.Pv77QuxOutput, error) { + return &patchv1.Pv77QuxOutput{TaskQueues: []string{activity.GetInfo(ctx).TaskQueue}}, nil +} + +type Pv77Output interface { + GetDefaults() map[string]string + GetTaskQueues() []string +} + +func (w *Pv77Workflows) execute(ctx workflow.Context, input *patchv1.Pv77Input) (*patchv1.Pv77Output, error) { + result := &patchv1.Pv77Output{ + TaskQueues: []string{workflow.GetInfo(ctx).TaskQueueName}, + Defaults: patch.DefaultTaskQueues(ctx), + } + var out Pv77Output + var err error + var n string + next := input.GetNext() + for len(next) > 0 { + n, next = next[0], next[1:] + switch n { + case patchv1.Pv77FooActivityName: + out, err = patchv1.Pv77Foo(ctx, &patchv1.Pv77FooInput{Next: next}) + case patchv1.Pv77BarActivityName: + out, err = patchv1.Pv77Bar(ctx, &patchv1.Pv77BarInput{Next: next}) + case patchv1.Pv77BazActivityName: + out, err = patchv1.Pv77Baz(ctx, &patchv1.Pv77BazInput{Next: next}) + case patchv1.Pv77QuxActivityName: + out, err = patchv1.Pv77Qux(ctx, &patchv1.Pv77QuxInput{Next: next}) + case patchv1.Pv77FooWorkflowName: + out, err = patchv1.Pv77FooChild(ctx, &patchv1.Pv77FooInput{Next: next}) + next = nil + case patchv1.Pv77BarWorkflowName: + out, err = patchv1.Pv77BarChild(ctx, &patchv1.Pv77BarInput{Next: next}) + next = nil + case patchv1.Pv77BazWorkflowName: + out, err = patchv1.Pv77BazChild(ctx, &patchv1.Pv77BazInput{Next: next}) + next = nil + case patchv1.Pv77QuxWorkflowName: + out, err = patchv1.Pv77QuxChild(ctx, &patchv1.Pv77QuxInput{Next: next}) + next = nil + default: + return nil, fmt.Errorf("unknown workflow: %q", next[0]) + } + if out != nil { + result.TaskQueues = append(result.TaskQueues, out.GetTaskQueues()...) + for k, v := range out.GetDefaults() { + result.Defaults[k] = v + } + } + } + return result, err +} diff --git a/test/patch/pv77_test.go b/test/patch/pv77_test.go new file mode 100644 index 00000000..5cf7b387 --- /dev/null +++ b/test/patch/pv77_test.go @@ -0,0 +1,301 @@ +package main + +import ( + "context" + "fmt" + "testing" + + patchv1 "github.com/cludden/protoc-gen-go-temporal/gen/test/patch/v1" + "github.com/cludden/protoc-gen-go-temporal/pkg/patch" + "github.com/stretchr/testify/require" + "go.temporal.io/sdk/client" + "go.temporal.io/sdk/testsuite" + "go.temporal.io/sdk/worker" + "go.temporal.io/sdk/workflow" +) + +func TestPv77_WithoutContextPropagator(t *testing.T) { + if testing.Short() { + t.SkipNow() + } + + ctx := context.Background() + + srv, err := testsuite.StartDevServer(ctx, testsuite.DevServerOptions{}) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, srv.Stop()) }) + + c := srv.Client() + t.Cleanup(c.Close) + + var wf Pv77Workflows + var a Pv77Activities + customTaskQueue := "custom" + for _, w := range []worker.Worker{ + worker.New(c, patchv1.Pv77FooServiceTaskQueue, worker.Options{}), + worker.New(c, patchv1.Pv77QuxServiceTaskQueue, worker.Options{}), + worker.New(c, patchv1.Pv77BarServiceTaskQueue, worker.Options{}), + worker.New(c, patchv1.Pv77BazServiceTaskQueue, worker.Options{}), + worker.New(c, customTaskQueue, worker.Options{}), + } { + patchv1.RegisterPv77FooServiceWorkflows(w, &wf) + patchv1.RegisterPv77FooServiceActivities(w, &a) + patchv1.RegisterPv77QuxServiceWorkflows(w, &wf) + patchv1.RegisterPv77QuxServiceActivities(w, &a) + patchv1.RegisterPv77BarServiceWorkflows(w, &wf) + patchv1.RegisterPv77BarServiceActivities(w, &a) + patchv1.RegisterPv77BazServiceWorkflows(w, &wf) + patchv1.RegisterPv77BazServiceActivities(w, &a) + require.NoError(t, w.Start()) + t.Cleanup(w.Stop) + } + + cases := []struct { + taskQueue string + next []string + expected []string + }{ + { + taskQueue: patchv1.Pv77FooServiceTaskQueue, + next: []string{ + patchv1.Pv77FooWorkflowName, + patchv1.Pv77BarWorkflowName, + patchv1.Pv77BazWorkflowName, + patchv1.Pv77QuxWorkflowName, + }, + expected: []string{ + patchv1.Pv77FooServiceTaskQueue, + patchv1.Pv77BarServiceTaskQueue, + patchv1.Pv77BazServiceTaskQueue, + patchv1.Pv77QuxServiceTaskQueue, + }, + }, + { + taskQueue: customTaskQueue, + next: []string{ + patchv1.Pv77FooWorkflowName, + patchv1.Pv77BarWorkflowName, + patchv1.Pv77BazWorkflowName, + patchv1.Pv77QuxWorkflowName, + }, + expected: []string{ + customTaskQueue, + customTaskQueue, + patchv1.Pv77BazServiceTaskQueue, + patchv1.Pv77QuxServiceTaskQueue, + }, + }, + { + taskQueue: customTaskQueue, + next: []string{ + patchv1.Pv77FooWorkflowName, + patchv1.Pv77BarWorkflowName, + patchv1.Pv77BazWorkflowName, + patchv1.Pv77FooWorkflowName, + }, + expected: []string{ + customTaskQueue, + customTaskQueue, + patchv1.Pv77BazServiceTaskQueue, + patchv1.Pv77FooServiceTaskQueue, + }, + }, + { + taskQueue: customTaskQueue, + next: []string{ + patchv1.Pv77FooWorkflowName, + patchv1.Pv77FooActivityName, + patchv1.Pv77QuxWorkflowName, + patchv1.Pv77FooActivityName, + }, + expected: []string{ + customTaskQueue, + customTaskQueue, + patchv1.Pv77QuxServiceTaskQueue, + patchv1.Pv77FooServiceTaskQueue, + }, + }, + { + taskQueue: customTaskQueue, + next: []string{ + patchv1.Pv77FooWorkflowName, + patchv1.Pv77FooActivityName, + patchv1.Pv77BarWorkflowName, + patchv1.Pv77QuxActivityName, + patchv1.Pv77FooActivityName, + }, + expected: []string{ + customTaskQueue, + customTaskQueue, + customTaskQueue, + patchv1.Pv77QuxServiceTaskQueue, + customTaskQueue, + }, + }, + } + + for i, tc := range cases { + t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { + var out Pv77Output + var err error + switch tc.next[0] { + case patchv1.Pv77FooWorkflowName: + out, err = patchv1.NewPv77FooServiceClient(c).Pv77Foo(ctx, &patchv1.Pv77FooInput{Next: tc.next[1:]}, patchv1.NewPv77FooOptions().WithTaskQueue(tc.taskQueue)) + case patchv1.Pv77BarWorkflowName: + out, err = patchv1.NewPv77BarServiceClient(c).Pv77Bar(ctx, &patchv1.Pv77BarInput{Next: tc.next[1:]}, patchv1.NewPv77BarOptions().WithTaskQueue(tc.taskQueue)) + case patchv1.Pv77BazWorkflowName: + out, err = patchv1.NewPv77BazServiceClient(c).Pv77Baz(ctx, &patchv1.Pv77BazInput{Next: tc.next[1:]}, patchv1.NewPv77BazOptions().WithTaskQueue(tc.taskQueue)) + case patchv1.Pv77QuxWorkflowName: + out, err = patchv1.NewPv77QuxServiceClient(c).Pv77Qux(ctx, &patchv1.Pv77QuxInput{Next: tc.next[1:]}, patchv1.NewPv77QuxOptions().WithTaskQueue(tc.taskQueue)) + } + require.NoError(t, err) + require.Equal(t, tc.expected, out.GetTaskQueues()) + }) + } +} + +func TestPv77_WithContextPropagator(t *testing.T) { + if testing.Short() { + t.SkipNow() + } + + ctx := context.Background() + + srv, err := testsuite.StartDevServer(ctx, testsuite.DevServerOptions{ + ClientOptions: &client.Options{ + ContextPropagators: []workflow.ContextPropagator{ + patch.NewContextPropagator(), + }, + }, + }) + require.NoError(t, err) + t.Cleanup(func() { require.NoError(t, srv.Stop()) }) + + c := srv.Client() + t.Cleanup(c.Close) + + var wf Pv77Workflows + var a Pv77Activities + customTaskQueue := "custom" + for _, w := range []worker.Worker{ + worker.New(c, patchv1.Pv77FooServiceTaskQueue, worker.Options{}), + worker.New(c, patchv1.Pv77QuxServiceTaskQueue, worker.Options{}), + worker.New(c, patchv1.Pv77BarServiceTaskQueue, worker.Options{}), + worker.New(c, patchv1.Pv77BazServiceTaskQueue, worker.Options{}), + worker.New(c, customTaskQueue, worker.Options{}), + } { + patchv1.RegisterPv77FooServiceWorkflows(w, &wf) + patchv1.RegisterPv77FooServiceActivities(w, &a) + patchv1.RegisterPv77QuxServiceWorkflows(w, &wf) + patchv1.RegisterPv77QuxServiceActivities(w, &a) + patchv1.RegisterPv77BarServiceWorkflows(w, &wf) + patchv1.RegisterPv77BarServiceActivities(w, &a) + patchv1.RegisterPv77BazServiceWorkflows(w, &wf) + patchv1.RegisterPv77BazServiceActivities(w, &a) + require.NoError(t, w.Start()) + t.Cleanup(w.Stop) + } + + cases := []struct { + taskQueue string + next []string + expected []string + }{ + { + taskQueue: patchv1.Pv77FooServiceTaskQueue, + next: []string{ + patchv1.Pv77FooWorkflowName, + patchv1.Pv77BarWorkflowName, + patchv1.Pv77BazWorkflowName, + patchv1.Pv77QuxWorkflowName, + }, + expected: []string{ + patchv1.Pv77FooServiceTaskQueue, + patchv1.Pv77BarServiceTaskQueue, + patchv1.Pv77BazServiceTaskQueue, + patchv1.Pv77QuxServiceTaskQueue, + }, + }, + { + taskQueue: customTaskQueue, + next: []string{ + patchv1.Pv77FooWorkflowName, + patchv1.Pv77BarWorkflowName, + patchv1.Pv77BazWorkflowName, + patchv1.Pv77QuxWorkflowName, + }, + expected: []string{ + customTaskQueue, + customTaskQueue, + patchv1.Pv77BazServiceTaskQueue, + patchv1.Pv77QuxServiceTaskQueue, + }, + }, + { + taskQueue: customTaskQueue, + next: []string{ + patchv1.Pv77FooWorkflowName, + patchv1.Pv77BarWorkflowName, + patchv1.Pv77BazWorkflowName, + patchv1.Pv77FooWorkflowName, + }, + expected: []string{ + customTaskQueue, + customTaskQueue, + patchv1.Pv77BazServiceTaskQueue, + customTaskQueue, + }, + }, + { + taskQueue: customTaskQueue, + next: []string{ + patchv1.Pv77FooWorkflowName, + patchv1.Pv77FooActivityName, + patchv1.Pv77QuxWorkflowName, + patchv1.Pv77FooActivityName, + }, + expected: []string{ + customTaskQueue, + customTaskQueue, + patchv1.Pv77QuxServiceTaskQueue, + customTaskQueue, + }, + }, + { + taskQueue: customTaskQueue, + next: []string{ + patchv1.Pv77FooWorkflowName, + patchv1.Pv77FooActivityName, + patchv1.Pv77BarWorkflowName, + patchv1.Pv77QuxActivityName, + patchv1.Pv77FooActivityName, + }, + expected: []string{ + customTaskQueue, + customTaskQueue, + customTaskQueue, + patchv1.Pv77QuxServiceTaskQueue, + customTaskQueue, + }, + }, + } + + for i, tc := range cases { + t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { + var out Pv77Output + var err error + switch tc.next[0] { + case patchv1.Pv77FooWorkflowName: + out, err = patchv1.NewPv77FooServiceClient(c).Pv77Foo(ctx, &patchv1.Pv77FooInput{Next: tc.next[1:]}, patchv1.NewPv77FooOptions().WithTaskQueue(tc.taskQueue)) + case patchv1.Pv77BarWorkflowName: + out, err = patchv1.NewPv77BarServiceClient(c).Pv77Bar(ctx, &patchv1.Pv77BarInput{Next: tc.next[1:]}, patchv1.NewPv77BarOptions().WithTaskQueue(tc.taskQueue)) + case patchv1.Pv77BazWorkflowName: + out, err = patchv1.NewPv77BazServiceClient(c).Pv77Baz(ctx, &patchv1.Pv77BazInput{Next: tc.next[1:]}, patchv1.NewPv77BazOptions().WithTaskQueue(tc.taskQueue)) + case patchv1.Pv77QuxWorkflowName: + out, err = patchv1.NewPv77QuxServiceClient(c).Pv77Qux(ctx, &patchv1.Pv77QuxInput{Next: tc.next[1:]}, patchv1.NewPv77QuxOptions().WithTaskQueue(tc.taskQueue)) + } + require.NoError(t, err) + require.Equal(t, tc.expected, out.GetTaskQueues()) + }) + } +} diff --git a/test/xnserr/client_test.go b/test/xnserr/client_test.go index caf845dc..565361ed 100644 --- a/test/xnserr/client_test.go +++ b/test/xnserr/client_test.go @@ -67,7 +67,7 @@ func registerNamespaceIfNotExists(ctx context.Context, t *testing.T, c client.Cl } // check if we already have xnserr-server and if so return - for _, n := range res.Namespaces { + for _, n := range namespaces { if n.NamespaceInfo.Name == "xnserr-server" { return } @@ -87,6 +87,9 @@ func (s *XnsErrSuite) SetupSuite() { ClientOptions: &client.Options{ HostPort: "0.0.0.0:7233", Logger: log.NewStructuredLogger(slog.New(slog.NewTextHandler(io.Discard, nil))), + // ContextPropagators: []workflow.ContextPropagator{ + // patch.NewContextPropagator(), + // }, }, EnableUI: true, LogLevel: "error", @@ -109,7 +112,12 @@ func (s *XnsErrSuite) SetupSuite() { }, ) - s.sc, err = client.NewClientFromExisting(s.c, client.Options{Namespace: "xnserr-server"}) + s.sc, err = client.NewClientFromExisting(s.c, client.Options{ + Namespace: "xnserr-server", + // ContextPropagators: []workflow.ContextPropagator{ + // patch.NewContextPropagator(), + // }, + }) s.require.NoError(err) server := worker.New(s.sc, xnserrv1.ServerTaskQueue, worker.Options{}) @@ -122,7 +130,12 @@ func (s *XnsErrSuite) SetupSuite() { server.Stop() }, ) - s.server, err = xnserrv1.NewServerClientWithOptions(s.sc, client.Options{Namespace: "xnserr-server"}) + s.server, err = xnserrv1.NewServerClientWithOptions(s.sc, client.Options{ + Namespace: "xnserr-server", + // ContextPropagators: []workflow.ContextPropagator{ + // patch.NewContextPropagator(), + // }, + }) s.require.NoError(err) client := worker.New(s.c, xnserrv1.ClientTaskQueue, worker.Options{}) @@ -173,7 +186,7 @@ func (s *XnsErrSuite) TestWorkflowExecutionError_ClientCanceled() { err = run.Get(s.ctx) var cancelledErr *temporal.CanceledError - s.require.ErrorAs(err, &cancelledErr) + s.require.ErrorContains(err, cancelledErr.Error()) execs, err := s.sc.WorkflowService().ListClosedWorkflowExecutions(s.ctx, &workflowservice.ListClosedWorkflowExecutionsRequest{ Namespace: "xnserr-server", @@ -184,7 +197,9 @@ func (s *XnsErrSuite) TestWorkflowExecutionError_ClientCanceled() { }, }) s.require.NoError(err) - s.require.Len(execs.GetExecutions(), 1) + s.require.Eventually(func() bool { + return len(execs.GetExecutions()) == 1 + }, time.Second*10, time.Second) s.require.Equal(enums.WORKFLOW_EXECUTION_STATUS_CANCELED, execs.GetExecutions()[0].GetStatus()) }