Skip to content

feat(nexus): Initial Nexus support #1708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 60 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
01502c7
Nexus handler near complete implementation
bergundy Mar 4, 2025
0490e7b
Use the Nexus SDK ServiceRegistry
bergundy May 15, 2025
be83b0d
Upgrade core, TODO fix protos and versioning behavior
bergundy May 15, 2025
2150a48
Link converter
bergundy May 15, 2025
3dcc150
Add worker/src/nexus directory
bergundy May 15, 2025
5e4a5c3
Lint
bergundy May 15, 2025
d29dee1
getClient() and fix versioning strategy
bergundy May 15, 2025
29e6c12
WorkflowRunOperation
bergundy May 16, 2025
244cbbb
Merge remote-tracking branch 'origin/main' into nexus
bergundy May 16, 2025
0e6dad1
Fix build
bergundy May 19, 2025
64cee58
Cleanup
bergundy May 19, 2025
ab2645a
Nexus workflow client
bergundy May 19, 2025
a627bfd
Fail requests with BAD_REQUEST if payload decoding fails
bergundy May 19, 2025
69d01c0
Format code
bergundy May 21, 2025
ebf1311
Merged context and options
bergundy May 23, 2025
9ed2ddf
OperationContext
bergundy May 28, 2025
79c9303
Merge branch 'main' into pr/bergundy/1708
mjameswh Jun 4, 2025
7a836da
stash - fixing build and test issues
mjameswh Jun 5, 2025
64aee0a
Try temp solution to get CI running
mjameswh Jun 6, 2025
386fac6
Try temp solution to get CI running - Take 2
mjameswh Jun 6, 2025
86d6575
Get CI running - Fix some issues
mjameswh Jun 6, 2025
a442b2c
Fixes failing tests
mjameswh Jun 6, 2025
35ef1b9
Fixes failing test on windows
mjameswh Jun 6, 2025
d90ef24
Fixes failing tests on Node 18 and Windows
mjameswh Jun 6, 2025
40d6b52
temporalio/nexus package was not being exported to npm repo (neither …
mjameswh Jun 6, 2025
0728ae2
Fix race in test causing flakyness
mjameswh Jun 6, 2025
9073514
Trivial renames of Nexus APIs
mjameswh Jun 6, 2025
5b9e50e
Don't ack cancels
bergundy Jun 5, 2025
ae5b2fe
Add NexusOperationFailure to isCancellation helper
bergundy Jul 3, 2025
4822548
Fix build errors
mjameswh Aug 15, 2025
90e20a0
Merge commit '0c587463e548c4450049d393577c993874ef6201' into pr/bergu…
mjameswh Aug 16, 2025
9a18b02
Fix build errors
mjameswh Aug 16, 2025
3bfcc85
Merge commit 'f9c94a53ba06ae86f75b2ca94197860866ae78f5' into pr/bergu…
mjameswh Aug 20, 2025
d6af5a7
Expose Client on Activity Context + impl all services over NativeConn…
mjameswh Aug 20, 2025
bf4f774
Merge commit 'd6af5a71219fe53f016853a483d8213c41e4c2d1' into nexus-re…
mjameswh Aug 20, 2025
c5d1f51
Update to head and address multiple review comments
mjameswh Aug 20, 2025
6dae17d
Spelling
mjameswh Aug 21, 2025
9885140
Normalize activity's Context around the constructor-arg-as-fields syntax
mjameswh Aug 21, 2025
c637d02
typedoc
mjameswh Aug 21, 2025
49848e8
Remove misplaced FIXME
mjameswh Aug 21, 2025
30b35c6
Remove unneeded linter bypass directives
mjameswh Aug 21, 2025
e0212df
Improved code comment
mjameswh Aug 21, 2025
72e805e
Prefer a different style
mjameswh Aug 21, 2025
0f96a5c
Switch dependencies to Nexus RPC release 0.0.1 instead of git
mjameswh Aug 21, 2025
a3a17e6
Prefer a different style
mjameswh Aug 21, 2025
615ed56
Merge commit '72e805eda8076de8507508d7fb0396a78c72dc85' into pr/bergu…
mjameswh Aug 21, 2025
3972dba
Avoid rare case where wf start opt requestId may be left undefined ra…
mjameswh Aug 21, 2025
048cf90
Add TODO comments
mjameswh Aug 21, 2025
8d18e0d
Lint: uniformize Activity's Context class to the contructor-args-as-f…
mjameswh Aug 21, 2025
95c1838
lint: Cleanup interceptors types and add type checking on wf completi…
mjameswh Aug 21, 2025
65a7913
Merge branch 'main' into nexus-cp-3
mjameswh Aug 21, 2025
a6f3585
Merge commit '65a7913afff440a661d34948b877dc53ad99d19a' into nexus
mjameswh Aug 21, 2025
d27fbbb
Merge commit '5473ebd3442d00624fb0ed20fa82f8d5bd78e8fd' into nexus
mjameswh Aug 21, 2025
d17bbe6
Add experimental annotations where missing
mjameswh Aug 21, 2025
90d03c0
Add experimental annotations where missing
mjameswh Aug 21, 2025
0bba211
Add experimental annotations where missing
mjameswh Aug 21, 2025
999f6d6
Address review comments
mjameswh Aug 22, 2025
deb7d43
Address more review comments
mjameswh Aug 22, 2025
88b9d77
Mention "operation property name" in workflow.NexusClient typedoc
mjameswh Aug 22, 2025
622dd4c
Strengthn the NexusCLient type safety check even more
mjameswh Aug 22, 2025
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
64 changes: 63 additions & 1 deletion package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@
"@temporalio/common": "file:packages/common",
"@temporalio/create": "file:packages/create-project",
"@temporalio/interceptors-opentelemetry": "file:packages/interceptors-opentelemetry",
"@temporalio/nexus": "file:packages/nexus",
"@temporalio/nyc-test-coverage": "file:packages/nyc-test-coverage",
"@temporalio/proto": "file:packages/proto",
"@temporalio/test": "file:packages/test",
"@temporalio/testing": "file:packages/testing",
"@temporalio/worker": "file:packages/worker",
"@temporalio/workflow": "file:packages/workflow",
"nexus-rpc": "^0.0.1",
"temporalio": "file:packages/meta"
},
"devDependencies": {
Expand Down Expand Up @@ -86,6 +88,7 @@
"packages/core-bridge",
"packages/create-project",
"packages/interceptors-opentelemetry",
"packages/nexus",
"packages/nyc-test-coverage",
"packages/proto",
"packages/test",
Expand Down
45 changes: 45 additions & 0 deletions packages/client/src/internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { temporal } from '@temporalio/proto';
import { WorkflowOptions } from './workflow-options';

/**
* A symbol used to attach extra, SDK-internal options to the `WorkflowClient.start()` call.
*
* These are notably used by the Temporal Nexus helpers.
*
* @internal
* @hidden
*/
export const InternalWorkflowStartOptionsSymbol = Symbol.for('__temporal_internal_client_workflow_start_options');
export interface InternalWorkflowStartOptions extends WorkflowOptions {
[InternalWorkflowStartOptionsSymbol]?: {
/**
* Request ID to be used for the workflow.
*/
requestId?: string;

/**
* Callbacks to be called by the server when this workflow reaches a terminal state.
* If the workflow continues-as-new, these callbacks will be carried over to the new execution.
* Callback addresses must be whitelisted in the server's dynamic configuration.
*/
completionCallbacks?: temporal.api.common.v1.ICallback[];

/**
* Links to be associated with the workflow.
*/
links?: temporal.api.common.v1.ILink[];

/**
* Backlink copied by the client from the StartWorkflowExecutionResponse.
* Only populated in servers newer than 1.27.
*/
backLink?: temporal.api.common.v1.ILink;

/**
* Conflict options for when USE_EXISTING is specified.
*
* Used by the Nexus WorkflowRunOperations to attach to a callback to a running workflow.
*/
onConflictOptions?: temporal.api.workflow.v1.IOnConflictOptions;
};
}
4 changes: 2 additions & 2 deletions packages/client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ export type WorkflowExecutionDescription = Replace<
* General fixed details for this workflow execution that may appear in UI/CLI.
* This can be in Temporal markdown format and can span multiple lines.
*
* @experimental User metadata is a new API and suspectible to change.
* @experimental User metadata is a new API and susceptible to change.
*/
staticDetails: () => Promise<string | undefined>;

/**
* A single-line fixed summary for this workflow execution that may appear in the UI/CLI.
* This can be in single-line Temporal markdown format.
*
* @experimental User metadata is a new API and suspectible to change.
* @experimental User metadata is a new API and susceptible to change.
*/
staticSummary: () => Promise<string | undefined>;
};
Expand Down
13 changes: 11 additions & 2 deletions packages/client/src/workflow-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import {
} from './base-client';
import { mapAsyncIterable } from './iterators-utils';
import { WorkflowUpdateStage, encodeWorkflowUpdateStage } from './workflow-update-stage';
import { InternalWorkflowStartOptionsSymbol, InternalWorkflowStartOptions } from './internal';

const UpdateWorkflowExecutionLifecycleStage = temporal.api.enums.v1.UpdateWorkflowExecutionLifecycleStage;

Expand Down Expand Up @@ -1248,8 +1249,13 @@ export class WorkflowClient extends BaseClient {
protected async _startWorkflowHandler(input: WorkflowStartInput): Promise<string> {
const req = await this.createStartWorkflowRequest(input);
const { options: opts, workflowType } = input;
const internalOptions = (opts as InternalWorkflowStartOptions)[InternalWorkflowStartOptionsSymbol];
try {
return (await this.workflowService.startWorkflowExecution(req)).runId;
const response = await this.workflowService.startWorkflowExecution(req);
if (internalOptions != null) {
internalOptions.backLink = response.link ?? undefined;
}
return response.runId;
} catch (err: any) {
if (err.code === grpcStatus.ALREADY_EXISTS) {
throw new WorkflowExecutionAlreadyStartedError(
Expand All @@ -1265,10 +1271,12 @@ export class WorkflowClient extends BaseClient {
protected async createStartWorkflowRequest(input: WorkflowStartInput): Promise<StartWorkflowExecutionRequest> {
const { options: opts, workflowType, headers } = input;
const { identity, namespace } = this.options;
const internalOptions = (opts as InternalWorkflowStartOptions)[InternalWorkflowStartOptionsSymbol];

return {
namespace,
identity,
requestId: uuid4(),
requestId: internalOptions?.requestId ?? uuid4(),
workflowId: opts.workflowId,
workflowIdReusePolicy: encodeWorkflowIdReusePolicy(opts.workflowIdReusePolicy),
workflowIdConflictPolicy: encodeWorkflowIdConflictPolicy(opts.workflowIdConflictPolicy),
Expand All @@ -1295,6 +1303,7 @@ export class WorkflowClient extends BaseClient {
userMetadata: await encodeUserMetadata(this.dataConverter, opts.staticSummary, opts.staticDetails),
priority: opts.priority ? compilePriority(opts.priority) : undefined,
versioningOverride: opts.versioningOverride ?? undefined,
...filterNullAndUndefined(internalOptions ?? {}),
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@temporalio/proto": "file:../proto",
"long": "^5.2.3",
"ms": "^3.0.0-canary.1",
"nexus-rpc": "^0.0.1",
"proto3-json-serializer": "^2.0.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/activity-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export interface ActivityOptions {
* A fixed, single-line summary for this workflow execution that may appear in the UI/CLI.
* This can be in single-line Temporal markdown format.
*
* @experimental User metadata is a new API and suspectible to change.
* @experimental User metadata is a new API and susceptible to change.
*/
summary?: string;

Expand Down Expand Up @@ -206,7 +206,7 @@ export interface LocalActivityOptions {
* A fixed, single-line summary for this workflow execution that may appear in the UI/CLI.
* This can be in single-line Temporal markdown format.
*
* @experimental User metadata is a new API and suspectible to change.
* @experimental User metadata is a new API and susceptible to change.
*/
summary?: string;
}
Loading
Loading