You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Nexus-based compute providers for worker invocation and scaling
Introduce a Nexus RPC compute providers for invoke and worker-set compute providers.
As the Nexus-based compute providers are called directly from the workflow, adding a new code path to the Workflow to do that - and fallback to activity when another compute provider is used. Also backfilling the so far missing field for the Nexus endpoint - which already existed in the frontend API.
Add a cmd/nexus-subprocess-example binary demonstrating a subprocess-backed Nexus invoke service, along with Makefile targets and .gitignore entries for the generated files and new binary.
| Nexus worker set |`nexus-worker-set`| Worker set (external Nexus service) |
25
27
26
28
**Invoke** providers are called once per scaling event to start a short-lived worker.
27
29
**Worker-set** providers manage a persistent pool whose size is adjusted up or down.
28
30
31
+
### Nexus compute providers
32
+
33
+
Nexus compute providers let WCI call an implementation hosted outside the WCI worker. Unlike native providers, Nexus providers are invoked directly from workflow code through Temporal Nexus APIs, without scheduling the activity-based native provider path.
34
+
35
+
For Nexus providers, `compute.nexus_endpoint` names the Temporal Nexus endpoint to call and `compute.config` is forwarded to the Nexus service as the provider config payload.
36
+
37
+
Invoke-style Nexus providers use the `InvokeComputeProvider` service:
38
+
39
+
| Operation | Purpose |
40
+
|---|---|
41
+
|`validate_config`| Validate the provider config payload |
42
+
|`invoke_worker`| Start one worker instance |
43
+
44
+
Worker-set Nexus providers use the `WorkerSetComputeProvider` service:
45
+
46
+
| Operation | Purpose |
47
+
|---|---|
48
+
|`validate_config`| Validate the provider config payload |
49
+
|`update_worker_set_size`| Resize the managed worker set |
50
+
29
51
## Supported Scaling Algorithms
30
52
31
53
| Algorithm | Type string | Description |
@@ -90,6 +112,62 @@ A WCI spec is a map of named scaling groups:
90
112
91
113
A group with no `task_types` acts as a catch-all for any task type not claimed by another group. At most one catch-all group is allowed. The `scaling` block is optional; omitting it leaves the group with the default scaling configuration for the given compute provider.
92
114
115
+
### Nexus invoke spec example
116
+
117
+
This example routes activity scaling events to a Nexus endpoint named `subprocess-compute`. The endpoint must be configured in Temporal to route to the task queue served by the example server below. The JSON below shows the decoded config values for readability; in the Go API, `compute.config` is a `*commonpb.Payload`.
When constructing the spec in Go, encode the provider config before assigning it. Note that `PreferProtoDataConverter` comes from `go.temporal.io/server/common/sdk`, not `go.temporal.io/sdk`:
@@ -145,13 +223,46 @@ Enable per namespace via the `WorkerControllerEnabled` dynamic config setting.
145
223
## Building
146
224
147
225
```bash
148
-
# Build
226
+
# Build the worker and example binaries
149
227
make bins
150
228
229
+
# Build only the local Nexus subprocess example server
230
+
make nexus-subprocess-example
231
+
151
232
# Run tests
152
233
make test
153
234
```
154
235
236
+
## Nexus Subprocess Example Server
237
+
238
+
`cmd/nexus-subprocess-example` is a local-development Nexus service implementation backed by the `subprocess` compute provider. It registers the generated `InvokeComputeProvider` Nexus service with a Temporal SDK worker and delegates `validate_config` and `invoke_worker` to the subprocess provider.
The example is a local-development helper and is not intended to ship to production. It requires GNU `timeout` and the configured subprocess `command` to be available on `PATH`. To call it from WCI, configure a Temporal Nexus endpoint whose name matches `compute.nexus_endpoint` and whose target task queue matches `NEXUS_EXAMPLE_TASK_QUEUE`.
265
+
155
266
## Run Together with a Local Temporal Server
156
267
157
268
1. Check out the [Temporal Server](https://github.com/temporalio/temporal) alongside this repository.
0 commit comments