@temporalio/core-bridge 1.4.3 → 1.5.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.
Files changed (123) hide show
  1. package/Cargo.lock +327 -419
  2. package/Cargo.toml +1 -1
  3. package/index.js +25 -2
  4. package/lib/errors.d.ts +22 -0
  5. package/lib/errors.js +65 -0
  6. package/lib/errors.js.map +1 -0
  7. package/lib/index.d.ts +440 -0
  8. package/lib/index.js +8 -0
  9. package/lib/index.js.map +1 -0
  10. package/package.json +11 -5
  11. package/releases/aarch64-apple-darwin/index.node +0 -0
  12. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  13. package/releases/x86_64-apple-darwin/index.node +0 -0
  14. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  15. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  16. package/sdk-core/.buildkite/docker/Dockerfile +1 -1
  17. package/sdk-core/.buildkite/docker/docker-compose.yaml +2 -2
  18. package/sdk-core/bridge-ffi/Cargo.toml +1 -1
  19. package/sdk-core/bridge-ffi/include/sdk-core-bridge.h +0 -25
  20. package/sdk-core/bridge-ffi/src/lib.rs +29 -108
  21. package/sdk-core/bridge-ffi/src/wrappers.rs +35 -25
  22. package/sdk-core/client/Cargo.toml +1 -1
  23. package/sdk-core/client/src/lib.rs +12 -20
  24. package/sdk-core/client/src/raw.rs +9 -8
  25. package/sdk-core/client/src/retry.rs +100 -23
  26. package/sdk-core/core/Cargo.toml +5 -5
  27. package/sdk-core/core/benches/workflow_replay.rs +13 -10
  28. package/sdk-core/core/src/abstractions.rs +22 -22
  29. package/sdk-core/core/src/core_tests/activity_tasks.rs +78 -1
  30. package/sdk-core/core/src/core_tests/local_activities.rs +228 -6
  31. package/sdk-core/core/src/core_tests/queries.rs +247 -89
  32. package/sdk-core/core/src/core_tests/workers.rs +2 -2
  33. package/sdk-core/core/src/core_tests/workflow_cancels.rs +1 -1
  34. package/sdk-core/core/src/core_tests/workflow_tasks.rs +46 -27
  35. package/sdk-core/core/src/lib.rs +139 -32
  36. package/sdk-core/core/src/replay/mod.rs +185 -41
  37. package/sdk-core/core/src/telemetry/log_export.rs +190 -0
  38. package/sdk-core/core/src/telemetry/metrics.rs +184 -139
  39. package/sdk-core/core/src/telemetry/mod.rs +296 -318
  40. package/sdk-core/core/src/telemetry/prometheus_server.rs +4 -3
  41. package/sdk-core/core/src/test_help/mod.rs +15 -8
  42. package/sdk-core/core/src/worker/activities/local_activities.rs +2 -1
  43. package/sdk-core/core/src/worker/activities.rs +40 -23
  44. package/sdk-core/core/src/worker/client/mocks.rs +1 -1
  45. package/sdk-core/core/src/worker/client.rs +30 -4
  46. package/sdk-core/core/src/worker/mod.rs +22 -18
  47. package/sdk-core/core/src/worker/workflow/driven_workflow.rs +10 -19
  48. package/sdk-core/core/src/worker/workflow/history_update.rs +99 -25
  49. package/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +1 -5
  50. package/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +1 -5
  51. package/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +1 -5
  52. package/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +1 -5
  53. package/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +1 -5
  54. package/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +2 -6
  55. package/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +1 -5
  56. package/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +18 -21
  57. package/sdk-core/core/src/worker/workflow/machines/mod.rs +12 -38
  58. package/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +178 -0
  59. package/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +1 -5
  60. package/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +1 -5
  61. package/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +1 -5
  62. package/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +8 -2
  63. package/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +1 -5
  64. package/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +232 -216
  65. package/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +1 -6
  66. package/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +4 -4
  67. package/sdk-core/core/src/worker/workflow/managed_run.rs +13 -5
  68. package/sdk-core/core/src/worker/workflow/mod.rs +84 -30
  69. package/sdk-core/core/src/worker/workflow/wft_poller.rs +2 -2
  70. package/sdk-core/core/src/worker/workflow/workflow_stream.rs +56 -11
  71. package/sdk-core/core-api/Cargo.toml +4 -3
  72. package/sdk-core/core-api/src/lib.rs +1 -43
  73. package/sdk-core/core-api/src/telemetry.rs +147 -0
  74. package/sdk-core/core-api/src/worker.rs +13 -0
  75. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
  76. package/sdk-core/histories/evict_while_la_running_no_interference-23_history.bin +0 -0
  77. package/sdk-core/histories/evict_while_la_running_no_interference-85_history.bin +0 -0
  78. package/sdk-core/protos/api_upstream/.github/CODEOWNERS +1 -1
  79. package/sdk-core/protos/api_upstream/buf.yaml +0 -3
  80. package/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +3 -7
  81. package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +8 -0
  82. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +1 -2
  83. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +2 -0
  84. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +3 -0
  85. package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +13 -0
  86. package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +19 -59
  87. package/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +0 -19
  88. package/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +108 -29
  89. package/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +2 -2
  90. package/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +1 -0
  91. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +47 -8
  92. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +15 -1
  93. package/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
  94. package/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +8 -1
  95. package/sdk-core/sdk/src/interceptors.rs +36 -3
  96. package/sdk-core/sdk/src/lib.rs +7 -4
  97. package/sdk-core/sdk/src/workflow_context.rs +13 -2
  98. package/sdk-core/sdk-core-protos/src/history_builder.rs +47 -1
  99. package/sdk-core/sdk-core-protos/src/history_info.rs +22 -22
  100. package/sdk-core/sdk-core-protos/src/lib.rs +49 -27
  101. package/sdk-core/test-utils/Cargo.toml +1 -0
  102. package/sdk-core/test-utils/src/lib.rs +81 -29
  103. package/sdk-core/tests/integ_tests/metrics_tests.rs +37 -0
  104. package/sdk-core/tests/integ_tests/polling_tests.rs +0 -13
  105. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +145 -4
  106. package/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +53 -0
  107. package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +106 -20
  108. package/sdk-core/tests/integ_tests/workflow_tests.rs +18 -8
  109. package/sdk-core/tests/main.rs +6 -4
  110. package/src/conversions.rs +52 -47
  111. package/src/errors.rs +28 -86
  112. package/src/helpers.rs +3 -4
  113. package/src/lib.rs +2 -2
  114. package/src/runtime.rs +132 -61
  115. package/src/testing.rs +7 -4
  116. package/src/worker.rs +67 -50
  117. package/ts/errors.ts +55 -0
  118. package/{index.d.ts → ts/index.ts} +121 -15
  119. package/sdk-core/core/src/log_export.rs +0 -62
  120. package/sdk-core/core/src/worker/workflow/machines/mutable_side_effect_state_machine.rs +0 -127
  121. package/sdk-core/core/src/worker/workflow/machines/side_effect_state_machine.rs +0 -71
  122. package/sdk-core/protos/api_upstream/temporal/api/cluster/v1/message.proto +0 -83
  123. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/cluster.proto +0 -40
package/Cargo.toml CHANGED
@@ -20,7 +20,7 @@ incremental = false
20
20
  futures = { version = "0.3", features = ["executor"] }
21
21
  log = "0.4"
22
22
  neon = { version = "0.10", default-features = false, features = ["napi-6", "event-queue-api"] }
23
- opentelemetry = "0.16"
23
+ opentelemetry = "0.18"
24
24
  parking_lot = "0.12"
25
25
  prost = "0.11"
26
26
  prost-types = "0.11"
package/index.js CHANGED
@@ -1,8 +1,31 @@
1
1
  const { getPrebuiltPath } = require('./common');
2
+ const typescriptExports = require('./lib/index');
3
+ const { convertFromNamedError } = require('./lib/errors');
4
+
5
+ function wrapErrors(fn) {
6
+ return (...args) => {
7
+ try {
8
+ // Some of our native functions expect callback functions. When present, these callbacks are
9
+ // always the last argument passed to the function, and always adhere to the signature
10
+ // `callback(err, result)`. If a callback is present, then make sure that errors sent
11
+ // to it are also converted.
12
+ if (typeof args[args.length - 1] === 'function') {
13
+ const callback = args[args.length - 1];
14
+ args[args.length - 1] = (e, x) => callback(convertFromNamedError(e, false), x);
15
+ }
16
+ return fn(...args);
17
+ } catch (e) {
18
+ throw convertFromNamedError(e, true);
19
+ }
20
+ };
21
+ }
2
22
 
3
23
  try {
4
- const prebuiltPath = getPrebuiltPath();
5
- module.exports = require(prebuiltPath);
24
+ const nativeLibPath = getPrebuiltPath();
25
+ const nativeExports = Object.fromEntries(
26
+ Object.entries(require(nativeLibPath)).map(([name, fn]) => [name, wrapErrors(fn)])
27
+ );
28
+ module.exports = { ...typescriptExports, ...nativeExports };
6
29
  } catch (err) {
7
30
  throw err;
8
31
  }
@@ -0,0 +1,22 @@
1
+ import { IllegalStateError } from '@temporalio/common';
2
+ /**
3
+ * The worker has been shut down
4
+ */
5
+ export declare class ShutdownError extends Error {
6
+ readonly name = "ShutdownError";
7
+ }
8
+ /**
9
+ * Thrown after shutdown was requested as a response to a poll function, JS should stop polling
10
+ * once this error is encountered
11
+ */
12
+ export declare class TransportError extends Error {
13
+ readonly name = "TransportError";
14
+ }
15
+ /**
16
+ * Something unexpected happened, considered fatal
17
+ */
18
+ export declare class UnexpectedError extends Error {
19
+ readonly name = "UnexpectedError";
20
+ }
21
+ export { IllegalStateError };
22
+ export declare function convertFromNamedError(e: unknown, keepStackTrace: boolean): unknown;
package/lib/errors.js ADDED
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertFromNamedError = exports.IllegalStateError = exports.UnexpectedError = exports.TransportError = exports.ShutdownError = void 0;
4
+ const common_1 = require("@temporalio/common");
5
+ Object.defineProperty(exports, "IllegalStateError", { enumerable: true, get: function () { return common_1.IllegalStateError; } });
6
+ /**
7
+ * The worker has been shut down
8
+ */
9
+ class ShutdownError extends Error {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.name = 'ShutdownError';
13
+ }
14
+ }
15
+ exports.ShutdownError = ShutdownError;
16
+ /**
17
+ * Thrown after shutdown was requested as a response to a poll function, JS should stop polling
18
+ * once this error is encountered
19
+ */
20
+ class TransportError extends Error {
21
+ constructor() {
22
+ super(...arguments);
23
+ this.name = 'TransportError';
24
+ }
25
+ }
26
+ exports.TransportError = TransportError;
27
+ /**
28
+ * Something unexpected happened, considered fatal
29
+ */
30
+ class UnexpectedError extends Error {
31
+ constructor() {
32
+ super(...arguments);
33
+ this.name = 'UnexpectedError';
34
+ }
35
+ }
36
+ exports.UnexpectedError = UnexpectedError;
37
+ function convertFromNamedError(e, keepStackTrace) {
38
+ // Check if the error's class is exactly Error (not a descendant of it).
39
+ // The instanceof check both ensure that e is indeed an object AND avoid
40
+ // TypeScript from complaining on accessing Error properties.
41
+ if (e instanceof Error && Object.getPrototypeOf(e).name === 'Error') {
42
+ let newerr;
43
+ switch (e.name) {
44
+ case 'TransportError':
45
+ newerr = new TransportError(e.message);
46
+ newerr.stack = keepStackTrace ? e.stack : undefined;
47
+ return newerr;
48
+ case 'IllegalStateError':
49
+ newerr = new common_1.IllegalStateError(e.message);
50
+ newerr.stack = keepStackTrace ? e.stack : undefined;
51
+ return newerr;
52
+ case 'ShutdownError':
53
+ newerr = new ShutdownError(e.message);
54
+ newerr.stack = keepStackTrace ? e.stack : undefined;
55
+ return newerr;
56
+ case 'UnexpectedError':
57
+ newerr = new UnexpectedError(e.message);
58
+ newerr.stack = keepStackTrace ? e.stack : undefined;
59
+ return newerr;
60
+ }
61
+ }
62
+ return e;
63
+ }
64
+ exports.convertFromNamedError = convertFromNamedError;
65
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +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;gBAC1C,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;gBACpD,OAAO,MAAM,CAAC;YAEhB,KAAK,eAAe;gBAClB,MAAM,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBACtC,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;gBACpD,OAAO,MAAM,CAAC;YAEhB,KAAK,iBAAiB;gBACpB,MAAM,GAAG,IAAI,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBACxC,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;gBACpD,OAAO,MAAM,CAAC;SACjB;KACF;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AA7BD,sDA6BC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,440 @@
1
+ import { SpanContext } from '@opentelemetry/api';
2
+ import type { TLSConfig } from '@temporalio/common/lib/internal-non-workflow';
3
+ export { TLSConfig };
4
+ declare type Shadow<Base, New> = Base extends object ? New extends object ? {
5
+ [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
+ } : New : New;
7
+ export interface RetryOptions {
8
+ /** Initial wait time before the first retry. */
9
+ initialInterval: number;
10
+ /**
11
+ * Randomization jitter that is used as a multiplier for the current retry interval
12
+ * and is added or subtracted from the interval length.
13
+ */
14
+ randomizationFactor: number;
15
+ /** Rate at which retry time should be increased, until it reaches max_interval. */
16
+ multiplier: number;
17
+ /** Maximum amount of time to wait between retries. */
18
+ maxInterval: number;
19
+ /** Maximum total amount of time requests should be retried for, if None is set then no limit will be used. */
20
+ maxElapsedTime?: number;
21
+ /** Maximum number of retry attempts. */
22
+ maxRetries: number;
23
+ }
24
+ export interface ClientOptions {
25
+ /**
26
+ * The URL of the Temporal server to connect to
27
+ */
28
+ url: string;
29
+ /** Version string for the whole node SDK. Should never be set by user */
30
+ sdkVersion: string;
31
+ /**
32
+ * TLS configuration options.
33
+ *
34
+ * Pass undefined to use a non-encrypted connection or an empty object to
35
+ * connect with TLS without any customization.
36
+ */
37
+ tls?: TLSConfig;
38
+ /**
39
+ * Optional retry options for server requests.
40
+ */
41
+ retry?: RetryOptions;
42
+ /**
43
+ * Optional mapping of gRPC metadata (HTTP headers) to send with each request to the server.
44
+ *
45
+ * Set statically at connection time, can be replaced later using {@link clientUpdateHeaders}.
46
+ */
47
+ metadata?: Record<string, string>;
48
+ }
49
+ /**
50
+ * Log directly to console
51
+ *
52
+ * @experimental
53
+ */
54
+ export interface ConsoleLogger {
55
+ console: {};
56
+ }
57
+ /**
58
+ * Forward logs to {@link Runtime} logger
59
+ *
60
+ * @experimental
61
+ */
62
+ export interface ForwardLogger {
63
+ forward: {
64
+ /**
65
+ * What level, if any, logs should be forwarded from core at
66
+ *
67
+ * @deprecated Use {@link TelemetryOptions.logging.filter} instead
68
+ */
69
+ level?: LogLevel;
70
+ };
71
+ }
72
+ /**
73
+ * Logger types supported by Core
74
+ *
75
+ * @experimental
76
+ */
77
+ export declare type Logger = ConsoleLogger | ForwardLogger;
78
+ /**
79
+ * OpenTelemetry Collector options for exporting metrics or traces
80
+ *
81
+ * @experimental
82
+ */
83
+ export interface OtelCollectorExporter {
84
+ otel: {
85
+ /**
86
+ * URL of a gRPC OpenTelemetry collector.
87
+ */
88
+ url: string;
89
+ /**
90
+ * Optional set of HTTP request headers to send to Collector (e.g. for authentication)
91
+ */
92
+ headers?: Record<string, string>;
93
+ /**
94
+ * Specify how frequently in metrics should be exported.
95
+ *
96
+ * @format number of milliseconds or {@link https://www.npmjs.com/package/ms | ms-formatted string}
97
+ * @defaults 1 second
98
+ */
99
+ metricsExportInterval?: string | number;
100
+ };
101
+ }
102
+ /** @experimental */
103
+ export declare type CompiledOtelTraceExporter = Shadow<OtelCollectorExporter, {
104
+ otel: {
105
+ metricsExportInterval?: never;
106
+ };
107
+ }>;
108
+ /** @experimental */
109
+ export declare type CompiledOtelMetricsExporter = Shadow<OtelCollectorExporter, {
110
+ otel: {
111
+ metricsExportInterval: number;
112
+ };
113
+ }>;
114
+ /**
115
+ * Prometheus metrics exporter options
116
+ *
117
+ * @experimental
118
+ */
119
+ export interface PrometheusMetricsExporter {
120
+ prometheus: {
121
+ /**
122
+ * Address to bind the Prometheus HTTP metrics exporter server
123
+ * (for example, `0.0.0.0:1234`).
124
+ *
125
+ * Metrics will be available for scraping under the standard `/metrics` route.
126
+ */
127
+ bindAddress: string;
128
+ };
129
+ }
130
+ /**
131
+ * Metrics exporters supported by Core
132
+ *
133
+ * `temporality` is the type of aggregation temporality for metric export. Applies to both Prometheus and OpenTelemetry exporters.
134
+ *
135
+ * See the [OpenTelemetry specification](https://github.com/open-telemetry/opentelemetry-specification/blob/ce50e4634efcba8da445cc23523243cb893905cb/specification/metrics/datamodel.md#temporality) for more information.
136
+ *
137
+ * @experimental
138
+ */
139
+ export declare type MetricsExporter = {
140
+ temporality?: 'cumulative' | 'delta';
141
+ } & (PrometheusMetricsExporter | OtelCollectorExporter);
142
+ /**
143
+ * Trace exporters supported by Core
144
+ *
145
+ * @experimental
146
+ */
147
+ export declare type TraceExporter = OtelCollectorExporter;
148
+ /** @experimental */
149
+ export interface TelemetryOptions {
150
+ /**
151
+ * A string in the env filter format specified here:
152
+ * https://docs.rs/tracing-subscriber/0.2.20/tracing_subscriber/struct.EnvFilter.html
153
+ *
154
+ * Which determines what tracing data is collected in the Core SDK.
155
+ *
156
+ * @deprecated Use either `logging.filter` or `tracing.filter` instead
157
+ */
158
+ tracingFilter?: string;
159
+ /**
160
+ * If set true, do not prefix metrics with `temporal_`. Will be removed eventually as
161
+ * the prefix is consistent with other SDKs.
162
+ *
163
+ * @default `false`
164
+ */
165
+ noTemporalPrefixForMetrics?: boolean;
166
+ /**
167
+ * Control where to send Rust Core logs
168
+ */
169
+ logging?: {
170
+ /**
171
+ * A string in (env filter format)[https://docs.rs/tracing-subscriber/0.2.20/tracing_subscriber/struct.EnvFilter.html]
172
+ * which determines the verboseness of logging output.
173
+ *
174
+ * You can use {@link Runtime.makeTelemetryFilterString()} to easily build a correctly formatted filter
175
+ * string based on desired log level for Core SDK and other native packages.
176
+ *
177
+ * **BACKWARD COMPATIBILITY**
178
+ *
179
+ * If `logging.filter` is missing, the following legacy values (if present) will be used instead (in the given order):
180
+ * - {@link ForwardLogger.forward.level} => `makeTelemetryFilterString({ core: level, other: level })`
181
+ * - {@link TelemetryOptions.tracingFilter}
182
+ * - Default value of `makeTelemetryFilterString({ core: 'INFO', other: 'INFO'})`
183
+ *
184
+ * @default `makeTelemetryFilterString({ core: 'INFO', other: 'INFO'})` (with some exceptions, as described in backward compatibility note above)
185
+ */
186
+ filter?: string;
187
+ } & Partial<Logger>;
188
+ /**
189
+ * Control where to send traces generated by Rust Core, optional and turned off by default.
190
+ *
191
+ * This is typically used for profiling SDK internals.
192
+ */
193
+ tracing?: {
194
+ /**
195
+ * A string in (env filter format)[https://docs.rs/tracing-subscriber/0.2.20/tracing_subscriber/struct.EnvFilter.html]
196
+ * which determines what tracing data is collected in the Core SDK.
197
+ *
198
+ * You can use {@link Runtime.makeTelemetryFilterString()} to easily build a correctly formatted filter
199
+ * string based on desired log level for Core SDK and other native packages.
200
+ *
201
+ * **BACKWARD COMPATIBILITY**
202
+ *
203
+ * If `tracing.filter` is missing, the following legacy values (if present) will be used instead (in the given order):
204
+ * - {@link TelemetryOptions.tracingFilter}
205
+ * - Default value of `makeTelemetryFilterString({ core: 'INFO', other: 'INFO'})`
206
+ *
207
+ * @default `makeTelemetryFilterString({ core: 'INFO', other: 'INFO'})` (with some exceptions, as described in backward compatibility note above)
208
+ */
209
+ filter?: string;
210
+ } & Partial<TraceExporter>;
211
+ /**
212
+ * Control exporting {@link NativeConnection} and {@link Worker} metrics.
213
+ *
214
+ * Turned off by default
215
+ */
216
+ metrics?: MetricsExporter;
217
+ }
218
+ /** @experimental */
219
+ export declare type CompiledTelemetryOptions = {
220
+ noTemporalPrefixForMetrics?: boolean;
221
+ logging: {
222
+ filter: string;
223
+ } & ({
224
+ console: {};
225
+ } | {
226
+ forward: {};
227
+ });
228
+ tracing?: {
229
+ filter: string;
230
+ } & CompiledOtelTraceExporter;
231
+ metrics?: {
232
+ temporality?: 'cumulative' | 'delta';
233
+ } & (PrometheusMetricsExporter | CompiledOtelMetricsExporter);
234
+ };
235
+ export interface WorkerOptions {
236
+ /**
237
+ * A human-readable string that can identify your worker
238
+ */
239
+ identity: string;
240
+ /**
241
+ * A string that should be unique to the exact worker code/binary being executed
242
+ */
243
+ buildId: string;
244
+ /**
245
+ * The task queue the worker will pull from
246
+ */
247
+ taskQueue: string;
248
+ maxConcurrentActivityTaskExecutions: number;
249
+ maxConcurrentWorkflowTaskExecutions: number;
250
+ maxConcurrentLocalActivityExecutions: number;
251
+ /**
252
+ * If set to `false` this worker will only handle workflow tasks and local activities, it will not
253
+ * poll for activity tasks.
254
+ */
255
+ enableNonLocalActivities: boolean;
256
+ /**
257
+ * How long a workflow task is allowed to sit on the sticky queue before it is timed out
258
+ * and moved to the non-sticky queue where it may be picked up by any worker.
259
+ */
260
+ stickyQueueScheduleToStartTimeoutMs: number;
261
+ /**
262
+ * Maximum number of Workflow instances to cache before automatic eviction
263
+ */
264
+ maxCachedWorkflows: number;
265
+ /**
266
+ * Longest interval for throttling activity heartbeats
267
+ * @default 60 seconds
268
+ */
269
+ maxHeartbeatThrottleIntervalMs: number;
270
+ /**
271
+ * Default interval for throttling activity heartbeats in case
272
+ * `ActivityOptions.heartbeat_timeout` is unset.
273
+ * When the timeout *is* set in the `ActivityOptions`, throttling is set to
274
+ * `heartbeat_timeout * 0.8`.
275
+ * @default 30 seconds
276
+ */
277
+ defaultHeartbeatThrottleIntervalMs: number;
278
+ /**
279
+ * Sets the maximum number of activities per second the task queue will dispatch, controlled
280
+ * server-side. Note that this only takes effect upon an activity poll request. If multiple
281
+ * workers on the same queue have different values set, they will thrash with the last poller
282
+ * winning.
283
+ */
284
+ maxTaskQueueActivitiesPerSecond?: number;
285
+ /**
286
+ * Limits the number of activities per second that this worker will process. The worker will
287
+ * not poll for new activities if by doing so it might receive and execute an activity which
288
+ * would cause it to exceed this limit. Must be a positive floating point number.
289
+ */
290
+ maxActivitiesPerSecond?: number;
291
+ }
292
+ /** Log level - must match rust log level names */
293
+ export declare type LogLevel = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
294
+ export interface LogEntry {
295
+ /** Log message */
296
+ message: string;
297
+ /**
298
+ * Time since epoch [seconds, nanos].
299
+ *
300
+ * Should be switched to bigint once it is supported in neon.
301
+ */
302
+ timestamp: [number, number];
303
+ /** Log level */
304
+ level: LogLevel;
305
+ }
306
+ /**
307
+ * Which version of the executable to run.
308
+ */
309
+ export declare type EphemeralServerExecutable = {
310
+ type: 'cached-download';
311
+ /**
312
+ * Download destination directory or the system's temp directory if none set.
313
+ */
314
+ downloadDir?: string;
315
+ /**
316
+ * Optional version, can be set to a specific server release or "default" or "latest".
317
+ *
318
+ * At the time of writing the the server is released as part of the Java SDK - (https://github.com/temporalio/sdk-java/releases).
319
+ *
320
+ * @default "default" - get the best version for the current SDK version.
321
+ */
322
+ version?: string;
323
+ } | {
324
+ type: 'existing-path';
325
+ /** Path to executable */
326
+ path: string;
327
+ };
328
+ /**
329
+ * Configuration for the time-skipping test server.
330
+ */
331
+ export interface TimeSkippingServerConfig {
332
+ type: 'time-skipping';
333
+ executable?: EphemeralServerExecutable;
334
+ /**
335
+ * Optional port to listen on, defaults to find a random free port.
336
+ */
337
+ port?: number;
338
+ /**
339
+ * Extra args to pass to the executable command.
340
+ */
341
+ extraArgs?: string[];
342
+ }
343
+ /**
344
+ * Configuration for temporalite.
345
+ */
346
+ export interface TemporaliteConfig {
347
+ type: 'temporalite';
348
+ executable?: EphemeralServerExecutable;
349
+ /**
350
+ * Namespace to use - created at startup.
351
+ *
352
+ * @default "default"
353
+ */
354
+ namespace?: string;
355
+ /**
356
+ * IP to bind to.
357
+ *
358
+ * @default 127.0.0.1
359
+ */
360
+ ip?: string;
361
+ /**
362
+ * Sqlite DB filename if persisting or non-persistent if none.
363
+ */
364
+ db_filename?: string;
365
+ /**
366
+ * Whether to enable the UI.
367
+ */
368
+ ui?: boolean;
369
+ /**
370
+ * Log format and level
371
+ * @default { format: "pretty", level" "warn" }
372
+ */
373
+ log?: {
374
+ format: string;
375
+ level: string;
376
+ };
377
+ /**
378
+ * Optional port to listen on, defaults to find a random free port.
379
+ */
380
+ port?: number;
381
+ /**
382
+ * Extra args to pass to the executable command.
383
+ */
384
+ extraArgs?: string[];
385
+ }
386
+ /**
387
+ * Configuration for spawning an ephemeral Temporal server.
388
+ *
389
+ * Both the time-skipping test server and temporalite are supported.
390
+ */
391
+ export declare type EphemeralServerConfig = TimeSkippingServerConfig | TemporaliteConfig;
392
+ export interface Worker {
393
+ type: 'Worker';
394
+ }
395
+ export interface Runtime {
396
+ type: 'Runtime';
397
+ }
398
+ export interface Client {
399
+ type: 'Client';
400
+ }
401
+ export interface EphemeralServer {
402
+ type: 'EphemeralServer';
403
+ }
404
+ export interface HistoryPusher {
405
+ type: 'HistoryPusher';
406
+ }
407
+ export interface ReplayWorker {
408
+ type: 'ReplayWorker';
409
+ worker: Worker;
410
+ pusher: HistoryPusher;
411
+ }
412
+ export declare type Callback<T> = (err: Error, result: T) => void;
413
+ export declare type PollCallback = (err: Error, result: ArrayBuffer) => void;
414
+ export declare type WorkerCallback = (err: Error, result: Worker) => void;
415
+ export declare type ReplayWorkerCallback = (err: Error, worker: ReplayWorker) => void;
416
+ export declare type ClientCallback = (err: Error, result: Client) => void;
417
+ export declare type VoidCallback = (err: Error, result: void) => void;
418
+ export declare type LogsCallback = (err: Error, result: LogEntry[]) => void;
419
+ export declare function newRuntime(telemOptions: CompiledTelemetryOptions): Runtime;
420
+ export declare function newClient(runtime: Runtime, clientOptions: ClientOptions, callback: ClientCallback): void;
421
+ export declare function newWorker(client: Client, workerOptions: WorkerOptions, callback: WorkerCallback): void;
422
+ export declare function newReplayWorker(runtime: Runtime, workerOptions: WorkerOptions, callback: ReplayWorkerCallback): void;
423
+ export declare function pushHistory(pusher: HistoryPusher, workflowId: string, history: ArrayBuffer, callback: VoidCallback): void;
424
+ export declare function closeHistoryStream(pusher: HistoryPusher): void;
425
+ export declare function workerInitiateShutdown(worker: Worker, callback: VoidCallback): void;
426
+ export declare function workerFinalizeShutdown(worker: Worker): void;
427
+ export declare function clientUpdateHeaders(client: Client, headers: Record<string, string>, callback: VoidCallback): void;
428
+ export declare function clientClose(client: Client): void;
429
+ export declare function runtimeShutdown(runtime: Runtime, callback: VoidCallback): void;
430
+ export declare function pollLogs(runtime: Runtime, callback: LogsCallback): void;
431
+ export declare function workerPollWorkflowActivation(worker: Worker, spanContext: SpanContext, callback: PollCallback): void;
432
+ export declare function workerCompleteWorkflowActivation(worker: Worker, spanContext: SpanContext, result: ArrayBuffer, callback: VoidCallback): void;
433
+ export declare function workerPollActivityTask(worker: Worker, spanContext: SpanContext, callback: PollCallback): void;
434
+ export declare function workerCompleteActivityTask(worker: Worker, spanContext: SpanContext, result: ArrayBuffer, callback: VoidCallback): void;
435
+ export declare function workerRecordActivityHeartbeat(worker: Worker, heartbeat: ArrayBuffer): void;
436
+ export declare function getTimeOfDay(): [number, number];
437
+ export declare function startEphemeralServer(runtime: Runtime, config: EphemeralServerConfig, sdkVersion: string, callback: Callback<EphemeralServer>): void;
438
+ export declare function shutdownEphemeralServer(server: EphemeralServer, callback: Callback<EphemeralServer>): void;
439
+ export declare function getEphemeralServerTarget(server: EphemeralServer): string;
440
+ export { ShutdownError, TransportError, UnexpectedError } from './errors';
package/lib/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnexpectedError = exports.TransportError = exports.ShutdownError = void 0;
4
+ var errors_1 = require("./errors");
5
+ Object.defineProperty(exports, "ShutdownError", { enumerable: true, get: function () { return errors_1.ShutdownError; } });
6
+ Object.defineProperty(exports, "TransportError", { enumerable: true, get: function () { return errors_1.TransportError; } });
7
+ Object.defineProperty(exports, "UnexpectedError", { enumerable: true, get: function () { return errors_1.UnexpectedError; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;AAigBA,mCAA0E;AAAjE,uGAAA,aAAa,OAAA;AAAE,wGAAA,cAAc,OAAA;AAAE,yGAAA,eAAe,OAAA"}
package/package.json CHANGED
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "name": "@temporalio/core-bridge",
3
- "version": "1.4.3",
3
+ "version": "1.5.0",
4
4
  "description": "Temporal.io SDK Core<>Node bridge",
5
5
  "main": "index.js",
6
- "types": "index.d.ts",
6
+ "types": "lib/index.d.ts",
7
7
  "scripts": {
8
8
  "build-rust": "node ./scripts/build.js --force",
9
9
  "build": "npm run build-rust",
10
10
  "build-rust-release": "npm run build-rust -- --release",
11
- "install": "node ./scripts/build.js"
11
+ "install": "node ./scripts/build.js",
12
+ "format": "cargo fmt",
13
+ "lint": "cargo clippy --fix",
14
+ "lint.check": "cargo clippy"
12
15
  },
13
16
  "keywords": [
14
17
  "temporal",
@@ -20,6 +23,7 @@
20
23
  "license": "MIT",
21
24
  "dependencies": {
22
25
  "@opentelemetry/api": "^1.1.0",
26
+ "@temporalio/common": "~1.5.0",
23
27
  "arg": "^5.0.2",
24
28
  "cargo-cp-artifact": "^0.1.6",
25
29
  "which": "^2.0.2"
@@ -37,10 +41,12 @@
37
41
  "Cargo.lock",
38
42
  "index.js",
39
43
  "common.js",
40
- "index.d.ts"
44
+ "index.d.ts",
45
+ "ts",
46
+ "lib"
41
47
  ],
42
48
  "publishConfig": {
43
49
  "access": "public"
44
50
  },
45
- "gitHead": "be51cfac7016b66151d70dbd5aca7f7ef02b260a"
51
+ "gitHead": "b46426d8b9b342c052d53520b50dbb991b8d5e03"
46
52
  }
@@ -1,4 +1,4 @@
1
- FROM rust:1.63
1
+ FROM rust:1.65
2
2
 
3
3
  RUN rustup component add rustfmt && \
4
4
  rustup component add clippy
@@ -9,7 +9,7 @@ services:
9
9
  # - '9042:9042'
10
10
 
11
11
  temporal:
12
- image: temporalio/auto-setup:1.16.2
12
+ image: temporalio/auto-setup:1.18.3
13
13
  ports:
14
14
  - "7233:7233"
15
15
  - "7234:7234"
@@ -28,7 +28,7 @@ services:
28
28
  - cassandra
29
29
 
30
30
  temporal-web:
31
- image: temporalio/ui:0.10.2
31
+ image: temporalio/ui:2.8.0
32
32
  logging:
33
33
  driver: none
34
34
  ports: