Skip to content

Commit

Permalink
Add enable_parent_task_queue_for_child_workflows service option
Browse files Browse the repository at this point in the history
  • Loading branch information
cludden committed Aug 29, 2024
1 parent d2f9bfc commit fa6af99
Show file tree
Hide file tree
Showing 57 changed files with 9,836 additions and 447 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions docs/docs/configuration/service.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
]
};
}
Expand Down
149 changes: 147 additions & 2 deletions docs/docs/guides/clients.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<Tabs>
<TabItem value="constructor-new-schema" label="Schema">
```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;
}
```
</TabItem>
<TabItem value="constructor-new-client" label="Client">
```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())
}
```
</TabItem>
</Tabs>

### 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
10 changes: 10 additions & 0 deletions docs/docs/guides/patches.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
:::
2 changes: 1 addition & 1 deletion docs/docs/guides/signals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
)

type FooWorkflow struct {
examplev1.FooWorkflowInput
*examplev1.FooWorkflowInput
}

func (w *FooWorkflow) Execute(ctx workflow.Context) (*examplev1.FooOutput, error) {
Expand Down
15 changes: 13 additions & 2 deletions gen/example/helloworld/v1/example_temporal.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 33 additions & 4 deletions gen/example/mutex/v1/mutex_temporal.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen/example/mutex/v1/mutexv1xns/mutex_xns_temporal.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions gen/example/schedule/v1/schedule_temporal.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fa6af99

Please sign in to comment.