@temporalio/core-bridge 0.15.0 → 0.17.0
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 +13 -12
- package/index.d.ts +14 -0
- package/index.node +0 -0
- package/package.json +7 -5
- package/releases/aarch64-apple-darwin/index.node +0 -0
- package/releases/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 +70 -33
- package/sdk-core/Cargo.toml +1 -0
- package/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +1 -1
- package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +8 -9
- package/sdk-core/fsm/rustfsm_trait/Cargo.toml +1 -1
- package/sdk-core/fsm/rustfsm_trait/src/lib.rs +1 -1
- package/sdk-core/sdk-core-protos/src/lib.rs +36 -48
- 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/mod.rs +3 -3
- package/sdk-core/src/core_tests/retry.rs +14 -8
- package/sdk-core/src/core_tests/workflow_tasks.rs +244 -2
- package/sdk-core/src/errors.rs +11 -9
- package/sdk-core/src/lib.rs +12 -2
- 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 +19 -20
- package/sdk-core/src/pollers/gateway.rs +15 -7
- package/sdk-core/src/pollers/poll_buffer.rs +6 -5
- package/sdk-core/src/pollers/retry.rs +7 -5
- 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 +16 -22
- 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 +16 -93
- package/sdk-core/src/test_help/history_builder.rs +61 -2
- package/sdk-core/src/test_help/history_info.rs +21 -2
- package/sdk-core/src/test_help/mod.rs +24 -33
- package/sdk-core/src/worker/activities/activity_heartbeat_manager.rs +246 -138
- package/sdk-core/src/worker/activities.rs +46 -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 +46 -28
- 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 +1 -1
- package/sdk-core/src/workflow/workflow_tasks/cache_manager.rs +13 -17
- package/sdk-core/src/workflow/workflow_tasks/concurrency_manager.rs +4 -8
- package/sdk-core/src/workflow/workflow_tasks/mod.rs +14 -19
- package/sdk-core/test_utils/src/lib.rs +2 -2
- package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +61 -1
- package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +2 -2
- package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +2 -2
- package/src/conversions.rs +17 -0
- package/releases/x86_64-pc-windows-gnu/index.node +0 -0
package/Cargo.lock
CHANGED
|
@@ -39,9 +39,9 @@ checksum = "ee10e43ae4a853c0a3591d4e2ada1719e553be18199d9da9d4a83f5927c2f5c7"
|
|
|
39
39
|
|
|
40
40
|
[[package]]
|
|
41
41
|
name = "arc-swap"
|
|
42
|
-
version = "1.
|
|
42
|
+
version = "1.5.0"
|
|
43
43
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
44
|
-
checksum = "
|
|
44
|
+
checksum = "c5d78ce20460b82d3fa150275ed9d55e21064fc7951177baacf86a145c4a4b1f"
|
|
45
45
|
|
|
46
46
|
[[package]]
|
|
47
47
|
name = "async-stream"
|
|
@@ -124,9 +124,9 @@ checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba"
|
|
|
124
124
|
|
|
125
125
|
[[package]]
|
|
126
126
|
name = "cc"
|
|
127
|
-
version = "1.0.
|
|
127
|
+
version = "1.0.72"
|
|
128
128
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
129
|
-
checksum = "
|
|
129
|
+
checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"
|
|
130
130
|
|
|
131
131
|
[[package]]
|
|
132
132
|
name = "cfg-if"
|
|
@@ -563,9 +563,9 @@ checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440"
|
|
|
563
563
|
|
|
564
564
|
[[package]]
|
|
565
565
|
name = "hyper"
|
|
566
|
-
version = "0.14.
|
|
566
|
+
version = "0.14.15"
|
|
567
567
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
568
|
-
checksum = "
|
|
568
|
+
checksum = "436ec0091e4f20e655156a30a0df3770fe2900aa301e548e08446ec794b6953c"
|
|
569
569
|
dependencies = [
|
|
570
570
|
"bytes",
|
|
571
571
|
"futures-channel",
|
|
@@ -1418,9 +1418,9 @@ checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
|
|
|
1418
1418
|
|
|
1419
1419
|
[[package]]
|
|
1420
1420
|
name = "serde_json"
|
|
1421
|
-
version = "1.0.
|
|
1421
|
+
version = "1.0.70"
|
|
1422
1422
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1423
|
-
checksum = "
|
|
1423
|
+
checksum = "e277c495ac6cd1a01a58d0a0c574568b4d1ddf14f59965c6a58b8d96400b54f3"
|
|
1424
1424
|
dependencies = [
|
|
1425
1425
|
"itoa",
|
|
1426
1426
|
"ryu",
|
|
@@ -1550,6 +1550,7 @@ dependencies = [
|
|
|
1550
1550
|
"thiserror",
|
|
1551
1551
|
"tokio",
|
|
1552
1552
|
"tokio-stream",
|
|
1553
|
+
"tokio-util",
|
|
1553
1554
|
"tonic 0.6.1",
|
|
1554
1555
|
"tonic-build 0.6.0",
|
|
1555
1556
|
"tower",
|
|
@@ -1634,9 +1635,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
|
|
1634
1635
|
|
|
1635
1636
|
[[package]]
|
|
1636
1637
|
name = "tokio"
|
|
1637
|
-
version = "1.
|
|
1638
|
+
version = "1.14.0"
|
|
1638
1639
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1639
|
-
checksum = "
|
|
1640
|
+
checksum = "70e992e41e0d2fb9f755b37446f20900f64446ef54874f40a60c78f021ac6144"
|
|
1640
1641
|
dependencies = [
|
|
1641
1642
|
"autocfg",
|
|
1642
1643
|
"bytes",
|
|
@@ -1664,9 +1665,9 @@ dependencies = [
|
|
|
1664
1665
|
|
|
1665
1666
|
[[package]]
|
|
1666
1667
|
name = "tokio-macros"
|
|
1667
|
-
version = "1.
|
|
1668
|
+
version = "1.6.0"
|
|
1668
1669
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1669
|
-
checksum = "
|
|
1670
|
+
checksum = "c9efc1aba077437943f7515666aa2b882dfabfbfdf89c819ea75a8d6e9eaba5e"
|
|
1670
1671
|
dependencies = [
|
|
1671
1672
|
"proc-macro2",
|
|
1672
1673
|
"quote",
|
package/index.d.ts
CHANGED
|
@@ -125,6 +125,20 @@ export interface WorkerOptions {
|
|
|
125
125
|
* Maximum number of Workflow instances to cache before automatic eviction
|
|
126
126
|
*/
|
|
127
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;
|
|
128
142
|
}
|
|
129
143
|
|
|
130
144
|
/** Log level - must match rust log level names */
|
package/index.node
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/core-bridge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
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
|
},
|
|
@@ -19,8 +19,10 @@
|
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@opentelemetry/api": "^1.0.3",
|
|
22
|
-
"@temporalio/common": "^0.
|
|
23
|
-
"
|
|
22
|
+
"@temporalio/common": "^0.17.0",
|
|
23
|
+
"arg": "^5.0.1",
|
|
24
|
+
"cargo-cp-artifact": "^0.1.4",
|
|
25
|
+
"which": "^2.0.2"
|
|
24
26
|
},
|
|
25
27
|
"bugs": {
|
|
26
28
|
"url": "https://github.com/temporalio/sdk-typescript/issues"
|
|
@@ -38,5 +40,5 @@
|
|
|
38
40
|
"publishConfig": {
|
|
39
41
|
"access": "public"
|
|
40
42
|
},
|
|
41
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "7706410cb67a1c92b9ae9eea1cac48e0dad4a8d1"
|
|
42
44
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/scripts/build.js
CHANGED
|
@@ -1,33 +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
|
|
|
11
|
+
// List of tested compile targets
|
|
8
12
|
const targets = [
|
|
9
13
|
'x86_64-apple-darwin',
|
|
10
14
|
'aarch64-apple-darwin',
|
|
11
15
|
'x86_64-unknown-linux-gnu',
|
|
12
16
|
'aarch64-unknown-linux-gnu',
|
|
17
|
+
// TODO: this is not supported on macos
|
|
18
|
+
'x86_64-pc-windows-msvc',
|
|
13
19
|
'x86_64-pc-windows-gnu',
|
|
14
20
|
];
|
|
15
21
|
|
|
16
|
-
const requestedTargets =
|
|
17
|
-
process.env.TEMPORAL_WORKER_BUILD_TARGETS === 'all'
|
|
18
|
-
? targets
|
|
19
|
-
: process.env.TEMPORAL_WORKER_BUILD_TARGETS
|
|
20
|
-
? process.env.TEMPORAL_WORKER_BUILD_TARGETS.split(':')
|
|
21
|
-
: [];
|
|
22
|
-
|
|
23
|
-
// Only applicable if TEMPORAL_WORKER_BUILD_TARGETS is not specified
|
|
24
|
-
const forceBuild = new Set(['y', 't', '1', 'yes', 'true']).has(
|
|
25
|
-
(process.env.TEMPORAL_WORKER_FORCE_BUILD || '').toLowerCase()
|
|
26
|
-
);
|
|
27
|
-
|
|
28
22
|
const archAlias = { x64: 'x86_64', arm64: 'aarch64' };
|
|
29
23
|
const platformMapping = { darwin: 'apple-darwin', linux: 'unknown-linux-gnu', win32: 'pc-windows-gnu' };
|
|
30
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
|
+
|
|
31
69
|
function compile(target) {
|
|
32
70
|
console.log('Compiling bridge', { target });
|
|
33
71
|
|
|
@@ -39,26 +77,25 @@ function compile(target) {
|
|
|
39
77
|
throw err;
|
|
40
78
|
}
|
|
41
79
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
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
|
+
});
|
|
62
99
|
if (status !== 0) {
|
|
63
100
|
throw new Error(`Failed to build${target ? ' for ' + target : ''}`);
|
|
64
101
|
}
|
|
@@ -110,7 +147,7 @@ if (requestedTargets.length > 0) {
|
|
|
110
147
|
}
|
|
111
148
|
}
|
|
112
149
|
} else {
|
|
113
|
-
console.log('
|
|
150
|
+
console.log('Forced the build via --force');
|
|
114
151
|
compile();
|
|
115
152
|
}
|
|
116
153
|
}
|
package/sdk-core/Cargo.toml
CHANGED
|
@@ -43,6 +43,7 @@ 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
48
|
tonic = { version = "0.6", features = ["tls", "tls-roots"] }
|
|
48
49
|
tower = "0.4"
|
|
@@ -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
|
}
|
|
@@ -38,7 +38,7 @@ pub mod coresdk {
|
|
|
38
38
|
activity_id: String,
|
|
39
39
|
reason: ActivityCancelReason,
|
|
40
40
|
) -> Self {
|
|
41
|
-
|
|
41
|
+
Self {
|
|
42
42
|
task_token,
|
|
43
43
|
activity_id,
|
|
44
44
|
variant: Some(activity_task::Variant::Cancel(Cancel {
|
|
@@ -75,7 +75,7 @@ pub mod coresdk {
|
|
|
75
75
|
})),
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
pub fn will_complete_async() -> Self {
|
|
78
|
+
pub const fn will_complete_async() -> Self {
|
|
79
79
|
Self {
|
|
80
80
|
status: Some(activity_result::Status::WillCompleteAsync(
|
|
81
81
|
WillCompleteAsync {},
|
|
@@ -195,7 +195,7 @@ pub mod coresdk {
|
|
|
195
195
|
"jobs: {})",
|
|
196
196
|
self.jobs
|
|
197
197
|
.iter()
|
|
198
|
-
.map(
|
|
198
|
+
.map(ToString::to_string)
|
|
199
199
|
.collect::<Vec<_>>()
|
|
200
200
|
.as_slice()
|
|
201
201
|
.join(", ")
|
|
@@ -264,18 +264,18 @@ pub mod coresdk {
|
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
pub mod workflow_completion {
|
|
267
|
-
use crate::coresdk::workflow_completion::wf_activation_completion::Status;
|
|
268
267
|
tonic::include_proto!("coresdk.workflow_completion");
|
|
269
268
|
|
|
270
269
|
impl wf_activation_completion::Status {
|
|
271
|
-
pub fn is_success(&self) -> bool {
|
|
270
|
+
pub const fn is_success(&self) -> bool {
|
|
272
271
|
match &self {
|
|
273
|
-
|
|
274
|
-
|
|
272
|
+
Self::Successful(_) => true,
|
|
273
|
+
Self::Failed(_) => false,
|
|
275
274
|
}
|
|
276
275
|
}
|
|
277
276
|
}
|
|
278
277
|
}
|
|
278
|
+
|
|
279
279
|
pub mod child_workflow {
|
|
280
280
|
tonic::include_proto!("coresdk.child_workflow");
|
|
281
281
|
}
|
|
@@ -370,7 +370,7 @@ pub mod coresdk {
|
|
|
370
370
|
|
|
371
371
|
impl From<wf_activation_job::Variant> for WfActivationJob {
|
|
372
372
|
fn from(a: wf_activation_job::Variant) -> Self {
|
|
373
|
-
|
|
373
|
+
Self { variant: Some(a) }
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
|
|
@@ -382,7 +382,7 @@ pub mod coresdk {
|
|
|
382
382
|
|
|
383
383
|
impl From<workflow_command::Variant> for WorkflowCommand {
|
|
384
384
|
fn from(v: workflow_command::Variant) -> Self {
|
|
385
|
-
|
|
385
|
+
Self { variant: Some(v) }
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
|
|
@@ -591,7 +591,7 @@ pub mod coresdk {
|
|
|
591
591
|
}
|
|
592
592
|
|
|
593
593
|
impl ActivityResult {
|
|
594
|
-
pub fn ok(result: Payload) -> Self {
|
|
594
|
+
pub const fn ok(result: Payload) -> Self {
|
|
595
595
|
Self {
|
|
596
596
|
status: Some(activity_result::activity_result::Status::Completed(
|
|
597
597
|
activity_result::Success {
|
|
@@ -615,24 +615,18 @@ pub mod coresdk {
|
|
|
615
615
|
.workflow_execution
|
|
616
616
|
.map(|we| (we.workflow_id, we.run_id))
|
|
617
617
|
.unwrap_or_default();
|
|
618
|
-
|
|
618
|
+
Self {
|
|
619
619
|
task_token: r.task_token,
|
|
620
620
|
activity_id: r.activity_id,
|
|
621
621
|
variant: Some(activity_task::activity_task::Variant::Start(
|
|
622
622
|
activity_task::Start {
|
|
623
623
|
workflow_namespace: r.workflow_namespace,
|
|
624
|
-
workflow_type: r
|
|
625
|
-
.workflow_type
|
|
626
|
-
.map(|wt| wt.name)
|
|
627
|
-
.unwrap_or_else(|| "".to_string()),
|
|
624
|
+
workflow_type: r.workflow_type.map_or_else(|| "".to_string(), |wt| wt.name),
|
|
628
625
|
workflow_execution: Some(common::WorkflowExecution {
|
|
629
626
|
workflow_id,
|
|
630
627
|
run_id,
|
|
631
628
|
}),
|
|
632
|
-
activity_type: r
|
|
633
|
-
.activity_type
|
|
634
|
-
.map(|at| at.name)
|
|
635
|
-
.unwrap_or_else(|| "".to_string()),
|
|
629
|
+
activity_type: r.activity_type.map_or_else(|| "".to_string(), |at| at.name),
|
|
636
630
|
header_fields: r.header.map(Into::into).unwrap_or_default(),
|
|
637
631
|
input: Vec::from_payloads(r.input),
|
|
638
632
|
heartbeat_details: Vec::from_payloads(r.heartbeat_details),
|
|
@@ -664,7 +658,7 @@ pub mod coresdk {
|
|
|
664
658
|
|
|
665
659
|
impl From<common::WorkflowExecution> for WorkflowExecution {
|
|
666
660
|
fn from(exc: common::WorkflowExecution) -> Self {
|
|
667
|
-
|
|
661
|
+
Self {
|
|
668
662
|
workflow_id: exc.workflow_id,
|
|
669
663
|
run_id: exc.run_id,
|
|
670
664
|
}
|
|
@@ -767,7 +761,7 @@ pub mod coresdk {
|
|
|
767
761
|
T: AsRef<[u8]>,
|
|
768
762
|
{
|
|
769
763
|
fn from(v: T) -> Self {
|
|
770
|
-
|
|
764
|
+
Self {
|
|
771
765
|
payloads: vec![v.into()],
|
|
772
766
|
}
|
|
773
767
|
}
|
|
@@ -786,10 +780,10 @@ pub mod coresdk {
|
|
|
786
780
|
match v.payloads.pop() {
|
|
787
781
|
None => Err(PayloadsToPayloadError::NoPayload),
|
|
788
782
|
Some(p) => {
|
|
789
|
-
if
|
|
790
|
-
Err(PayloadsToPayloadError::MoreThanOnePayload)
|
|
791
|
-
} else {
|
|
783
|
+
if v.payloads.is_empty() {
|
|
792
784
|
Ok(p.into())
|
|
785
|
+
} else {
|
|
786
|
+
Err(PayloadsToPayloadError::MoreThanOnePayload)
|
|
793
787
|
}
|
|
794
788
|
}
|
|
795
789
|
}
|
|
@@ -1091,26 +1085,22 @@ pub mod temporal {
|
|
|
1091
1085
|
impl HistoryEvent {
|
|
1092
1086
|
/// Returns true if this is an event created to mirror a command
|
|
1093
1087
|
pub fn is_command_event(&self) -> bool {
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
}
|
|
1111
|
-
} else {
|
|
1112
|
-
false
|
|
1113
|
-
}
|
|
1088
|
+
EventType::from_i32(self.event_type).map_or(false, |et| match et {
|
|
1089
|
+
EventType::ActivityTaskScheduled
|
|
1090
|
+
| EventType::ActivityTaskCancelRequested
|
|
1091
|
+
| EventType::MarkerRecorded
|
|
1092
|
+
| EventType::RequestCancelExternalWorkflowExecutionInitiated
|
|
1093
|
+
| EventType::SignalExternalWorkflowExecutionInitiated
|
|
1094
|
+
| EventType::StartChildWorkflowExecutionInitiated
|
|
1095
|
+
| EventType::TimerCanceled
|
|
1096
|
+
| EventType::TimerStarted
|
|
1097
|
+
| EventType::UpsertWorkflowSearchAttributes
|
|
1098
|
+
| EventType::WorkflowExecutionCanceled
|
|
1099
|
+
| EventType::WorkflowExecutionCompleted
|
|
1100
|
+
| EventType::WorkflowExecutionContinuedAsNew
|
|
1101
|
+
| EventType::WorkflowExecutionFailed => true,
|
|
1102
|
+
_ => false,
|
|
1103
|
+
})
|
|
1114
1104
|
}
|
|
1115
1105
|
|
|
1116
1106
|
/// Returns the command's initiating event id, if present. This is the id of the
|
|
@@ -1262,16 +1252,14 @@ pub mod temporal {
|
|
|
1262
1252
|
let last_event = self
|
|
1263
1253
|
.history
|
|
1264
1254
|
.as_ref()
|
|
1265
|
-
.
|
|
1266
|
-
.flatten()
|
|
1255
|
+
.and_then(|h| h.events.last().map(|he| he.event_id))
|
|
1267
1256
|
.unwrap_or(0);
|
|
1268
1257
|
write!(
|
|
1269
1258
|
f,
|
|
1270
1259
|
"PollWFTQResp(run_id: {}, attempt: {}, last_event: {})",
|
|
1271
1260
|
self.workflow_execution
|
|
1272
1261
|
.as_ref()
|
|
1273
|
-
.
|
|
1274
|
-
.unwrap_or(""),
|
|
1262
|
+
.map_or("", |we| we.run_id.as_str()),
|
|
1275
1263
|
self.attempt,
|
|
1276
1264
|
last_event
|
|
1277
1265
|
)
|
|
@@ -76,7 +76,7 @@ async fn max_activities_respected() {
|
|
|
76
76
|
core.register_worker(
|
|
77
77
|
WorkerConfigBuilder::default()
|
|
78
78
|
.task_queue(TEST_Q)
|
|
79
|
-
.max_outstanding_activities(
|
|
79
|
+
.max_outstanding_activities(2_usize)
|
|
80
80
|
.build()
|
|
81
81
|
.unwrap(),
|
|
82
82
|
)
|
|
@@ -163,7 +163,7 @@ async fn heartbeats_report_cancels_only_once() {
|
|
|
163
163
|
core.record_activity_heartbeat(ActivityHeartbeat {
|
|
164
164
|
task_token: act.task_token.clone(),
|
|
165
165
|
task_queue: TEST_Q.to_string(),
|
|
166
|
-
details: vec![vec![
|
|
166
|
+
details: vec![vec![1_u8, 2, 3].into()],
|
|
167
167
|
});
|
|
168
168
|
// We have to wait a beat for the heartbeat to be processed
|
|
169
169
|
sleep(Duration::from_millis(10)).await;
|
|
@@ -183,7 +183,7 @@ async fn heartbeats_report_cancels_only_once() {
|
|
|
183
183
|
core.record_activity_heartbeat(ActivityHeartbeat {
|
|
184
184
|
task_token: act.task_token,
|
|
185
185
|
task_queue: TEST_Q.to_string(),
|
|
186
|
-
details: vec![vec![
|
|
186
|
+
details: vec![vec![1_u8, 2, 3].into()],
|
|
187
187
|
});
|
|
188
188
|
sleep(Duration::from_millis(10)).await;
|
|
189
189
|
// Since cancels always come before new tasks, if we get a new non-cancel task, we did not
|
|
@@ -251,7 +251,7 @@ async fn activity_cancel_interrupts_poll() {
|
|
|
251
251
|
core.record_activity_heartbeat(ActivityHeartbeat {
|
|
252
252
|
task_token: act.task_token,
|
|
253
253
|
task_queue: TEST_Q.to_string(),
|
|
254
|
-
details: vec![vec![
|
|
254
|
+
details: vec![vec![1_u8, 2, 3].into()],
|
|
255
255
|
});
|
|
256
256
|
last_finisher.store(1, Ordering::SeqCst);
|
|
257
257
|
},
|
|
@@ -358,7 +358,7 @@ async fn many_concurrent_heartbeat_cancels() {
|
|
|
358
358
|
.task_queue(TEST_Q)
|
|
359
359
|
.max_outstanding_activities(CONCURRENCY_NUM)
|
|
360
360
|
// Only 1 poll at a time to avoid over-polling and running out of responses
|
|
361
|
-
.max_concurrent_at_polls(
|
|
361
|
+
.max_concurrent_at_polls(1_usize)
|
|
362
362
|
.build()
|
|
363
363
|
.unwrap(),
|
|
364
364
|
)
|