@temporalio/core-bridge 1.7.4 → 1.8.1

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.
Files changed (90) hide show
  1. package/Cargo.lock +245 -247
  2. package/Cargo.toml +1 -1
  3. package/lib/errors.d.ts +9 -0
  4. package/lib/errors.js +13 -0
  5. package/lib/errors.js.map +1 -1
  6. package/lib/index.d.ts +19 -3
  7. package/lib/index.js.map +1 -1
  8. package/package.json +3 -3
  9. package/releases/aarch64-apple-darwin/index.node +0 -0
  10. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  11. package/releases/x86_64-apple-darwin/index.node +0 -0
  12. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  13. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  14. package/sdk-core/.github/workflows/heavy.yml +1 -1
  15. package/sdk-core/.github/workflows/semgrep.yml +25 -0
  16. package/sdk-core/README.md +2 -0
  17. package/sdk-core/cargo-tokio-console.sh +5 -0
  18. package/sdk-core/client/src/lib.rs +6 -41
  19. package/sdk-core/client/src/raw.rs +9 -0
  20. package/sdk-core/client/src/retry.rs +0 -16
  21. package/sdk-core/core/Cargo.toml +9 -5
  22. package/sdk-core/core/src/abstractions.rs +7 -75
  23. package/sdk-core/core/src/core_tests/activity_tasks.rs +16 -8
  24. package/sdk-core/core/src/core_tests/local_activities.rs +97 -5
  25. package/sdk-core/core/src/core_tests/mod.rs +1 -1
  26. package/sdk-core/core/src/core_tests/workers.rs +16 -16
  27. package/sdk-core/core/src/core_tests/workflow_tasks.rs +247 -28
  28. package/sdk-core/core/src/lib.rs +2 -3
  29. package/sdk-core/core/src/pollers/mod.rs +30 -3
  30. package/sdk-core/core/src/pollers/poll_buffer.rs +166 -77
  31. package/sdk-core/core/src/protosext/mod.rs +4 -8
  32. package/sdk-core/core/src/replay/mod.rs +1 -1
  33. package/sdk-core/core/src/telemetry/metrics.rs +9 -0
  34. package/sdk-core/core/src/telemetry/mod.rs +3 -0
  35. package/sdk-core/core/src/test_help/mod.rs +9 -16
  36. package/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +6 -31
  37. package/sdk-core/core/src/worker/activities/local_activities.rs +214 -110
  38. package/sdk-core/core/src/worker/activities.rs +72 -47
  39. package/sdk-core/core/src/worker/client/mocks.rs +1 -1
  40. package/sdk-core/core/src/worker/client.rs +45 -32
  41. package/sdk-core/core/src/worker/mod.rs +170 -122
  42. package/sdk-core/core/src/worker/workflow/driven_workflow.rs +0 -4
  43. package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +9 -2
  44. package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +9 -2
  45. package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +6 -3
  46. package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +74 -22
  47. package/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +3 -2
  48. package/sdk-core/core/src/worker/workflow/managed_run.rs +16 -3
  49. package/sdk-core/core/src/worker/workflow/mod.rs +13 -22
  50. package/sdk-core/core/src/worker/workflow/run_cache.rs +5 -0
  51. package/sdk-core/core/src/worker/workflow/wft_extraction.rs +4 -7
  52. package/sdk-core/core/src/worker/workflow/wft_poller.rs +38 -8
  53. package/sdk-core/core/src/worker/workflow/workflow_stream.rs +1 -0
  54. package/sdk-core/core-api/src/worker.rs +43 -2
  55. package/sdk-core/protos/api_upstream/Makefile +1 -1
  56. package/sdk-core/protos/api_upstream/buf.yaml +1 -6
  57. package/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +12 -0
  58. package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +11 -0
  59. package/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +13 -2
  60. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +1 -0
  61. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +2 -0
  62. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +9 -0
  63. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +19 -0
  64. package/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +5 -0
  65. package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +36 -4
  66. package/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +24 -7
  67. package/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +4 -0
  68. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +76 -44
  69. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +23 -1
  70. package/sdk-core/protos/google/rpc/status.proto +52 -0
  71. package/sdk-core/protos/local/temporal/sdk/core/common/common.proto +16 -0
  72. package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +4 -0
  73. package/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +6 -0
  74. package/sdk-core/sdk/src/lib.rs +31 -10
  75. package/sdk-core/sdk/src/workflow_future.rs +7 -5
  76. package/sdk-core/sdk-core-protos/src/history_builder.rs +2 -0
  77. package/sdk-core/sdk-core-protos/src/history_info.rs +1 -0
  78. package/sdk-core/sdk-core-protos/src/lib.rs +82 -73
  79. package/sdk-core/test-utils/Cargo.toml +1 -1
  80. package/sdk-core/test-utils/src/lib.rs +50 -37
  81. package/sdk-core/tests/integ_tests/metrics_tests.rs +143 -10
  82. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +26 -15
  83. package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +1 -1
  84. package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +2 -2
  85. package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +5 -1
  86. package/sdk-core/tests/integ_tests/workflow_tests.rs +1 -0
  87. package/src/conversions.rs +9 -2
  88. package/src/runtime.rs +5 -7
  89. package/ts/errors.ts +15 -0
  90. package/ts/index.ts +22 -4
package/Cargo.toml CHANGED
@@ -26,6 +26,6 @@ prost = "0.11"
26
26
  prost-types = "0.11"
27
27
  tokio = "1.13"
28
28
  once_cell = "1.7.2"
29
- temporal-sdk-core = { version = "*", path = "./sdk-core/core" }
29
+ temporal-sdk-core = { version = "*", path = "./sdk-core/core", features = ["ephemeral-server"] }
30
30
  temporal-client = { version = "*", path = "./sdk-core/client" }
31
31
  tokio-stream = "0.1"
package/lib/errors.d.ts CHANGED
@@ -1,9 +1,18 @@
1
1
  import { IllegalStateError } from '@temporalio/common';
2
+ declare const isShutdownError: unique symbol;
2
3
  /**
3
4
  * The worker has been shut down
4
5
  */
5
6
  export declare class ShutdownError extends Error {
6
7
  readonly name = "ShutdownError";
8
+ /**
9
+ * Marker to determine whether an error is an instance of TerminatedFailure.
10
+ */
11
+ protected readonly [isShutdownError] = true;
12
+ /**
13
+ * Instanceof check that works when multiple versions of @temporalio/core-bridge are installed.
14
+ */
15
+ static is(error: unknown): error is ShutdownError;
7
16
  }
8
17
  /**
9
18
  * Thrown after shutdown was requested as a response to a poll function, JS should stop polling
package/lib/errors.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.convertFromNamedError = exports.IllegalStateError = exports.UnexpectedError = exports.TransportError = exports.ShutdownError = void 0;
4
5
  const common_1 = require("@temporalio/common");
5
6
  Object.defineProperty(exports, "IllegalStateError", { enumerable: true, get: function () { return common_1.IllegalStateError; } });
7
+ const isShutdownError = Symbol.for('__temporal_isShutdownError');
6
8
  /**
7
9
  * The worker has been shut down
8
10
  */
@@ -10,9 +12,20 @@ class ShutdownError extends Error {
10
12
  constructor() {
11
13
  super(...arguments);
12
14
  this.name = 'ShutdownError';
15
+ /**
16
+ * Marker to determine whether an error is an instance of TerminatedFailure.
17
+ */
18
+ this[_a] = true;
19
+ }
20
+ /**
21
+ * Instanceof check that works when multiple versions of @temporalio/core-bridge are installed.
22
+ */
23
+ static is(error) {
24
+ return error instanceof ShutdownError || error?.[isShutdownError] === true;
13
25
  }
14
26
  }
15
27
  exports.ShutdownError = ShutdownError;
28
+ _a = isShutdownError;
16
29
  /**
17
30
  * Thrown after shutdown was requested as a response to a poll function, JS should stop polling
18
31
  * once this error is encountered
package/lib/errors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":";;;AAAA,+CAAuD;AAuB9C,kGAvBA,0BAAiB,OAuBA;AArB1B;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IAAxC;;QACkB,SAAI,GAAG,eAAe,CAAC;IACzC,CAAC;CAAA;AAFD,sCAEC;AAED;;;GAGG;AACH,MAAa,cAAe,SAAQ,KAAK;IAAzC;;QACkB,SAAI,GAAG,gBAAgB,CAAC;IAC1C,CAAC;CAAA;AAFD,wCAEC;AAED;;GAEG;AACH,MAAa,eAAgB,SAAQ,KAAK;IAA1C;;QACkB,SAAI,GAAG,iBAAiB,CAAC;IAC3C,CAAC;CAAA;AAFD,0CAEC;AAGD,SAAgB,qBAAqB,CAAC,CAAU,EAAE,cAAuB;IACvE,wEAAwE;IACxE,wEAAwE;IACxE,6DAA6D;IAC7D,IAAI,CAAC,YAAY,KAAK,IAAI,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE;QACnE,IAAI,MAAa,CAAC;QAClB,QAAQ,CAAC,CAAC,IAAI,EAAE;YACd,KAAK,gBAAgB;gBACnB,MAAM,GAAG,IAAI,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBACvC,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;gBACpD,OAAO,MAAM,CAAC;YAEhB,KAAK,mBAAmB;gBACtB,MAAM,GAAG,IAAI,0BAAiB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBA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D,OAAO,MAAM,CAAC;SACjB;KACF;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AA7BD,sDA6BC"}
package/lib/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { SpanContext } from '@opentelemetry/api';
2
+ import { LogLevel, Duration } from '@temporalio/common';
2
3
  import type { TLSConfig } from '@temporalio/common/lib/internal-non-workflow';
3
4
  export { TLSConfig };
5
+ /** @deprecated Import from @temporalio/common instead */
6
+ export { LogLevel };
4
7
  type Shadow<Base, New> = Base extends object ? New extends object ? {
5
8
  [K in keyof Base | keyof New]: K extends keyof Base ? K extends keyof New ? Shadow<Base[K], New[K]> : Base[K] : K extends keyof New ? New[K] : never;
6
9
  } : New : New;
@@ -96,7 +99,7 @@ export interface OtelCollectorExporter {
96
99
  * @format number of milliseconds or {@link https://www.npmjs.com/package/ms | ms-formatted string}
97
100
  * @defaults 1 second
98
101
  */
99
- metricsExportInterval?: string | number;
102
+ metricsExportInterval?: Duration;
100
103
  };
101
104
  }
102
105
  /** @experimental */
@@ -241,6 +244,13 @@ export interface WorkerOptions {
241
244
  * A string that should be unique to the exact worker code/binary being executed
242
245
  */
243
246
  buildId: string;
247
+ /**
248
+ * If set true, this worker opts into the worker versioning feature. This ensures it only receives
249
+ * workflow tasks for workflows which it claims to be compatible with.
250
+ *
251
+ * For more information, see https://docs.temporal.io/workers#worker-versioning
252
+ */
253
+ useVersioning: boolean;
244
254
  /**
245
255
  * The task queue the worker will pull from
246
256
  */
@@ -248,6 +258,14 @@ export interface WorkerOptions {
248
258
  maxConcurrentActivityTaskExecutions: number;
249
259
  maxConcurrentWorkflowTaskExecutions: number;
250
260
  maxConcurrentLocalActivityExecutions: number;
261
+ /**
262
+ * Maximum number of Workflow tasks to poll concurrently.
263
+ */
264
+ maxConcurrentWorkflowTaskPolls: number;
265
+ /**
266
+ * Maximum number of Activity tasks to poll concurrently.
267
+ */
268
+ maxConcurrentActivityTaskPolls: number;
251
269
  /**
252
270
  * If set to `false` this worker will only handle workflow tasks and local activities, it will not
253
271
  * poll for activity tasks.
@@ -289,8 +307,6 @@ export interface WorkerOptions {
289
307
  */
290
308
  maxActivitiesPerSecond?: number;
291
309
  }
292
- /** Log level - must match rust log level names */
293
- export type LogLevel = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
294
310
  export interface LogEntry {
295
311
  /** Log message */
296
312
  message: string;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;AAmgBA,mCAA0E;AAAjE,uGAAA,aAAa,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,yGAAA,eAAe,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;AAqhBA,mCAA0E;AAAjE,uGAAA,aAAa,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,yGAAA,eAAe,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temporalio/core-bridge",
3
- "version": "1.7.4",
3
+ "version": "1.8.1",
4
4
  "description": "Temporal.io SDK Core<>Node bridge",
5
5
  "main": "index.js",
6
6
  "types": "lib/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
25
  "@opentelemetry/api": "^1.4.1",
26
- "@temporalio/common": "1.7.4",
26
+ "@temporalio/common": "1.8.1",
27
27
  "arg": "^5.0.2",
28
28
  "cargo-cp-artifact": "^0.1.6",
29
29
  "which": "^2.0.2"
@@ -53,5 +53,5 @@
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
- "gitHead": "fb4088a8174b60b7a3fc7763ed39dbfc514a3e56"
56
+ "gitHead": "97808111bbec478260e915726bb9730a489f8fa4"
57
57
  }
@@ -26,4 +26,4 @@ jobs:
26
26
  - uses: actions-rs/cargo@v1
27
27
  with:
28
28
  command: integ-test
29
- args: -c "--release" -c "--all-features" -t heavy_tests -- --test-threads 1
29
+ args: -c "--release" -c "--features=save_wf_inputs" -t heavy_tests -- --test-threads 1
@@ -0,0 +1,25 @@
1
+ name: Semgrep
2
+ on:
3
+ workflow_dispatch: {}
4
+ pull_request: {}
5
+ push:
6
+ branches:
7
+ - main
8
+ - master
9
+ paths:
10
+ - .github/workflows/semgrep.yml
11
+ schedule:
12
+ # random HH:MM to avoid a load spike on GitHub Actions at 00:00
13
+ - cron: '15 21 * * *'
14
+ jobs:
15
+ semgrep:
16
+ name: semgrep/ci
17
+ runs-on: ubuntu-20.04
18
+ env:
19
+ SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
20
+ container:
21
+ image: returntocorp/semgrep
22
+ if: (github.actor != 'dependabot[bot]')
23
+ steps:
24
+ - uses: actions/checkout@v3
25
+ - run: semgrep ci
@@ -42,6 +42,8 @@ You can buld and test the project using cargo:
42
42
  Run integ tests with `cargo integ-test`. You will need to already be running the server:
43
43
  `docker-compose -f .buildkite/docker/docker-compose.yaml up`
44
44
 
45
+ Run load tests with `cargo test --features=save_wf_inputs --test heavy_tests`.
46
+
45
47
  ## Formatting
46
48
  To format all code run:
47
49
  `cargo fmt --all`
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ export RUSTFLAGS="--cfg tokio_unstable"
4
+
5
+ cargo "$1" --features "tokio-console" "${@:2}"
@@ -49,7 +49,7 @@ use temporal_sdk_core_protos::{
49
49
  grpc::health::v1::health_client::HealthClient,
50
50
  temporal::api::{
51
51
  common::v1::{Header, Payload, Payloads, WorkflowExecution, WorkflowType},
52
- enums::v1::{TaskQueueKind, WorkflowIdReusePolicy, WorkflowTaskFailedCause},
52
+ enums::v1::{TaskQueueKind, WorkflowIdReusePolicy},
53
53
  failure::v1::Failure,
54
54
  operatorservice::v1::operator_service_client::OperatorServiceClient,
55
55
  query::v1::WorkflowQuery,
@@ -525,8 +525,6 @@ pub struct Client {
525
525
  inner: ConfiguredClient<TemporalServiceClientWithMetrics>,
526
526
  /// The namespace this client interacts with
527
527
  namespace: String,
528
- /// If set, attach as the worker build id to relevant calls
529
- bound_worker_build_id: Option<String>,
530
528
  }
531
529
 
532
530
  impl Client {
@@ -538,7 +536,6 @@ impl Client {
538
536
  Client {
539
537
  inner: client,
540
538
  namespace,
541
- bound_worker_build_id: None,
542
539
  }
543
540
  }
544
541
 
@@ -572,12 +569,6 @@ impl Client {
572
569
  Arc::make_mut(&mut self.inner.options)
573
570
  }
574
571
 
575
- /// Set a worker build id to be attached to relevant requests. Unlikely to be useful outside
576
- /// of core.
577
- pub fn set_worker_build_id(&mut self, id: String) {
578
- self.bound_worker_build_id = Some(id)
579
- }
580
-
581
572
  /// Returns a reference to the underlying client
582
573
  pub fn inner(&self) -> &ConfiguredClient<TemporalServiceClientWithMetrics> {
583
574
  &self.inner
@@ -800,15 +791,6 @@ pub trait WorkflowClientTrait {
800
791
  failure: Option<Failure>,
801
792
  ) -> Result<RespondActivityTaskFailedResponse>;
802
793
 
803
- /// Fail task by sending the failure to the server. `task_token` is the task token that would've
804
- /// been received from polling for a workflow activation.
805
- async fn fail_workflow_task(
806
- &self,
807
- task_token: TaskToken,
808
- cause: WorkflowTaskFailedCause,
809
- failure: Option<Failure>,
810
- ) -> Result<RespondWorkflowTaskFailedResponse>;
811
-
812
794
  /// Send a signal to a certain workflow instance
813
795
  async fn signal_workflow_execution(
814
796
  &self,
@@ -976,6 +958,7 @@ impl WorkflowClientTrait for Client {
976
958
  task_queue: Some(TaskQueue {
977
959
  name: task_queue,
978
960
  kind: TaskQueueKind::Unspecified as i32,
961
+ normal_name: "".to_string(),
979
962
  }),
980
963
  request_id: request_id.unwrap_or_else(|| Uuid::new_v4().to_string()),
981
964
  workflow_id_reuse_policy: options.id_reuse_policy as i32,
@@ -1023,6 +1006,7 @@ impl WorkflowClientTrait for Client {
1023
1006
  result,
1024
1007
  identity: self.inner.options.identity.clone(),
1025
1008
  namespace: self.namespace.clone(),
1009
+ worker_version: None,
1026
1010
  })
1027
1011
  .await?
1028
1012
  .into_inner())
@@ -1057,6 +1041,7 @@ impl WorkflowClientTrait for Client {
1057
1041
  details,
1058
1042
  identity: self.inner.options.identity.clone(),
1059
1043
  namespace: self.namespace.clone(),
1044
+ worker_version: None,
1060
1045
  })
1061
1046
  .await?
1062
1047
  .into_inner())
@@ -1076,33 +1061,12 @@ impl WorkflowClientTrait for Client {
1076
1061
  namespace: self.namespace.clone(),
1077
1062
  // TODO: Implement - https://github.com/temporalio/sdk-core/issues/293
1078
1063
  last_heartbeat_details: None,
1064
+ worker_version: None,
1079
1065
  })
1080
1066
  .await?
1081
1067
  .into_inner())
1082
1068
  }
1083
1069
 
1084
- async fn fail_workflow_task(
1085
- &self,
1086
- task_token: TaskToken,
1087
- cause: WorkflowTaskFailedCause,
1088
- failure: Option<Failure>,
1089
- ) -> Result<RespondWorkflowTaskFailedResponse> {
1090
- let request = RespondWorkflowTaskFailedRequest {
1091
- task_token: task_token.0,
1092
- cause: cause as i32,
1093
- failure,
1094
- identity: self.inner.options.identity.clone(),
1095
- binary_checksum: self.bound_worker_build_id.clone().unwrap_or_default(),
1096
- namespace: self.namespace.clone(),
1097
- messages: vec![],
1098
- };
1099
- Ok(self
1100
- .wf_svc()
1101
- .respond_workflow_task_failed(request)
1102
- .await?
1103
- .into_inner())
1104
- }
1105
-
1106
1070
  async fn signal_workflow_execution(
1107
1071
  &self,
1108
1072
  workflow_id: String,
@@ -1145,6 +1109,7 @@ impl WorkflowClientTrait for Client {
1145
1109
  task_queue: Some(TaskQueue {
1146
1110
  name: options.task_queue,
1147
1111
  kind: TaskQueueKind::Normal as i32,
1112
+ normal_name: "".to_string(),
1148
1113
  }),
1149
1114
  input: options.input,
1150
1115
  signal_name: options.signal_name,
@@ -759,6 +759,15 @@ proxier! {
759
759
  r.extensions_mut().insert(labels);
760
760
  }
761
761
  );
762
+ (
763
+ get_worker_task_reachability,
764
+ GetWorkerTaskReachabilityRequest,
765
+ GetWorkerTaskReachabilityResponse,
766
+ |r| {
767
+ let mut labels = AttachMetricLabels::namespace(r.get_ref().namespace.clone());
768
+ r.extensions_mut().insert(labels);
769
+ }
770
+ );
762
771
  (
763
772
  update_workflow_execution,
764
773
  UpdateWorkflowExecutionRequest,
@@ -9,7 +9,6 @@ use temporal_sdk_core_protos::{
9
9
  coresdk::workflow_commands::QueryResult,
10
10
  temporal::api::{
11
11
  common::v1::{Payload, Payloads},
12
- enums::v1::WorkflowTaskFailedCause,
13
12
  failure::v1::Failure,
14
13
  query::v1::WorkflowQuery,
15
14
  workflowservice::v1::*,
@@ -326,21 +325,6 @@ where
326
325
  )
327
326
  }
328
327
 
329
- async fn fail_workflow_task(
330
- &self,
331
- task_token: TaskToken,
332
- cause: WorkflowTaskFailedCause,
333
- failure: Option<Failure>,
334
- ) -> Result<RespondWorkflowTaskFailedResponse> {
335
- retry_call!(
336
- self,
337
- fail_workflow_task,
338
- task_token.clone(),
339
- cause,
340
- failure.clone()
341
- )
342
- }
343
-
344
328
  async fn signal_workflow_execution(
345
329
  &self,
346
330
  workflow_id: String,
@@ -13,23 +13,27 @@ categories = ["development-tools"]
13
13
  [lib]
14
14
 
15
15
  [features]
16
+ default = []
16
17
  # Do not enable this feature when building production SDKs. If we ever want a user in the field to
17
18
  # record WF input data, we can build them a custom SDK or they can build - it adds significant extra
18
19
  # code size in the form of [de]serializers.
19
20
  save_wf_inputs = ["rmp-serde", "temporal-sdk-core-protos/serde_serialize"]
21
+ tokio-console = ["console-subscriber"]
22
+ ephemeral-server = ["dep:flate2", "dep:nix", "dep:reqwest", "dep:tar", "dep:zip"]
20
23
 
21
24
  [dependencies]
22
25
  anyhow = "1.0"
23
26
  arc-swap = "1.3"
24
27
  async-trait = "0.1"
25
28
  base64 = "0.21"
29
+ console-subscriber = { version = "0.1", optional = true }
26
30
  crossbeam = "0.8"
27
31
  dashmap = "5.0"
28
32
  derive_builder = "0.12"
29
33
  derive_more = "0.99"
30
34
  enum_dispatch = "0.3"
31
35
  enum-iterator = "1.4"
32
- flate2 = "1.0"
36
+ flate2 = { version = "1.0", optional = true }
33
37
  futures = "0.3"
34
38
  futures-util = "0.3"
35
39
  governor = "0.5"
@@ -39,7 +43,7 @@ itertools = "0.10"
39
43
  lazy_static = "1.4"
40
44
  lru = "0.10"
41
45
  mockall = "0.11"
42
- nix = "0.26"
46
+ nix = { version = "0.26", optional = true }
43
47
  once_cell = "1.5"
44
48
  opentelemetry = { version = "0.18", features = ["rt-tokio"] }
45
49
  opentelemetry-otlp = { version = "0.11", features = ["tokio", "metrics"] }
@@ -50,14 +54,14 @@ prometheus = "0.13"
50
54
  prost = "0.11"
51
55
  prost-types = { version = "0.4", package = "prost-wkt-types" }
52
56
  rand = "0.8.3"
53
- reqwest = { version = "0.11", features = ["json", "stream", "rustls-tls", "tokio-rustls"], default-features = false }
57
+ reqwest = { version = "0.11", features = ["json", "stream", "rustls-tls", "tokio-rustls"], default-features = false, optional = true }
54
58
  ringbuf = "0.3"
55
59
  rmp-serde = { version = "1.1", optional = true }
56
60
  serde = "1.0"
57
61
  serde_json = "1.0"
58
62
  siphasher = "0.3"
59
63
  slotmap = "1.0"
60
- tar = "0.4"
64
+ tar = { version = "0.4", optional = true }
61
65
  thiserror = "1.0"
62
66
  tokio = { version = "1.26", features = ["rt", "rt-multi-thread", "parking_lot", "time", "fs", "process"] }
63
67
  tokio-util = { version = "0.7", features = ["io", "io-util"] }
@@ -69,7 +73,7 @@ tracing-opentelemetry = "0.18"
69
73
  tracing-subscriber = { version = "0.3", features = ["parking_lot", "env-filter", "registry"] }
70
74
  url = "2.2"
71
75
  uuid = { version = "1.1", features = ["v4"] }
72
- zip = "0.6.3"
76
+ zip = { version = "0.6.3", optional = true }
73
77
 
74
78
  # 1st party local deps
75
79
  [dependencies.temporal-sdk-core-api]
@@ -4,7 +4,6 @@ pub mod take_cell;
4
4
 
5
5
  use crate::MetricsContext;
6
6
  use derive_more::DebugCustom;
7
- use futures::{stream, Stream, StreamExt};
8
7
  use std::{
9
8
  fmt::{Debug, Formatter},
10
9
  sync::{
@@ -47,6 +46,11 @@ impl MeteredSemaphore {
47
46
  self.sem.available_permits()
48
47
  }
49
48
 
49
+ #[cfg(test)]
50
+ pub fn unused_permits(&self) -> usize {
51
+ self.sem.available_permits() + self.unused_claimants.load(Ordering::Acquire)
52
+ }
53
+
50
54
  pub async fn acquire_owned(&self) -> Result<OwnedMeteredSemPermit, AcquireError> {
51
55
  let res = self.sem.clone().acquire_owned().await?;
52
56
  Ok(self.build_owned(res))
@@ -114,8 +118,8 @@ impl ClosableMeteredSemaphore {
114
118
 
115
119
  impl ClosableMeteredSemaphore {
116
120
  #[cfg(test)]
117
- pub fn available_permits(&self) -> usize {
118
- self.inner.available_permits()
121
+ pub fn unused_permits(&self) -> usize {
122
+ self.inner.unused_permits()
119
123
  }
120
124
 
121
125
  /// Request to close the semaphore and prevent new permits from being acquired.
@@ -231,35 +235,6 @@ impl UsedMeteredSemPermit {
231
235
  }
232
236
  }
233
237
 
234
- /// From the input stream, create a new stream which only pulls from the input stream when allowed.
235
- /// When allowed is determined by the passed in `proceeder` emitting an item. The input stream is
236
- /// only pulled from when that future resolves.
237
- ///
238
- /// This is *almost* identical to `zip`, but does not terminate early if the input stream closes.
239
- /// The proceeder must allow the poll before the returned stream closes. If the proceeder terminates
240
- /// the overall stream will terminate.
241
- pub(crate) fn stream_when_allowed<S, AS>(
242
- input: S,
243
- proceeder: AS,
244
- ) -> impl Stream<Item = (S::Item, AS::Item)>
245
- where
246
- S: Stream + Send + 'static,
247
- AS: Stream + Send + 'static,
248
- {
249
- let stream = stream::unfold(
250
- (proceeder.boxed(), input.boxed()),
251
- |(mut proceeder, mut input)| async {
252
- let v = proceeder.next().await;
253
- if let Some(v) = v {
254
- input.next().await.map(|i| ((i, v), (proceeder, input)))
255
- } else {
256
- None
257
- }
258
- },
259
- );
260
- stream
261
- }
262
-
263
238
  macro_rules! dbg_panic {
264
239
  ($($arg:tt)*) => {
265
240
  error!($($arg)*);
@@ -271,49 +246,6 @@ pub(crate) use dbg_panic;
271
246
  #[cfg(test)]
272
247
  mod tests {
273
248
  use super::*;
274
- use futures::pin_mut;
275
- use std::task::Poll;
276
- use tokio::sync::mpsc::unbounded_channel;
277
- use tokio_stream::wrappers::UnboundedReceiverStream;
278
-
279
- #[test]
280
- fn stream_when_allowed_works() {
281
- let inputs = stream::iter([1, 2, 3]);
282
- let (allow_tx, allow_rx) = unbounded_channel();
283
- let when_allowed = stream_when_allowed(inputs, UnboundedReceiverStream::new(allow_rx));
284
-
285
- let waker = futures::task::noop_waker_ref();
286
- let mut cx = std::task::Context::from_waker(waker);
287
- pin_mut!(when_allowed);
288
-
289
- allow_tx.send(()).unwrap();
290
- assert_eq!(
291
- when_allowed.poll_next_unpin(&mut cx),
292
- Poll::Ready(Some((1, ())))
293
- );
294
- // Now, it won't be ready
295
- for _ in 1..10 {
296
- assert_eq!(when_allowed.poll_next_unpin(&mut cx), Poll::Pending);
297
- }
298
- allow_tx.send(()).unwrap();
299
- assert_eq!(
300
- when_allowed.poll_next_unpin(&mut cx),
301
- Poll::Ready(Some((2, ())))
302
- );
303
- for _ in 1..10 {
304
- assert_eq!(when_allowed.poll_next_unpin(&mut cx), Poll::Pending);
305
- }
306
- allow_tx.send(()).unwrap();
307
- assert_eq!(
308
- when_allowed.poll_next_unpin(&mut cx),
309
- Poll::Ready(Some((3, ())))
310
- );
311
- for _ in 1..10 {
312
- assert_eq!(when_allowed.poll_next_unpin(&mut cx), Poll::Pending);
313
- }
314
- allow_tx.send(()).unwrap();
315
- assert_eq!(when_allowed.poll_next_unpin(&mut cx), Poll::Ready(None));
316
- }
317
249
 
318
250
  #[tokio::test]
319
251
  async fn closable_semaphore_permit_drop_returns_permit() {
@@ -1058,26 +1058,34 @@ async fn graceful_shutdown(#[values(true, false)] at_max_outstanding: bool) {
1058
1058
  let _task_q = "q";
1059
1059
  let grace_period = Duration::from_millis(200);
1060
1060
  let mut tasks = three_tasks();
1061
- let mut mock_client = mock_workflow_client();
1062
- mock_client
1063
- .expect_poll_activity_task()
1061
+ let mut mock_act_poller = mock_poller();
1062
+ mock_act_poller
1063
+ .expect_poll()
1064
1064
  .times(3)
1065
- .returning(move |_, _| Ok(tasks.pop_front().unwrap()));
1065
+ .returning(move || Some(Ok(tasks.pop_front().unwrap())));
1066
+ mock_act_poller
1067
+ .expect_poll()
1068
+ .times(1)
1069
+ .returning(move || None);
1066
1070
  // They shall all be reported as failed
1071
+ let mut mock_client = mock_workflow_client();
1067
1072
  mock_client
1068
1073
  .expect_fail_activity_task()
1069
1074
  .times(3)
1070
1075
  .returning(|_, _| Ok(Default::default()));
1071
1076
 
1072
1077
  let max_outstanding = if at_max_outstanding { 3_usize } else { 100 };
1073
- let worker = Worker::new_test(
1074
- test_worker_cfg()
1078
+ let mw = MockWorkerInputs {
1079
+ act_poller: Some(Box::from(mock_act_poller)),
1080
+ config: test_worker_cfg()
1075
1081
  .graceful_shutdown_period(grace_period)
1076
1082
  .max_outstanding_activities(max_outstanding)
1083
+ .max_concurrent_at_polls(1_usize) // Makes test logic simple
1077
1084
  .build()
1078
1085
  .unwrap(),
1079
- mock_client,
1080
- );
1086
+ ..Default::default()
1087
+ };
1088
+ let worker = mock_worker(MocksHolder::from_mock_worker(mock_client, mw));
1081
1089
 
1082
1090
  let _1 = worker.poll_activity_task().await.unwrap();
1083
1091