Skip to content

Commit 58df441

Browse files
authored
feat: Priority annotations (#1669)
1 parent 0097ccf commit 58df441

File tree

22 files changed

+192
-4
lines changed

22 files changed

+192
-4
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ env:
1919

2020
# Use these variables to force specific version of CLI/Time Skipping Server for SDK tests
2121
# TESTS_CLI_VERSION: 'v0.13.2'
22+
TESTS_CLI_VERSION: 'v1.3.1-persistence-fix.0'
2223
# TESTS_TIME_SKIPPING_SERVER_VERSION: 'v1.24.1'
2324

2425
jobs:

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ env:
1414

1515
# Use these variables to force specific version of CLI/Time Skipping Server for SDK tests
1616
# TESTS_CLI_VERSION: 'v0.13.2'
17+
TESTS_CLI_VERSION: 'v1.3.1-persistence-fix.0'
1718
# TESTS_TIME_SKIPPING_SERVER_VERSION: 'v1.24.1'
1819

1920
jobs:

packages/activity/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
*/
7171

7272
import { AsyncLocalStorage } from 'node:async_hooks';
73-
import { Logger, Duration, LogLevel, LogMetadata } from '@temporalio/common';
73+
import { Logger, Duration, LogLevel, LogMetadata, Priority } from '@temporalio/common';
7474
import { msToNumber } from '@temporalio/common/lib/time';
7575
import { SymbolBasedInstanceOfError } from '@temporalio/common/lib/type-helpers';
7676

@@ -198,6 +198,10 @@ export interface Info {
198198
* For Local Activities, this is set to the Workflow's Task Queue.
199199
*/
200200
readonly taskQueue: string;
201+
/**
202+
* Priority of this activity
203+
*/
204+
readonly priority?: Priority;
201205
}
202206

203207
/**

packages/client/src/helpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ServiceError as GrpcServiceError, status as grpcStatus } from '@grpc/grpc-js';
2-
import { LoadedDataConverter, NamespaceNotFoundError } from '@temporalio/common';
2+
import { decodePriority, LoadedDataConverter, NamespaceNotFoundError } from '@temporalio/common';
33
import {
44
decodeSearchAttributes,
55
decodeTypedSearchAttributes,
@@ -79,6 +79,7 @@ export async function executionInfoFromRaw<T>(
7979
}
8080
: undefined,
8181
raw: rawDataToEmbed,
82+
priority: decodePriority(raw.priority),
8283
};
8384
}
8485

packages/client/src/schedule-helpers.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import Long from 'long'; // eslint-disable-line import/no-named-as-default
2-
import { compileRetryPolicy, decompileRetryPolicy, extractWorkflowType, LoadedDataConverter } from '@temporalio/common';
2+
import {
3+
compilePriority,
4+
compileRetryPolicy,
5+
decodePriority,
6+
decompileRetryPolicy,
7+
extractWorkflowType,
8+
LoadedDataConverter,
9+
} from '@temporalio/common';
310
import {
411
encodeUnifiedSearchAttributes,
512
decodeSearchAttributes,
@@ -263,6 +270,7 @@ export async function encodeScheduleAction(
263270
}
264271
: undefined,
265272
header: { fields: headers },
273+
priority: action.priority ? compilePriority(action.priority) : undefined,
266274
},
267275
};
268276
}
@@ -328,6 +336,7 @@ export async function decodeScheduleAction(
328336
workflowExecutionTimeout: optionalTsToMs(pb.startWorkflow.workflowExecutionTimeout),
329337
workflowRunTimeout: optionalTsToMs(pb.startWorkflow.workflowRunTimeout),
330338
workflowTaskTimeout: optionalTsToMs(pb.startWorkflow.workflowTaskTimeout),
339+
priority: decodePriority(pb.startWorkflow.priority),
331340
};
332341
}
333342
throw new TypeError('Unsupported schedule action');

packages/client/src/schedule-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ export type ScheduleDescriptionStartWorkflowAction = ScheduleSummaryStartWorkflo
815815
| 'workflowExecutionTimeout'
816816
| 'workflowRunTimeout'
817817
| 'workflowTaskTimeout'
818+
| 'priority'
818819
>;
819820

820821
// Invariant: an existing ScheduleDescriptionAction can be used as is to create or update a schedule

packages/client/src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type * as grpc from '@grpc/grpc-js';
2-
import type { TypedSearchAttributes, SearchAttributes, SearchAttributeValue } from '@temporalio/common';
2+
import type { TypedSearchAttributes, SearchAttributes, SearchAttributeValue, Priority } from '@temporalio/common';
33
import { makeProtoEnumConverters } from '@temporalio/common/lib/internal-workflow';
44
import * as proto from '@temporalio/proto';
55
import { Replace } from '@temporalio/common/lib/type-helpers';
@@ -52,6 +52,7 @@ export interface WorkflowExecutionInfo {
5252
typedSearchAttributes: TypedSearchAttributes;
5353
parentExecution?: Required<proto.temporal.api.common.v1.IWorkflowExecution>;
5454
raw: RawWorkflowExecutionInfo;
55+
priority?: Priority;
5556
}
5657

5758
export interface CountWorkflowExecution {

packages/client/src/workflow-client.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
decodeRetryState,
2323
encodeWorkflowIdConflictPolicy,
2424
WorkflowIdConflictPolicy,
25+
compilePriority,
2526
} from '@temporalio/common';
2627
import { encodeUnifiedSearchAttributes } from '@temporalio/common/lib/converter/payload-search-attributes';
2728
import { composeInterceptors } from '@temporalio/common/lib/interceptors';
@@ -1225,6 +1226,7 @@ export class WorkflowClient extends BaseClient {
12251226
: undefined,
12261227
cronSchedule: options.cronSchedule,
12271228
header: { fields: headers },
1229+
priority: options.priority ? compilePriority(options.priority) : undefined,
12281230
};
12291231
try {
12301232
return (await this.workflowService.signalWithStartWorkflowExecution(req)).runId;
@@ -1293,6 +1295,7 @@ export class WorkflowClient extends BaseClient {
12931295
: undefined,
12941296
cronSchedule: opts.cronSchedule,
12951297
header: { fields: headers },
1298+
priority: opts.priority ? compilePriority(opts.priority) : undefined,
12961299
};
12971300
}
12981301

packages/common/src/activity-options.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { RetryPolicy } from './retry-policy';
33
import { Duration } from './time';
44
import { VersioningIntent } from './versioning-intent';
55
import { makeProtoEnumConverters } from './internal-workflow';
6+
import { Priority } from './priority';
67

78
export const ActivityCancellationType = {
89
TRY_CANCEL: 'TRY_CANCEL',
@@ -122,6 +123,11 @@ export interface ActivityOptions {
122123
* @experimental The Worker Versioning API is still being designed. Major changes are expected.
123124
*/
124125
versioningIntent?: VersioningIntent;
126+
127+
/**
128+
* Priority of this activity
129+
*/
130+
priority?: Priority;
125131
}
126132

127133
/**

packages/common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export * from './failure';
1919
export { Headers, Next } from './interceptors';
2020
export * from './interfaces';
2121
export * from './logger';
22+
export * from './priority';
2223
export * from './retry-policy';
2324
export type { Timestamp, Duration, StringValue } from './time';
2425
export * from './workflow-handle';

0 commit comments

Comments
 (0)