@temporalio/core-bridge 0.13.0 → 0.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +203 -78
- package/Cargo.toml +3 -3
- package/index.d.ts +195 -0
- package/index.node +0 -0
- package/package.json +10 -6
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/{x86_64-pc-windows-gnu → aarch64-unknown-linux-gnu}/index.node +0 -0
- package/releases/x86_64-apple-darwin/index.node +0 -0
- package/releases/x86_64-pc-windows-msvc/index.node +0 -0
- package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
- package/scripts/build.js +77 -34
- package/sdk-core/.buildkite/docker/Dockerfile +1 -1
- package/sdk-core/CODEOWNERS +1 -1
- package/sdk-core/Cargo.toml +6 -5
- package/sdk-core/fsm/Cargo.toml +1 -1
- package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +2 -2
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +8 -9
- package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +13 -7
- package/sdk-core/fsm/rustfsm_trait/Cargo.toml +2 -2
- package/sdk-core/fsm/rustfsm_trait/src/lib.rs +1 -1
- package/sdk-core/protos/local/activity_result.proto +10 -1
- package/sdk-core/protos/local/workflow_activation.proto +6 -3
- package/sdk-core/sdk-core-protos/Cargo.toml +4 -4
- package/sdk-core/sdk-core-protos/src/lib.rs +44 -49
- package/sdk-core/src/core_tests/activity_tasks.rs +5 -5
- package/sdk-core/src/core_tests/child_workflows.rs +55 -29
- package/sdk-core/src/core_tests/determinism.rs +19 -9
- package/sdk-core/src/core_tests/mod.rs +3 -3
- package/sdk-core/src/core_tests/retry.rs +96 -2
- package/sdk-core/src/core_tests/workers.rs +1 -1
- package/sdk-core/src/core_tests/workflow_tasks.rs +278 -4
- package/sdk-core/src/errors.rs +27 -44
- package/sdk-core/src/lib.rs +13 -3
- package/sdk-core/src/machines/activity_state_machine.rs +44 -5
- package/sdk-core/src/machines/child_workflow_state_machine.rs +31 -11
- package/sdk-core/src/machines/complete_workflow_state_machine.rs +1 -1
- package/sdk-core/src/machines/continue_as_new_workflow_state_machine.rs +1 -1
- package/sdk-core/src/machines/mod.rs +18 -23
- package/sdk-core/src/machines/patch_state_machine.rs +8 -8
- package/sdk-core/src/machines/signal_external_state_machine.rs +22 -1
- package/sdk-core/src/machines/timer_state_machine.rs +21 -3
- package/sdk-core/src/machines/transition_coverage.rs +3 -3
- package/sdk-core/src/machines/workflow_machines.rs +11 -11
- package/sdk-core/src/pending_activations.rs +27 -22
- package/sdk-core/src/pollers/gateway.rs +28 -7
- package/sdk-core/src/pollers/poll_buffer.rs +6 -5
- package/sdk-core/src/pollers/retry.rs +193 -136
- package/sdk-core/src/prototype_rust_sdk/workflow_context.rs +61 -46
- package/sdk-core/src/prototype_rust_sdk/workflow_future.rs +13 -12
- package/sdk-core/src/prototype_rust_sdk.rs +17 -23
- package/sdk-core/src/telemetry/metrics.rs +2 -4
- package/sdk-core/src/telemetry/mod.rs +6 -7
- package/sdk-core/src/test_help/canned_histories.rs +17 -93
- package/sdk-core/src/test_help/history_builder.rs +51 -2
- package/sdk-core/src/test_help/history_info.rs +2 -2
- package/sdk-core/src/test_help/mod.rs +21 -34
- package/sdk-core/src/worker/activities/activity_heartbeat_manager.rs +246 -138
- package/sdk-core/src/worker/activities.rs +47 -45
- package/sdk-core/src/worker/config.rs +11 -0
- package/sdk-core/src/worker/dispatcher.rs +5 -5
- package/sdk-core/src/worker/mod.rs +86 -56
- package/sdk-core/src/workflow/driven_workflow.rs +3 -3
- package/sdk-core/src/workflow/history_update.rs +1 -1
- package/sdk-core/src/workflow/mod.rs +2 -1
- package/sdk-core/src/workflow/workflow_tasks/cache_manager.rs +13 -17
- package/sdk-core/src/workflow/workflow_tasks/concurrency_manager.rs +10 -18
- package/sdk-core/src/workflow/workflow_tasks/mod.rs +72 -57
- package/sdk-core/test_utils/Cargo.toml +1 -1
- package/sdk-core/test_utils/src/lib.rs +2 -2
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +131 -2
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +2 -2
- package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +49 -0
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +2 -2
- package/sdk-core/tests/integ_tests/workflow_tests.rs +74 -47
- package/src/conversions.rs +17 -0
- package/src/errors.rs +0 -7
- package/src/lib.rs +0 -20
package/index.d.ts
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { TLSConfig } from '@temporalio/common';
|
|
2
|
+
import { SpanContext } from '@opentelemetry/api';
|
|
3
|
+
|
|
4
|
+
export { TLSConfig };
|
|
5
|
+
|
|
6
|
+
export interface RetryOptions {
|
|
7
|
+
/** Initial wait time before the first retry. */
|
|
8
|
+
initialInterval: number;
|
|
9
|
+
/**
|
|
10
|
+
* Randomization jitter that is used as a multiplier for the current retry interval
|
|
11
|
+
* and is added or subtracted from the interval length.
|
|
12
|
+
*/
|
|
13
|
+
randomizationFactor: number;
|
|
14
|
+
/** Rate at which retry time should be increased, until it reaches max_interval. */
|
|
15
|
+
multiplier: number;
|
|
16
|
+
/** Maximum amount of time to wait between retries. */
|
|
17
|
+
maxInterval: number;
|
|
18
|
+
/** Maximum total amount of time requests should be retried for, if None is set then no limit will be used. */
|
|
19
|
+
maxElapsedTime?: number;
|
|
20
|
+
/** Maximum number of retry attempts. */
|
|
21
|
+
maxRetries: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ServerOptions {
|
|
25
|
+
/**
|
|
26
|
+
* The URL of the Temporal server to connect to
|
|
27
|
+
*/
|
|
28
|
+
url: string;
|
|
29
|
+
/**
|
|
30
|
+
* What namespace will we operate under
|
|
31
|
+
*/
|
|
32
|
+
namespace: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A human-readable string that can identify your worker
|
|
36
|
+
*/
|
|
37
|
+
identity: string;
|
|
38
|
+
/**
|
|
39
|
+
* A string that should be unique to the exact worker code/binary being executed
|
|
40
|
+
*/
|
|
41
|
+
workerBinaryId: string;
|
|
42
|
+
|
|
43
|
+
/** Version string for the whole node SDK. Should never be set by user */
|
|
44
|
+
sdkVersion: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* TLS configuration options.
|
|
48
|
+
*
|
|
49
|
+
* Pass undefined to use a non-encrypted connection or an empty object to
|
|
50
|
+
* connect with TLS without any customization.
|
|
51
|
+
*/
|
|
52
|
+
tls?: TLSConfig;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Optional retry options for server requests.
|
|
56
|
+
*/
|
|
57
|
+
retry?: RetryOptions;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Configure a Core instance
|
|
62
|
+
*/
|
|
63
|
+
export interface CoreOptions {
|
|
64
|
+
/**
|
|
65
|
+
* Options for communicating with the Temporal server
|
|
66
|
+
*/
|
|
67
|
+
serverOptions: ServerOptions;
|
|
68
|
+
/**
|
|
69
|
+
* Telemetry options
|
|
70
|
+
*/
|
|
71
|
+
telemetryOptions: TelemetryOptions;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface TelemetryOptions {
|
|
75
|
+
/**
|
|
76
|
+
* If set, telemetry is turned on and this URL must be the URL of a gRPC
|
|
77
|
+
* OTel collector.
|
|
78
|
+
*/
|
|
79
|
+
oTelCollectorUrl?: string;
|
|
80
|
+
/**
|
|
81
|
+
* A string in the env filter format specified here:
|
|
82
|
+
* https://docs.rs/tracing-subscriber/0.2.20/tracing_subscriber/struct.EnvFilter.html
|
|
83
|
+
*
|
|
84
|
+
* Which determines what tracing data is collected in the Core SDK
|
|
85
|
+
*/
|
|
86
|
+
tracingFilter?: string;
|
|
87
|
+
/** What level, if any, logs should be forwarded from core at */
|
|
88
|
+
// These strings should match the log::LevelFilter enum in rust
|
|
89
|
+
logForwardingLevel: 'OFF' | LogLevel;
|
|
90
|
+
/** If set, metrics will be exposed on an http server in this process for direct scraping by
|
|
91
|
+
* prometheus. If used in conjunction with the OTel collector, metrics will *not* be exported
|
|
92
|
+
* to the collector, but traces will be.
|
|
93
|
+
*
|
|
94
|
+
* The string provided must be an address the server will bind to. For example, `0.0.0.0:1234`.
|
|
95
|
+
* Metrics will be available for scraping under the standard `/metrics` route.
|
|
96
|
+
*/
|
|
97
|
+
prometheusMetricsBindAddress?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface WorkerOptions {
|
|
101
|
+
/**
|
|
102
|
+
* The task queue the worker will pull from
|
|
103
|
+
*/
|
|
104
|
+
taskQueue: string;
|
|
105
|
+
|
|
106
|
+
maxConcurrentActivityTaskExecutions: number;
|
|
107
|
+
maxConcurrentWorkflowTaskExecutions: number;
|
|
108
|
+
maxConcurrentWorkflowTaskPolls: number;
|
|
109
|
+
maxConcurrentActivityTaskPolls: number;
|
|
110
|
+
/**
|
|
111
|
+
* `maxConcurrentWorkflowTaskPolls` * this number = the number of max pollers that will
|
|
112
|
+
* be allowed for the nonsticky queue when sticky tasks are enabled. If both defaults are used,
|
|
113
|
+
* the sticky queue will allow 4 max pollers while the nonsticky queue will allow one. The
|
|
114
|
+
* minimum for either poller is 1, so if `max_concurrent_wft_polls` is 1 and sticky queues are
|
|
115
|
+
* enabled, there will be 2 concurrent polls.
|
|
116
|
+
*/
|
|
117
|
+
nonStickyToStickyPollRatio: number;
|
|
118
|
+
/**
|
|
119
|
+
* How long a workflow task is allowed to sit on the sticky queue before it is timed out
|
|
120
|
+
* and moved to the non-sticky queue where it may be picked up by any worker.
|
|
121
|
+
*/
|
|
122
|
+
stickyQueueScheduleToStartTimeoutMs: number;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Maximum number of Workflow instances to cache before automatic eviction
|
|
126
|
+
*/
|
|
127
|
+
maxCachedWorkflows: number;
|
|
128
|
+
/**
|
|
129
|
+
* Longest interval for throttling activity heartbeats
|
|
130
|
+
* @default 60 seconds
|
|
131
|
+
*/
|
|
132
|
+
maxHeartbeatThrottleIntervalMs: number;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Default interval for throttling activity heartbeats in case
|
|
136
|
+
* `ActivityOptions.heartbeat_timeout` is unset.
|
|
137
|
+
* When the timeout *is* set in the `ActivityOptions`, throttling is set to
|
|
138
|
+
* `heartbeat_timeout * 0.8`.
|
|
139
|
+
* @default 30 seconds
|
|
140
|
+
*/
|
|
141
|
+
defaultHeartbeatThrottleIntervalMs: number;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Log level - must match rust log level names */
|
|
145
|
+
export type LogLevel = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
|
|
146
|
+
|
|
147
|
+
export interface LogEntry {
|
|
148
|
+
/** Log message */
|
|
149
|
+
message: string;
|
|
150
|
+
/**
|
|
151
|
+
* Time since epoch [seconds, nanos].
|
|
152
|
+
*
|
|
153
|
+
* Should be switched to bigint once it is supported in neon.
|
|
154
|
+
*/
|
|
155
|
+
timestamp: [number, number];
|
|
156
|
+
/** Log level */
|
|
157
|
+
level: LogLevel;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface Worker {}
|
|
161
|
+
export interface Core {}
|
|
162
|
+
|
|
163
|
+
export declare type PollCallback = (err: Error, result: ArrayBuffer) => void;
|
|
164
|
+
export declare type WorkerCallback = (err: Error, result: Worker) => void;
|
|
165
|
+
export declare type CoreCallback = (err: Error, result: Core) => void;
|
|
166
|
+
export declare type VoidCallback = (err: Error, result: void) => void;
|
|
167
|
+
export declare type LogsCallback = (err: Error, result: LogEntry[]) => void;
|
|
168
|
+
|
|
169
|
+
// TODO: improve type, for some reason Error is not accepted here
|
|
170
|
+
export declare function registerErrors(errors: Record<string, any>): void;
|
|
171
|
+
export declare function newCore(coreOptions: CoreOptions, callback: CoreCallback): void;
|
|
172
|
+
export declare function newWorker(core: Core, workerOptions: WorkerOptions, callback: WorkerCallback): void;
|
|
173
|
+
export declare function workerShutdown(worker: Worker, callback: VoidCallback): void;
|
|
174
|
+
export declare function coreShutdown(core: Core, callback: VoidCallback): void;
|
|
175
|
+
export declare function corePollLogs(core: Core, callback: LogsCallback): void;
|
|
176
|
+
export declare function workerPollWorkflowActivation(
|
|
177
|
+
worker: Worker,
|
|
178
|
+
spanContext: SpanContext,
|
|
179
|
+
callback: PollCallback
|
|
180
|
+
): void;
|
|
181
|
+
export declare function workerCompleteWorkflowActivation(
|
|
182
|
+
worker: Worker,
|
|
183
|
+
spanContext: SpanContext,
|
|
184
|
+
result: ArrayBuffer,
|
|
185
|
+
callback: VoidCallback
|
|
186
|
+
): void;
|
|
187
|
+
export declare function workerPollActivityTask(worker: Worker, spanContext: SpanContext, callback: PollCallback): void;
|
|
188
|
+
export declare function workerCompleteActivityTask(
|
|
189
|
+
worker: Worker,
|
|
190
|
+
spanContext: SpanContext,
|
|
191
|
+
result: ArrayBuffer,
|
|
192
|
+
callback: VoidCallback
|
|
193
|
+
): void;
|
|
194
|
+
export declare function workerRecordActivityHeartbeat(worker: Worker, heartbeat: ArrayBuffer): void;
|
|
195
|
+
export declare function getTimeOfDay(): [number, number];
|
package/index.node
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/core-bridge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"description": "Temporal.io SDK Core<>Node bridge",
|
|
5
5
|
"main": "index.node",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build-rust": "
|
|
8
|
+
"build-rust": "node ./scripts/build.js --force",
|
|
9
9
|
"build": "npm run build-rust",
|
|
10
10
|
"install": "node ./scripts/build.js"
|
|
11
11
|
},
|
|
@@ -18,8 +18,11 @@
|
|
|
18
18
|
"author": "Roey Berman <roey@temporal.io>",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@
|
|
22
|
-
"
|
|
21
|
+
"@opentelemetry/api": "^1.0.3",
|
|
22
|
+
"@temporalio/common": "^0.16.0",
|
|
23
|
+
"arg": "^5.0.1",
|
|
24
|
+
"cargo-cp-artifact": "^0.1.4",
|
|
25
|
+
"which": "^2.0.2"
|
|
23
26
|
},
|
|
24
27
|
"bugs": {
|
|
25
28
|
"url": "https://github.com/temporalio/sdk-typescript/issues"
|
|
@@ -31,10 +34,11 @@
|
|
|
31
34
|
"releases",
|
|
32
35
|
"sdk-core",
|
|
33
36
|
"Cargo.toml",
|
|
34
|
-
"Cargo.lock"
|
|
37
|
+
"Cargo.lock",
|
|
38
|
+
"index.d.ts"
|
|
35
39
|
],
|
|
36
40
|
"publishConfig": {
|
|
37
41
|
"access": "public"
|
|
38
42
|
},
|
|
39
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "af54140a4da7e191c06627c5e06b92a3fd929bcc"
|
|
40
44
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/scripts/build.js
CHANGED
|
@@ -1,27 +1,71 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const arg = require('arg');
|
|
2
3
|
const os = require('os');
|
|
3
4
|
const fs = require('fs');
|
|
5
|
+
const which = require('which');
|
|
4
6
|
const { spawnSync } = require('child_process');
|
|
7
|
+
const { version } = require('../package.json');
|
|
5
8
|
|
|
6
9
|
process.chdir(path.resolve(__dirname, '..'));
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const forceBuild = new Set(['y', 't', '1', 'yes', 'true']).has(
|
|
19
|
-
(process.env.TEMPORAL_WORKER_FORCE_BUILD || '').toLowerCase()
|
|
20
|
-
);
|
|
11
|
+
// List of tested compile targets
|
|
12
|
+
const targets = [
|
|
13
|
+
'x86_64-apple-darwin',
|
|
14
|
+
'aarch64-apple-darwin',
|
|
15
|
+
'x86_64-unknown-linux-gnu',
|
|
16
|
+
'aarch64-unknown-linux-gnu',
|
|
17
|
+
// TODO: this is not supported on macos
|
|
18
|
+
'x86_64-pc-windows-msvc',
|
|
19
|
+
'x86_64-pc-windows-gnu',
|
|
20
|
+
];
|
|
21
21
|
|
|
22
22
|
const archAlias = { x64: 'x86_64', arm64: 'aarch64' };
|
|
23
23
|
const platformMapping = { darwin: 'apple-darwin', linux: 'unknown-linux-gnu', win32: 'pc-windows-gnu' };
|
|
24
24
|
|
|
25
|
+
const args = arg({
|
|
26
|
+
'--help': Boolean,
|
|
27
|
+
'-h': '--help',
|
|
28
|
+
'--version': Boolean,
|
|
29
|
+
'-v': '--version',
|
|
30
|
+
'--target': [String],
|
|
31
|
+
'--force': Boolean,
|
|
32
|
+
'-f': '--force',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const HELP_STRING = `${path.basename(
|
|
36
|
+
process.argv[1]
|
|
37
|
+
)} compiles the Core SDK and temporal-sdk-typescript-bridge Rust libraries
|
|
38
|
+
|
|
39
|
+
Options:
|
|
40
|
+
|
|
41
|
+
-h, --help Show this help message and exit
|
|
42
|
+
-v, --version Show program's version number and exit
|
|
43
|
+
-f, --force Forces a build instead of using a prebuilt binary
|
|
44
|
+
-t, --target Compilation targets, choose any of:
|
|
45
|
+
${targets.concat('all').join('\n ')}
|
|
46
|
+
|
|
47
|
+
Happy compiling!`;
|
|
48
|
+
|
|
49
|
+
if (args['--help']) {
|
|
50
|
+
console.log(HELP_STRING);
|
|
51
|
+
process.exit();
|
|
52
|
+
}
|
|
53
|
+
if (args['--version']) {
|
|
54
|
+
console.log(version);
|
|
55
|
+
process.exit();
|
|
56
|
+
}
|
|
57
|
+
// });
|
|
58
|
+
|
|
59
|
+
// prepare recompile options
|
|
60
|
+
const targetsArg = args['--target'] || [];
|
|
61
|
+
const requestedTargets = targetsArg.includes('all') ? targets : targetsArg;
|
|
62
|
+
const unsupportedTargets = requestedTargets.filter((t) => !targets.includes(t));
|
|
63
|
+
if (unsupportedTargets.length) {
|
|
64
|
+
console.error(`Unsupported targets ${JSON.stringify(unsupportedTargets)}`);
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
const forceBuild = args['--force'];
|
|
68
|
+
|
|
25
69
|
function compile(target) {
|
|
26
70
|
console.log('Compiling bridge', { target });
|
|
27
71
|
|
|
@@ -33,26 +77,25 @@ function compile(target) {
|
|
|
33
77
|
throw err;
|
|
34
78
|
}
|
|
35
79
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
80
|
+
|
|
81
|
+
const argv = [
|
|
82
|
+
'--artifact',
|
|
83
|
+
'cdylib',
|
|
84
|
+
'temporal_sdk_typescript_bridge',
|
|
85
|
+
out,
|
|
86
|
+
'--',
|
|
87
|
+
'cargo',
|
|
88
|
+
'build',
|
|
89
|
+
'--message-format=json-render-diagnostics',
|
|
90
|
+
'--release',
|
|
91
|
+
...(target ? ['--target', target] : []),
|
|
92
|
+
];
|
|
93
|
+
const cmd = which.sync('cargo-cp-artifact');
|
|
94
|
+
|
|
95
|
+
console.log('Running', cmd, argv);
|
|
96
|
+
const { status } = spawnSync(cmd, argv, {
|
|
97
|
+
stdio: 'inherit',
|
|
98
|
+
});
|
|
56
99
|
if (status !== 0) {
|
|
57
100
|
throw new Error(`Failed to build${target ? ' for ' + target : ''}`);
|
|
58
101
|
}
|
|
@@ -104,7 +147,7 @@ if (requestedTargets.length > 0) {
|
|
|
104
147
|
}
|
|
105
148
|
}
|
|
106
149
|
} else {
|
|
107
|
-
console.log('
|
|
150
|
+
console.log('Forced the build via --force');
|
|
108
151
|
compile();
|
|
109
152
|
}
|
|
110
153
|
}
|
package/sdk-core/CODEOWNERS
CHANGED
package/sdk-core/Cargo.toml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "temporal-sdk-core"
|
|
3
3
|
version = "0.1.0-alpha.1"
|
|
4
4
|
authors = ["Spencer Judge <spencer@temporal.io>", "Vitaly Arbuzov <vitaly@temporal.io>"]
|
|
5
|
-
edition = "
|
|
5
|
+
edition = "2021"
|
|
6
6
|
license-file = "LICENSE.txt"
|
|
7
7
|
description = "Library for building new Temporal SDKs"
|
|
8
8
|
homepage = "https://temporal.io/"
|
|
@@ -36,15 +36,16 @@ opentelemetry-otlp = { version = "0.9.0", features = ["tokio", "metrics"] }
|
|
|
36
36
|
opentelemetry-prometheus = "0.9.0"
|
|
37
37
|
parking_lot = { version = "0.11", features = ["send_guard"] }
|
|
38
38
|
prometheus = "0.12"
|
|
39
|
-
prost = "0.
|
|
40
|
-
prost-types = "0.
|
|
39
|
+
prost = "0.9"
|
|
40
|
+
prost-types = "0.9"
|
|
41
41
|
rand = "0.8.3"
|
|
42
42
|
ringbuf = "0.2"
|
|
43
43
|
slotmap = "1.0"
|
|
44
44
|
thiserror = "1.0"
|
|
45
45
|
tokio = { version = "1.1", features = ["rt", "rt-multi-thread", "parking_lot", "time", "fs"] }
|
|
46
|
+
tokio-util = { version = "0.6.9" }
|
|
46
47
|
tokio-stream = "0.1"
|
|
47
|
-
tonic = { version = "0.
|
|
48
|
+
tonic = { version = "0.6", features = ["tls", "tls-roots"] }
|
|
48
49
|
tower = "0.4"
|
|
49
50
|
tracing = { version = "0.1", features = ["log-always"] }
|
|
50
51
|
tracing-futures = "0.2"
|
|
@@ -70,7 +71,7 @@ rstest = "0.10"
|
|
|
70
71
|
test_utils = { path = "test_utils" }
|
|
71
72
|
|
|
72
73
|
[build-dependencies]
|
|
73
|
-
tonic-build = "0.
|
|
74
|
+
tonic-build = "0.6"
|
|
74
75
|
|
|
75
76
|
[workspace]
|
|
76
77
|
members = [".", "fsm", "test_utils", "sdk-core-protos"]
|
package/sdk-core/fsm/Cargo.toml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "rustfsm"
|
|
3
3
|
version = "0.1.0"
|
|
4
4
|
authors = ["Spencer Judge <spencer@temporal.io>"]
|
|
5
|
-
edition = "
|
|
5
|
+
edition = "2021"
|
|
6
6
|
license-file = "LICENSE.txt"
|
|
7
7
|
description = "Define state machines that can accept events and produce commands"
|
|
8
8
|
homepage = "https://temporal.io/"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "rustfsm_procmacro"
|
|
3
3
|
version = "0.1.0"
|
|
4
4
|
authors = ["Spencer Judge <spencer@temporal.io>"]
|
|
5
|
-
edition = "
|
|
5
|
+
edition = "2021"
|
|
6
6
|
license-file = "LICENSE.txt"
|
|
7
7
|
description = "Procmacro sub-crate of the `rustfsm` crate"
|
|
8
8
|
|
|
@@ -24,4 +24,4 @@ rustfsm_trait = { version = "0.1", path = "../rustfsm_trait" }
|
|
|
24
24
|
trybuild = { version = "1.0", features = ["diff"] }
|
|
25
25
|
|
|
26
26
|
[package.metadata.workspaces]
|
|
27
|
-
independent = true
|
|
27
|
+
independent = true
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
extern crate proc_macro;
|
|
2
|
-
|
|
3
1
|
use proc_macro::TokenStream;
|
|
4
2
|
use quote::{quote, quote_spanned};
|
|
5
3
|
use std::collections::{hash_map::Entry, HashMap, HashSet};
|
|
@@ -82,7 +80,7 @@ use syn::{
|
|
|
82
80
|
/// ReadingCard { card_data: data.clone() }.into(),
|
|
83
81
|
/// SharedState { last_id: Some(data) }
|
|
84
82
|
/// )
|
|
85
|
-
/// }
|
|
83
|
+
/// }
|
|
86
84
|
/// }
|
|
87
85
|
/// }
|
|
88
86
|
/// }
|
|
@@ -200,7 +198,7 @@ impl Parse for StateMachineDefinition {
|
|
|
200
198
|
// Parse visibility if present
|
|
201
199
|
let visibility = input.parse()?;
|
|
202
200
|
// parse the state machine name, command type, and error type
|
|
203
|
-
let (name, command_type, error_type, shared_state_type) = parse_machine_types(
|
|
201
|
+
let (name, command_type, error_type, shared_state_type) = parse_machine_types(input)
|
|
204
202
|
.map_err(|mut e| {
|
|
205
203
|
e.combine(Error::new(
|
|
206
204
|
e.span(),
|
|
@@ -235,7 +233,7 @@ impl Parse for StateMachineDefinition {
|
|
|
235
233
|
}
|
|
236
234
|
}
|
|
237
235
|
|
|
238
|
-
fn parse_machine_types(input:
|
|
236
|
+
fn parse_machine_types(input: ParseStream) -> Result<(Ident, Ident, Ident, Option<Type>)> {
|
|
239
237
|
let _: kw::name = input.parse()?;
|
|
240
238
|
let name: Ident = input.parse()?;
|
|
241
239
|
input.parse::<Token![;]>()?;
|
|
@@ -443,7 +441,7 @@ impl StateMachineDefinition {
|
|
|
443
441
|
},
|
|
444
442
|
multi_dests => {
|
|
445
443
|
let string_dests: Vec<_> = multi_dests.iter()
|
|
446
|
-
.map(
|
|
444
|
+
.map(ToString::to_string).collect();
|
|
447
445
|
let enum_ident = Ident::new(&string_dests.join("Or"),
|
|
448
446
|
multi_dests[0].span());
|
|
449
447
|
let multi_dest_enum = quote! {
|
|
@@ -558,6 +556,7 @@ impl StateMachineDefinition {
|
|
|
558
556
|
fn state(&self) -> &Self::State {
|
|
559
557
|
&self.state
|
|
560
558
|
}
|
|
559
|
+
|
|
561
560
|
fn set_state(&mut self, new: Self::State) {
|
|
562
561
|
self.state = new
|
|
563
562
|
}
|
|
@@ -590,7 +589,7 @@ impl StateMachineDefinition {
|
|
|
590
589
|
#trait_impl
|
|
591
590
|
};
|
|
592
591
|
|
|
593
|
-
output
|
|
592
|
+
TokenStream::from(output)
|
|
594
593
|
}
|
|
595
594
|
|
|
596
595
|
fn all_states(&self) -> HashSet<Ident> {
|
|
@@ -628,7 +627,7 @@ impl StateMachineDefinition {
|
|
|
628
627
|
/// Merge transition's dest state lists for those with the same from state & handler
|
|
629
628
|
fn merge_transition_dests(transitions: Vec<Transition>) -> Vec<Transition> {
|
|
630
629
|
let mut map = HashMap::<_, Transition>::new();
|
|
631
|
-
|
|
630
|
+
for t in transitions {
|
|
632
631
|
// We want to use the transition sans-destinations as the key
|
|
633
632
|
let without_dests = {
|
|
634
633
|
let mut wd = t.clone();
|
|
@@ -643,6 +642,6 @@ fn merge_transition_dests(transitions: Vec<Transition>) -> Vec<Transition> {
|
|
|
643
642
|
v.insert(t);
|
|
644
643
|
}
|
|
645
644
|
}
|
|
646
|
-
}
|
|
645
|
+
}
|
|
647
646
|
map.into_iter().map(|(_, v)| v).collect()
|
|
648
647
|
}
|
package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
error[E0277]: the trait bound `One: From<Two>` is not satisfied
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
11
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
--> tests/trybuild/no_handle_conversions_require_into_fail.rs:11:18
|
|
3
|
+
|
|
|
4
|
+
11 | Two --(B)--> One;
|
|
5
|
+
| ^^^ the trait `From<Two>` is not implemented for `One`
|
|
6
|
+
|
|
|
7
|
+
= note: required because of the requirements on the impl of `Into<One>` for `Two`
|
|
8
|
+
note: required by `TransitionResult::<Sm, Ds>::from`
|
|
9
|
+
--> $WORKSPACE/fsm/rustfsm_trait/src/lib.rs
|
|
10
|
+
|
|
|
11
|
+
| / pub fn from<CurrentState>(current_state: CurrentState) -> Self
|
|
12
|
+
| | where
|
|
13
|
+
| | CurrentState: Into<Ds>,
|
|
14
|
+
| |_______________________________^
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "rustfsm_trait"
|
|
3
3
|
version = "0.1.0"
|
|
4
4
|
authors = ["Spencer Judge <spencer@temporal.io>"]
|
|
5
|
-
edition = "
|
|
5
|
+
edition = "2021"
|
|
6
6
|
license-file = "LICENSE.txt"
|
|
7
7
|
description = "Trait sub-crate of the `rustfsm` crate"
|
|
8
8
|
|
|
@@ -11,4 +11,4 @@ description = "Trait sub-crate of the `rustfsm` crate"
|
|
|
11
11
|
[dependencies]
|
|
12
12
|
|
|
13
13
|
[package.metadata.workspaces]
|
|
14
|
-
independent = true
|
|
14
|
+
independent = true
|
|
@@ -13,6 +13,7 @@ message ActivityResult {
|
|
|
13
13
|
Success completed = 1;
|
|
14
14
|
Failure failed = 2;
|
|
15
15
|
Cancellation cancelled = 3;
|
|
16
|
+
WillCompleteAsync will_complete_async = 4;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -34,4 +35,12 @@ message Failure {
|
|
|
34
35
|
*/
|
|
35
36
|
message Cancellation {
|
|
36
37
|
temporal.api.failure.v1.Failure failure = 1;
|
|
37
|
-
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Used in ActivityResult to notify Core that this Activity will complete asynchronously.
|
|
42
|
+
* Core will forget about this Activity and free up resources used to track this Activity.
|
|
43
|
+
*/
|
|
44
|
+
message WillCompleteAsync {
|
|
45
|
+
}
|
|
46
|
+
|
|
@@ -59,9 +59,8 @@ message WFActivationJob {
|
|
|
59
59
|
/// after performing the activation.
|
|
60
60
|
///
|
|
61
61
|
/// If other job variant are present in the list, this variant will be the last job in the
|
|
62
|
-
/// job list. The
|
|
63
|
-
|
|
64
|
-
bool remove_from_cache = 50;
|
|
62
|
+
/// job list. The string value is a reason for eviction.
|
|
63
|
+
RemoveFromCache remove_from_cache = 50;
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
|
|
@@ -187,3 +186,7 @@ message ResolveRequestCancelExternalWorkflow {
|
|
|
187
186
|
/// type / info.
|
|
188
187
|
temporal.api.failure.v1.Failure failure = 2;
|
|
189
188
|
}
|
|
189
|
+
|
|
190
|
+
message RemoveFromCache {
|
|
191
|
+
string reason = 1;
|
|
192
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "temporal-sdk-core-protos"
|
|
3
3
|
version = "0.1.0"
|
|
4
|
-
edition = "
|
|
4
|
+
edition = "2021"
|
|
5
5
|
authors = ["Spencer Judge <spencer@temporal.io>"]
|
|
6
6
|
license-file = "LICENSE.txt"
|
|
7
7
|
description = "Protobuf definitions for Temporal SDKs Core/Lang interface"
|
|
@@ -12,9 +12,9 @@ categories = ["development-tools"]
|
|
|
12
12
|
|
|
13
13
|
[dependencies]
|
|
14
14
|
derive_more = "0.99"
|
|
15
|
-
prost = "0.
|
|
16
|
-
prost-types = "0.
|
|
17
|
-
tonic = "0.
|
|
15
|
+
prost = "0.9"
|
|
16
|
+
prost-types = "0.9"
|
|
17
|
+
tonic = "0.6"
|
|
18
18
|
|
|
19
19
|
[build-dependencies]
|
|
20
20
|
tonic-build = "0.5"
|