Skip to content

Commit 64cee58

Browse files
committed
Cleanup
1 parent 0e6dad1 commit 64cee58

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

packages/client/src/internal.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { temporal } from '@temporalio/proto';
22

33
// A key used internally to pass "hidden options to the WorkflowClient.start() call.
44
export const InternalWorkflowStartOptionsKey = Symbol.for('__temporal_client_internal_workflow_start_options');
5+
6+
// Hidden internal workflow start options, used by the temporal nexus helpers.
57
export interface InternalWorkflowStartOptions {
68
requestId?: string;
79
/**

packages/client/src/workflow-client.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,6 @@ export class WorkflowClient extends BaseClient {
12781278
const { identity, namespace } = this.options;
12791279
const internalOptions = (opts as any)[InternalWorkflowStartOptionsKey] as InternalWorkflowStartOptions | undefined;
12801280

1281-
console.log(internalOptions);
12821281
return {
12831282
namespace,
12841283
identity,

packages/nexus/src/context.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { InternalWorkflowStartOptionsKey, InternalWorkflowStartOptions } from '@
77
import { generateWorkflowRunOperationToken, loadWorkflowRunOperationToken } from './token';
88
import { convertNexusLinkToWorkflowEventLink, convertWorkflowEventLinkToNexusLink } from './link-converter';
99

10+
// Context used internally in the SDK to propagate information from the worker to the Temporal Nexus helpers.
1011
export interface HandlerContext extends BaseHandlerContext {
1112
log: Logger;
1213
client: Client;
@@ -44,18 +45,27 @@ export const log: Logger = {
4445
// TODO: also support getting a metrics handler.
4546

4647
/**
47-
* Returns a client to be used in a Nexus Operation's context, this Client is powered by the same Connection that the
48-
* worker was created with.
48+
* Returns a client to be used in a Nexus Operation's context, this Client is powered by the same NativeConnection that
49+
* the worker was created with.
4950
*/
5051
export function getClient(): Client {
5152
return getHandlerContext<HandlerContext>().client;
5253
}
5354

55+
/**
56+
* A handle to a running workflow that is returned by the {@link startWorkflow} helper.
57+
* This handle should be returned by {@link WorkflowRunOperationHandler} implementations.
58+
*/
5459
export interface WorkflowHandle<_T> {
5560
readonly workflowId: string;
5661
readonly runId: string;
5762
}
5863

64+
/**
65+
* Starts a workflow run for a {@link WorkflowRunOperationHandler}, linking the execution chain to a Nexus Operation
66+
* (subsequent runs started from continue-as-new and retries). Automatically propagates the callback, request ID, and
67+
* back and forward links from the Nexus options to the Workflow.
68+
*/
5969
export async function startWorkflow<T extends Workflow>(
6070
workflowTypeOrFunc: string | T,
6171
workflowOptions: WorkflowStartOptions<T>,
@@ -87,7 +97,7 @@ export async function startWorkflow<T extends Workflow>(
8797
internalOptions.completionCallbacks = [
8898
{
8999
nexus: { url: nexusOptions.callbackURL, header: nexusOptions.callbackHeaders },
90-
links, // pass in links here as well, the server dedupes them.
100+
links, // pass in links here as well for older servers, newer servers dedupe them.
91101
},
92102
];
93103
}
@@ -103,11 +113,17 @@ export async function startWorkflow<T extends Workflow>(
103113
return { workflowId: handle.workflowId, runId: handle.firstExecutionRunId };
104114
}
105115

116+
/**
117+
* A handler function for the {@link WorkflowRunOperation} constructor.
118+
*/
106119
export type WorkflowRunOperationHandler<I, O> = (
107120
input: I,
108121
options: nexus.StartOperationOptions
109122
) => Promise<WorkflowHandle<O>>;
110123

124+
/**
125+
* A Nexus Operation implementation that is backed by a Workflow run.
126+
*/
111127
export class WorkflowRunOperation<I, O> implements nexus.OperationHandler<I, O> {
112128
constructor(readonly handler: WorkflowRunOperationHandler<I, O>) {}
113129

packages/test/src/test-nexus-handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ test.before(async (t) => {
4747
extraArgs: [
4848
'--http-port',
4949
`${t.context.httpPort}`,
50-
// SDK tests use arbitrary callback URLs, permit that on the server
50+
// SDK tests use arbitrary callback URLs, permit that on the server.
5151
'--dynamic-config-value',
5252
'component.callbacks.allowedAddresses=[{"Pattern":"*","AllowInsecure":true}]',
53+
// TODO: remove this config when it becomes the default on the server.
5354
'--dynamic-config-value',
5455
'history.enableRequestIdRefLinks=true',
5556
],
@@ -638,7 +639,6 @@ test('WorkflowRunOperation attaches callback, link, and request ID', async (t) =
638639
};
639640
const nexusLink = convertWorkflowEventLinkToNexusLink(workflowLink);
640641

641-
// TODO: callback, link
642642
await w.runUntil(async () => {
643643
const backlinks = [];
644644
for (const requestId of [requestId1, requestId2]) {

0 commit comments

Comments
 (0)