Skip to content

Commit 808e562

Browse files
authored
feat: Add Schedule API (#937)
1 parent 66e85cb commit 808e562

File tree

13 files changed

+2553
-11
lines changed

13 files changed

+2553
-11
lines changed

package-lock.json

Lines changed: 25 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/client/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
"@grpc/grpc-js": "^1.6.7",
1717
"@temporalio/common": "file:../common",
1818
"@temporalio/proto": "file:../proto",
19-
"ms": "^2.1.3",
19+
"long": "^5.2.0",
2020
"uuid": "^8.3.2"
2121
},
2222
"devDependencies": {
23+
"@types/long": "^5.0.0",
2324
"protobufjs": "^7.0.0"
2425
},
2526
"bugs": {

packages/client/src/client.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import os from 'os';
66
import { AsyncCompletionClient } from './async-completion-client';
77
import { Connection } from './connection';
88
import { ClientInterceptors } from './interceptors';
9+
import { ScheduleClient } from './schedule-client';
910
import { ConnectionLike, Metadata, WorkflowService } from './types';
1011
import { WorkflowClient } from './workflow-client';
1112

@@ -95,6 +96,12 @@ export class Client {
9596
* (Async) Activity completion sub-client - use to manually manage Activities
9697
*/
9798
public readonly activity: AsyncCompletionClient;
99+
/**
100+
* Schedule sub-client - use to start and interact with Schedules
101+
*
102+
* @experimental
103+
*/
104+
public readonly schedule: ScheduleClient;
98105

99106
constructor(options?: ClientOptions) {
100107
this.connection = options?.connection ?? Connection.lazy();
@@ -119,6 +126,13 @@ export class Client {
119126
connection: this.connection,
120127
dataConverter: loadedDataConverter,
121128
});
129+
130+
this.schedule = new ScheduleClient({
131+
...base,
132+
connection: this.connection,
133+
dataConverter: loadedDataConverter,
134+
interceptors: interceptors.schedule,
135+
});
122136
}
123137

124138
/**

packages/client/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ export * from './interceptors';
3636
export * from './types';
3737
export * from './workflow-client';
3838
export * from './workflow-options';
39+
export * from './schedule-types';
40+
export * from './schedule-client';

packages/client/src/interceptors.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { Headers, Next } from '@temporalio/common';
88
import { temporal } from '@temporalio/proto';
9+
import { CompiledScheduleOptions } from './schedule-types';
910
import {
1011
DescribeWorkflowExecutionResponse,
1112
RequestCancelWorkflowExecutionResponse,
@@ -131,11 +132,42 @@ export interface WorkflowClientInterceptors {
131132
calls?: WorkflowClientCallsInterceptorFactory[];
132133
}
133134

135+
/**
136+
* Implement any of these methods to intercept ScheduleClient outbound calls
137+
*
138+
* @experimental
139+
*/
140+
export interface ScheduleClientInterceptor {
141+
/**
142+
* Intercept a service call to CreateSchedule
143+
*/
144+
create?: (input: CreateScheduleInput, next: Next<this, 'create'>) => Promise<CreateScheduleOutput>;
145+
}
146+
147+
/**
148+
* Input for {@link ScheduleClientInterceptor.create}
149+
*
150+
* @experimental
151+
*/
152+
export interface CreateScheduleInput {
153+
readonly headers: Headers;
154+
readonly options: CompiledScheduleOptions;
155+
}
156+
157+
export type CreateScheduleOutput = {
158+
readonly conflictToken: Uint8Array;
159+
};
160+
134161
/**
135162
* Interceptors for any high-level SDK client.
136163
*
137-
* NOTE: Currently only for {@link WorkflowClient}. More will be added later as needed.
164+
* NOTE: Currently only for {@link WorkflowClient} and {@link ScheduleClient}. More will be added later as needed.
138165
*/
139166
export interface ClientInterceptors {
140167
workflow?: WorkflowClientInterceptors;
168+
169+
/**
170+
* @experimental
171+
*/
172+
schedule?: ScheduleClientInterceptor[];
141173
}

0 commit comments

Comments
 (0)