Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Added-20251224-134551.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Added
body: Add ContinueAsNew workflow input method
time: 2025-12-24T13:45:51.232748-07:00
custom:
Author: cludden
PullRequest: "139"
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 25
cache: npm
cache-dependency-path: ./docs/package-lock.json

Expand Down
8 changes: 4 additions & 4 deletions buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ deps:
commit: 76b304caf5984a3a978e9565ea71a2ac
digest: b5:72c441888d19ff57f824b75f59aba0346a16bfa3ef5da83a5da21c614f0763764e1d37511312dc82f54e1dae5937a5829e8c2c1b7f806c983046bbf624b04ac2
- name: buf.build/cludden/protoc-gen-go-temporal
commit: 82d9a66e89c24dc492936b1a29a7f605
digest: b5:8f3671c822204f747a0ac55cde7c3f2b657d6bfc5ad14cc7057178741f258eac0d7f316f6f09a4689a8acf6b2eb746b239dcd87b72964bdc8220b368a046c006
commit: 1d9b7e091b284c519a6ef7b799129547
digest: b5:00d49833c1e03e0be1935743d5d279b1666b5725157dd6813b481d38a4a7c7abe5b64a7f78895672c6a458365486923d127cd4192cf8659fa931f520bbb48d48
- name: buf.build/envoyproxy/protoc-gen-validate
commit: daf171c6cdb54629b5f51e345a79e4dd
digest: b5:c745e1521879f43740230b1df673d0729f55704efefdcfc489d4a0a2d40c92a26cacfeab62813403040a8b180142d53b398c7ca784a065e43823605ee49681de
- name: buf.build/googleapis/googleapis
commit: 28151c0d0a1641bf938a7672c500e01d
digest: b5:93b70089baa4fc05a92d3e52db91a4b7812db3b57b9664f6cb301733938cb630e377a938e8a56779388171c749c1d42a2e9a6c6230f2ff45f127a8102a6a27d0
- name: buf.build/temporalio/api
commit: 54001d31c68a41dda97490fe01642301
digest: b5:5d08f3a5ae4f6941df4c84b6bb33c3e1e93f3cb28c7ef7b09277148c574b9edcee4999662b81efd0a62ab70c92245d460c1bffafefeb7e54dbd5aa328d239175
commit: ff85f03bb36a44b1b80c0c3b9f44637e
digest: b5:d37fb2d41b87376e57da251fe569d7ee659a9723eee957f90c406ecff4995dde8e6fa5d1210b776afd78c28b53c8b8490cd6daa79a481f4734744c62c41b81c0
160 changes: 160 additions & 0 deletions docs/docs/guides/workflows.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,166 @@ service Example {
</TabItem>
</Tabs>

## Workflow Input

Every workflow definition generates a `<Workflow>WorkflowInput` struct that contains the workflow input and any registered signals. It is passed to the workflow constructor and should be embedded in the workflow struct to allow for query and update handlers to access the workflow input.

### Req

If the workflow specifies a non-empty input message type, the generated `<Workflow>WorkflowInput` struct will include a `Req` field that contains a reference to the workflow input.

<Tabs>
<TabItem value="implementation-go" label="Go">
```go title="example.go"
package example

import (
examplev1 "path/to/gen/example/v1"
)

type HelloWorkflow struct {
*examplev1.HelloWorkflowInput
}

func (w *HelloWorkflow) Execute(ctx workflow.Context) (*examplev1.HelloOutput, error) {
return &examplev1.HelloOutput{
Result: fmt.Sprintf("Hello %s!", w.Req.GetName()),
}, nil
}
```
</TabItem>
<TabItem value="implementation-schema" label="Schema">
```protobuf title="example.proto"
syntax="proto3";

package example.v1;

import "temporal/v1/temporal.proto";

service Example {
rpc Hello(HelloInput) returns (HelloOutput) {
option (temporal.v1.workflow) = {};
}
}

message HelloInput {
string name = 1;
}

message HelloOutput {
string result = 1;
}
```
</TabItem>
</Tabs>

### \{Signal\}

If the workflow definition specifies one or more signals, the generated `<Workflow>WorkflowInput` struct will include a corresponding`{Signal}` field for each registered signalthat contains a reference to the [typed signal value](/docs/guides/signals).

<Tabs>
<TabItem value="implementation-go" label="Go">
```go title="example.go"
package example

import (
examplev1 "path/to/gen/example/v1"
)

type HelloWorkflow struct {
*examplev1.HelloWorkflowInput
}

func (w *HelloWorkflow) Execute(ctx workflow.Context) (*examplev1.HelloOutput, error) {
bar, _ := w.Bar.Receive(ctx)
return &examplev1.HelloOutput{
Result: fmt.Sprintf("%s %s!", bar.GetMessage(), w.Req.GetName()),
}, nil
}
```
</TabItem>
<TabItem value="implementation-schema" label="Schema">
```protobuf title="example.proto"
syntax="proto3";

package example.v1;

import "google/protobuf/empty.proto";
import "temporal/v1/temporal.proto";

service Example {
rpc Hello(HelloInput) returns (HelloOutput) {
option (temporal.v1.workflow) = {
signal: {ref: "Bar"}
};
}

rpc Bar(BarInput) returns (google.protobuf.Empty) {
option (temporal.v1.signal) = {};
}
}

message HelloInput {
string name = 1;
}

message HelloOutput {
string result = 1;
}

message BarInput {
string message = 1;
}
```
</TabItem>
</Tabs>

### ContinueAsNew

The generated `<Workflow>WorkflowInput` struct includes a `ContinueAsNew` method that returns an appropriately configured `ContinueAsNewError`. This method is used to continue a workflow as a new workflow execution.

<Tabs>
<TabItem value="implementation-go" label="Go">
```go title="example.go"
package example

import (
examplev1 "path/to/gen/example/v1"
)

type HelloWorkflow struct {
*examplev1.HelloWorkflowInput
}

func (w *HelloWorkflow) Execute(ctx workflow.Context) (*examplev1.HelloOutput, error) {
if workflow.GetInfo(ctx).GetContinueAsNewSuggested() {
return w.ContinueAsNew(ctx, &examplev1.HelloInput{
Name: strings.ToUpper(w.Req.GetName()),
})
}
return &examplev1.HelloOutput{
Result: fmt.Sprintf("Hello %s!", w.Req.GetName()),
}, nil
}
```
</TabItem>
<TabItem value="implementation-schema" label="Schema">
```protobuf title="example.proto"
syntax="proto3";

package example.v1;

import "temporal/v1/temporal.proto";

service Example {
rpc Hello(HelloInput) returns (HelloOutput) {
option (temporal.v1.workflow) = {};
}
}
```
</TabItem>
</Tabs>

## Parameters

Every `<Workflow>Workflow` interface includes an `Execute` method that defines the workflow entrypoint. The signature of this method varies based on whether or not the workflow specifies a non-empty output message type.
Expand Down
Loading
Loading