@temporalio/core-bridge 0.16.4 → 0.18.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 (170) hide show
  1. package/Cargo.lock +339 -226
  2. package/Cargo.toml +7 -3
  3. package/common.js +50 -0
  4. package/index.d.ts +7 -0
  5. package/index.js +12 -0
  6. package/package.json +7 -4
  7. package/releases/aarch64-apple-darwin/index.node +0 -0
  8. package/releases/aarch64-unknown-linux-gnu/index.node +0 -0
  9. package/{index.node → releases/index.node} +0 -0
  10. package/releases/x86_64-apple-darwin/index.node +0 -0
  11. package/releases/x86_64-pc-windows-msvc/index.node +0 -0
  12. package/releases/x86_64-unknown-linux-gnu/index.node +0 -0
  13. package/scripts/build.js +10 -50
  14. package/sdk-core/.buildkite/docker/Dockerfile +1 -1
  15. package/sdk-core/.buildkite/docker/docker-compose.yaml +2 -2
  16. package/sdk-core/.buildkite/pipeline.yml +2 -0
  17. package/sdk-core/Cargo.toml +1 -88
  18. package/sdk-core/README.md +30 -6
  19. package/sdk-core/bridge-ffi/Cargo.toml +24 -0
  20. package/sdk-core/bridge-ffi/LICENSE.txt +23 -0
  21. package/sdk-core/bridge-ffi/build.rs +25 -0
  22. package/sdk-core/bridge-ffi/include/sdk-core-bridge.h +216 -0
  23. package/sdk-core/bridge-ffi/src/lib.rs +829 -0
  24. package/sdk-core/bridge-ffi/src/wrappers.rs +193 -0
  25. package/sdk-core/client/Cargo.toml +32 -0
  26. package/sdk-core/{src/pollers/gateway.rs → client/src/lib.rs} +101 -195
  27. package/sdk-core/client/src/metrics.rs +89 -0
  28. package/sdk-core/client/src/mocks.rs +167 -0
  29. package/sdk-core/{src/pollers → client/src}/retry.rs +172 -14
  30. package/sdk-core/core/Cargo.toml +96 -0
  31. package/sdk-core/{src → core/src}/core_tests/activity_tasks.rs +193 -37
  32. package/sdk-core/{src → core/src}/core_tests/child_workflows.rs +14 -14
  33. package/sdk-core/{src → core/src}/core_tests/determinism.rs +8 -8
  34. package/sdk-core/core/src/core_tests/local_activities.rs +328 -0
  35. package/sdk-core/{src → core/src}/core_tests/mod.rs +6 -9
  36. package/sdk-core/{src → core/src}/core_tests/queries.rs +54 -54
  37. package/sdk-core/{src → core/src}/core_tests/replay_flag.rs +8 -12
  38. package/sdk-core/{src → core/src}/core_tests/workers.rs +120 -33
  39. package/sdk-core/{src → core/src}/core_tests/workflow_cancels.rs +16 -26
  40. package/sdk-core/{src → core/src}/core_tests/workflow_tasks.rs +280 -292
  41. package/sdk-core/core/src/lib.rs +374 -0
  42. package/sdk-core/{src → core/src}/log_export.rs +3 -27
  43. package/sdk-core/core/src/pending_activations.rs +162 -0
  44. package/sdk-core/{src → core/src}/pollers/mod.rs +4 -22
  45. package/sdk-core/{src → core/src}/pollers/poll_buffer.rs +1 -1
  46. package/sdk-core/core/src/protosext/mod.rs +396 -0
  47. package/sdk-core/core/src/replay/mod.rs +210 -0
  48. package/sdk-core/core/src/retry_logic.rs +144 -0
  49. package/sdk-core/{src → core/src}/telemetry/metrics.rs +3 -58
  50. package/sdk-core/{src → core/src}/telemetry/mod.rs +8 -8
  51. package/sdk-core/{src → core/src}/telemetry/prometheus_server.rs +0 -0
  52. package/sdk-core/{src → core/src}/test_help/mod.rs +35 -83
  53. package/sdk-core/{src → core/src}/worker/activities/activity_heartbeat_manager.rs +95 -42
  54. package/sdk-core/core/src/worker/activities/local_activities.rs +973 -0
  55. package/sdk-core/{src → core/src}/worker/activities.rs +52 -33
  56. package/sdk-core/{src → core/src}/worker/dispatcher.rs +8 -6
  57. package/sdk-core/{src → core/src}/worker/mod.rs +347 -221
  58. package/sdk-core/core/src/worker/wft_delivery.rs +81 -0
  59. package/sdk-core/{src → core/src}/workflow/bridge.rs +5 -2
  60. package/sdk-core/{src → core/src}/workflow/driven_workflow.rs +17 -7
  61. package/sdk-core/{src → core/src}/workflow/history_update.rs +33 -7
  62. package/sdk-core/{src → core/src/workflow}/machines/activity_state_machine.rs +26 -26
  63. package/sdk-core/{src → core/src/workflow}/machines/cancel_external_state_machine.rs +8 -11
  64. package/sdk-core/{src → core/src/workflow}/machines/cancel_workflow_state_machine.rs +19 -21
  65. package/sdk-core/{src → core/src/workflow}/machines/child_workflow_state_machine.rs +20 -31
  66. package/sdk-core/{src → core/src/workflow}/machines/complete_workflow_state_machine.rs +3 -5
  67. package/sdk-core/{src → core/src/workflow}/machines/continue_as_new_workflow_state_machine.rs +18 -18
  68. package/sdk-core/{src → core/src/workflow}/machines/fail_workflow_state_machine.rs +5 -6
  69. package/sdk-core/core/src/workflow/machines/local_activity_state_machine.rs +1451 -0
  70. package/sdk-core/{src → core/src/workflow}/machines/mod.rs +54 -107
  71. package/sdk-core/{src → core/src/workflow}/machines/mutable_side_effect_state_machine.rs +0 -0
  72. package/sdk-core/{src → core/src/workflow}/machines/patch_state_machine.rs +29 -30
  73. package/sdk-core/{src → core/src/workflow}/machines/side_effect_state_machine.rs +0 -0
  74. package/sdk-core/{src → core/src/workflow}/machines/signal_external_state_machine.rs +17 -19
  75. package/sdk-core/{src → core/src/workflow}/machines/timer_state_machine.rs +20 -21
  76. package/sdk-core/{src → core/src/workflow}/machines/transition_coverage.rs +5 -2
  77. package/sdk-core/{src → core/src/workflow}/machines/upsert_search_attributes_state_machine.rs +0 -0
  78. package/sdk-core/core/src/workflow/machines/workflow_machines/local_acts.rs +96 -0
  79. package/sdk-core/{src → core/src/workflow}/machines/workflow_machines.rs +357 -171
  80. package/sdk-core/{src → core/src/workflow}/machines/workflow_task_state_machine.rs +1 -1
  81. package/sdk-core/{src → core/src}/workflow/mod.rs +200 -39
  82. package/sdk-core/{src → core/src}/workflow/workflow_tasks/cache_manager.rs +0 -0
  83. package/sdk-core/{src → core/src}/workflow/workflow_tasks/concurrency_manager.rs +38 -5
  84. package/sdk-core/{src → core/src}/workflow/workflow_tasks/mod.rs +317 -103
  85. package/sdk-core/{test_utils → core-api}/Cargo.toml +10 -7
  86. package/sdk-core/{src → core-api/src}/errors.rs +42 -92
  87. package/sdk-core/core-api/src/lib.rs +158 -0
  88. package/sdk-core/{src/worker/config.rs → core-api/src/worker.rs} +18 -23
  89. package/sdk-core/etc/deps.svg +156 -0
  90. package/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +5 -5
  91. package/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +3 -5
  92. package/sdk-core/fsm/rustfsm_trait/src/lib.rs +7 -1
  93. package/sdk-core/histories/fail_wf_task.bin +0 -0
  94. package/sdk-core/histories/timer_workflow_history.bin +0 -0
  95. package/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +44 -13
  96. package/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +19 -1
  97. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +1 -1
  98. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +9 -0
  99. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +1 -0
  100. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +1 -0
  101. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +13 -0
  102. package/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +14 -7
  103. package/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +176 -18
  104. package/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +6 -0
  105. package/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +11 -0
  106. package/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +3 -0
  107. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +156 -7
  108. package/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +135 -104
  109. package/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +78 -0
  110. package/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +78 -0
  111. package/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +205 -0
  112. package/sdk-core/protos/local/temporal/sdk/core/bridge/service.proto +61 -0
  113. package/sdk-core/protos/local/{child_workflow.proto → temporal/sdk/core/child_workflow/child_workflow.proto} +1 -1
  114. package/sdk-core/protos/local/{common.proto → temporal/sdk/core/common/common.proto} +5 -3
  115. package/sdk-core/protos/local/{core_interface.proto → temporal/sdk/core/core_interface.proto} +10 -10
  116. package/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +30 -0
  117. package/sdk-core/protos/local/{workflow_activation.proto → temporal/sdk/core/workflow_activation/workflow_activation.proto} +35 -11
  118. package/sdk-core/protos/local/{workflow_commands.proto → temporal/sdk/core/workflow_commands/workflow_commands.proto} +55 -4
  119. package/sdk-core/protos/local/{workflow_completion.proto → temporal/sdk/core/workflow_completion/workflow_completion.proto} +3 -3
  120. package/sdk-core/sdk/Cargo.toml +32 -0
  121. package/sdk-core/{src/prototype_rust_sdk → sdk/src}/conversions.rs +0 -0
  122. package/sdk-core/sdk/src/lib.rs +699 -0
  123. package/sdk-core/sdk/src/payload_converter.rs +11 -0
  124. package/sdk-core/sdk/src/workflow_context/options.rs +180 -0
  125. package/sdk-core/{src/prototype_rust_sdk → sdk/src}/workflow_context.rs +201 -124
  126. package/sdk-core/{src/prototype_rust_sdk → sdk/src}/workflow_future.rs +63 -30
  127. package/sdk-core/sdk-core-protos/Cargo.toml +10 -0
  128. package/sdk-core/sdk-core-protos/build.rs +28 -6
  129. package/sdk-core/sdk-core-protos/src/constants.rs +7 -0
  130. package/sdk-core/{src/test_help → sdk-core-protos/src}/history_builder.rs +134 -49
  131. package/sdk-core/sdk-core-protos/src/history_info.rs +216 -0
  132. package/sdk-core/sdk-core-protos/src/lib.rs +601 -168
  133. package/sdk-core/sdk-core-protos/src/task_token.rs +38 -0
  134. package/sdk-core/sdk-core-protos/src/utilities.rs +14 -0
  135. package/sdk-core/test-utils/Cargo.toml +32 -0
  136. package/sdk-core/{src/test_help → test-utils/src}/canned_histories.rs +59 -78
  137. package/sdk-core/test-utils/src/histfetch.rs +28 -0
  138. package/sdk-core/{test_utils → test-utils}/src/lib.rs +131 -68
  139. package/sdk-core/tests/integ_tests/client_tests.rs +1 -1
  140. package/sdk-core/tests/integ_tests/heartbeat_tests.rs +11 -7
  141. package/sdk-core/tests/integ_tests/polling_tests.rs +12 -11
  142. package/sdk-core/tests/integ_tests/queries_tests.rs +82 -78
  143. package/sdk-core/tests/integ_tests/workflow_tests/activities.rs +91 -71
  144. package/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +3 -4
  145. package/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +2 -4
  146. package/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +4 -6
  147. package/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +4 -6
  148. package/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +3 -4
  149. package/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +496 -0
  150. package/sdk-core/tests/integ_tests/workflow_tests/patches.rs +5 -8
  151. package/sdk-core/tests/integ_tests/workflow_tests/replay.rs +125 -0
  152. package/sdk-core/tests/integ_tests/workflow_tests/signals.rs +7 -13
  153. package/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +33 -5
  154. package/sdk-core/tests/integ_tests/workflow_tests/timers.rs +12 -16
  155. package/sdk-core/tests/integ_tests/workflow_tests.rs +85 -82
  156. package/sdk-core/tests/load_tests.rs +6 -6
  157. package/sdk-core/tests/main.rs +2 -2
  158. package/src/conversions.rs +24 -21
  159. package/src/errors.rs +8 -0
  160. package/src/lib.rs +323 -211
  161. package/sdk-core/protos/local/activity_result.proto +0 -46
  162. package/sdk-core/protos/local/activity_task.proto +0 -66
  163. package/sdk-core/src/core_tests/retry.rs +0 -147
  164. package/sdk-core/src/lib.rs +0 -403
  165. package/sdk-core/src/machines/local_activity_state_machine.rs +0 -117
  166. package/sdk-core/src/pending_activations.rs +0 -249
  167. package/sdk-core/src/protosext/mod.rs +0 -160
  168. package/sdk-core/src/prototype_rust_sdk.rs +0 -412
  169. package/sdk-core/src/task_token.rs +0 -20
  170. package/sdk-core/src/test_help/history_info.rs +0 -157
@@ -0,0 +1,216 @@
1
+ #pragma once
2
+
3
+ #include <stdarg.h>
4
+ #include <stdbool.h>
5
+ #include <stdint.h>
6
+ #include <stdlib.h>
7
+
8
+ /**
9
+ * A core instance owned by Core. This must be passed to tmprl_core_shutdown
10
+ * when no longer in use which will free the resources.
11
+ */
12
+ typedef struct tmprl_core_t tmprl_core_t;
13
+
14
+ /**
15
+ * A runtime owned by Core. This must be passed to tmprl_runtime_free when no
16
+ * longer in use. This must not be freed until every call to every tmprl_core_t
17
+ * instance created with this runtime has been shutdown.
18
+ */
19
+ typedef struct tmprl_runtime_t tmprl_runtime_t;
20
+
21
+ /**
22
+ * A set of bytes owned by Core. No fields within nor any bytes references must
23
+ * ever be mutated outside of Core. This must always be passed to
24
+ * tmprl_bytes_free when no longer in use.
25
+ */
26
+ typedef struct tmprl_bytes_t {
27
+ const uint8_t *bytes;
28
+ size_t len;
29
+ /**
30
+ * For internal use only.
31
+ */
32
+ size_t cap;
33
+ /**
34
+ * For internal use only.
35
+ */
36
+ bool disable_free;
37
+ } tmprl_bytes_t;
38
+
39
+ /**
40
+ * Callback called by tmprl_core_init on completion. The first parameter of the
41
+ * callback is user data passed into the original function. The second
42
+ * parameter is a core instance if the call is successful or null if not. If
43
+ * present, the core instance must be freed via tmprl_core_shutdown when no
44
+ * longer in use. The third parameter of the callback is a byte array for a
45
+ * InitResponse protobuf message which must be freed via tmprl_bytes_free.
46
+ */
47
+ typedef void (*tmprl_core_init_callback)(void *user_data, struct tmprl_core_t *core, const struct tmprl_bytes_t *resp);
48
+
49
+ /**
50
+ * Callback called on function completion. The first parameter of the callback
51
+ * is user data passed into the original function. The second parameter of the
52
+ * callback is a never-null byte array for a response protobuf message which
53
+ * must be freed via tmprl_bytes_free.
54
+ */
55
+ typedef void (*tmprl_callback)(void *user_data, const struct tmprl_bytes_t *core);
56
+
57
+ /**
58
+ * Free a set of bytes. The first parameter can be null in cases where a
59
+ * tmprl_core_t instance isn't available. If the second parameter is null, this
60
+ * is a no-op.
61
+ */
62
+ void tmprl_bytes_free(struct tmprl_core_t *core, const struct tmprl_bytes_t *bytes);
63
+
64
+ /**
65
+ * Create a new runtime. The result is never null and must be freed via
66
+ * tmprl_runtime_free when no longer in use.
67
+ */
68
+ struct tmprl_runtime_t *tmprl_runtime_new(void);
69
+
70
+ /**
71
+ * Free a previously created runtime.
72
+ */
73
+ void tmprl_runtime_free(struct tmprl_runtime_t *runtime);
74
+
75
+ /**
76
+ * Create a new core instance.
77
+ *
78
+ * The runtime is required and must outlive this instance. The req_proto and
79
+ * req_proto_len represent a byte array for a InitRequest protobuf message. The
80
+ * callback is invoked on completion.
81
+ */
82
+ void tmprl_core_init(struct tmprl_runtime_t *runtime,
83
+ const uint8_t *req_proto,
84
+ size_t req_proto_len,
85
+ void *user_data,
86
+ tmprl_core_init_callback callback);
87
+
88
+ /**
89
+ * Shutdown and free a core instance.
90
+ *
91
+ * The req_proto and req_proto_len represent a byte array for a ShutdownRequest
92
+ * protobuf message. The callback is invoked on completion with a
93
+ * ShutdownResponse protobuf message.
94
+ */
95
+ void tmprl_core_shutdown(struct tmprl_core_t *core,
96
+ const uint8_t *req_proto,
97
+ size_t req_proto_len,
98
+ void *user_data,
99
+ tmprl_callback callback);
100
+
101
+ /**
102
+ * Register a worker.
103
+ *
104
+ * The req_proto and req_proto_len represent a byte array for a RegisterWorker
105
+ * protobuf message. The callback is invoked on completion with a
106
+ * RegisterWorkerResponse protobuf message.
107
+ */
108
+ void tmprl_register_worker(struct tmprl_core_t *core,
109
+ const uint8_t *req_proto,
110
+ size_t req_proto_len,
111
+ void *user_data,
112
+ tmprl_callback callback);
113
+
114
+ /**
115
+ * Shutdown registered worker.
116
+ *
117
+ * The req_proto and req_proto_len represent a byte array for a
118
+ * ShutdownWorkerRequest protobuf message. The callback is invoked on
119
+ * completion with a ShutdownWorkerResponse protobuf message.
120
+ */
121
+ void tmprl_shutdown_worker(struct tmprl_core_t *core,
122
+ const uint8_t *req_proto,
123
+ size_t req_proto_len,
124
+ void *user_data,
125
+ tmprl_callback callback);
126
+
127
+ /**
128
+ * Poll workflow activation.
129
+ *
130
+ * The req_proto and req_proto_len represent a byte array for a
131
+ * PollWorkflowActivationRequest protobuf message. The callback is invoked on
132
+ * completion with a PollWorkflowActivationResponse protobuf message.
133
+ */
134
+ void tmprl_poll_workflow_activation(struct tmprl_core_t *core,
135
+ const uint8_t *req_proto,
136
+ size_t req_proto_len,
137
+ void *user_data,
138
+ tmprl_callback callback);
139
+
140
+ /**
141
+ * Poll activity task.
142
+ *
143
+ * The req_proto and req_proto_len represent a byte array for a
144
+ * PollActivityTaskRequest protobuf message. The callback is invoked on
145
+ * completion with a PollActivityTaskResponse protobuf message.
146
+ */
147
+ void tmprl_poll_activity_task(struct tmprl_core_t *core,
148
+ const uint8_t *req_proto,
149
+ size_t req_proto_len,
150
+ void *user_data,
151
+ tmprl_callback callback);
152
+
153
+ /**
154
+ * Complete workflow activation.
155
+ *
156
+ * The req_proto and req_proto_len represent a byte array for a
157
+ * CompleteWorkflowActivationRequest protobuf message. The callback is invoked
158
+ * on completion with a CompleteWorkflowActivationResponse protobuf message.
159
+ */
160
+ void tmprl_complete_workflow_activation(struct tmprl_core_t *core,
161
+ const uint8_t *req_proto,
162
+ size_t req_proto_len,
163
+ void *user_data,
164
+ tmprl_callback callback);
165
+
166
+ /**
167
+ * Complete activity task.
168
+ *
169
+ * The req_proto and req_proto_len represent a byte array for a
170
+ * CompleteActivityTaskRequest protobuf message. The callback is invoked
171
+ * on completion with a CompleteActivityTaskResponse protobuf message.
172
+ */
173
+ void tmprl_complete_activity_task(struct tmprl_core_t *core,
174
+ const uint8_t *req_proto,
175
+ size_t req_proto_len,
176
+ void *user_data,
177
+ tmprl_callback callback);
178
+
179
+ /**
180
+ * Record activity heartbeat.
181
+ *
182
+ * The req_proto and req_proto_len represent a byte array for a
183
+ * RecordActivityHeartbeatRequest protobuf message. The callback is invoked
184
+ * on completion with a RecordActivityHeartbeatResponse protobuf message.
185
+ */
186
+ void tmprl_record_activity_heartbeat(struct tmprl_core_t *core,
187
+ const uint8_t *req_proto,
188
+ size_t req_proto_len,
189
+ void *user_data,
190
+ tmprl_callback callback);
191
+
192
+ /**
193
+ * Request workflow eviction.
194
+ *
195
+ * The req_proto and req_proto_len represent a byte array for a
196
+ * RequestWorkflowEvictionRequest protobuf message. The callback is invoked
197
+ * on completion with a RequestWorkflowEvictionResponse protobuf message.
198
+ */
199
+ void tmprl_request_workflow_eviction(struct tmprl_core_t *core,
200
+ const uint8_t *req_proto,
201
+ size_t req_proto_len,
202
+ void *user_data,
203
+ tmprl_callback callback);
204
+
205
+ /**
206
+ * Fetch buffered logs.
207
+ *
208
+ * The req_proto and req_proto_len represent a byte array for a
209
+ * FetchBufferedLogsRequest protobuf message. The callback is invoked
210
+ * on completion with a FetchBufferedLogsResponse protobuf message.
211
+ */
212
+ void tmprl_fetch_buffered_logs(struct tmprl_core_t *core,
213
+ const uint8_t *req_proto,
214
+ size_t req_proto_len,
215
+ void *user_data,
216
+ tmprl_callback callback);