temporalio 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +175 -4
- data/bridge/Cargo.lock +44 -21
- data/bridge/Cargo.toml +1 -0
- data/bridge/sdk-core/Cargo.toml +1 -1
- data/bridge/sdk-core/README.md +1 -4
- data/bridge/sdk-core/client/Cargo.toml +1 -1
- data/bridge/sdk-core/client/src/lib.rs +12 -20
- data/bridge/sdk-core/client/src/raw.rs +9 -8
- data/bridge/sdk-core/client/src/retry.rs +100 -23
- data/bridge/sdk-core/core/Cargo.toml +7 -7
- data/bridge/sdk-core/core/benches/workflow_replay.rs +13 -10
- data/bridge/sdk-core/core/src/abstractions.rs +22 -22
- data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +146 -43
- data/bridge/sdk-core/core/src/core_tests/local_activities.rs +419 -9
- data/bridge/sdk-core/core/src/core_tests/queries.rs +247 -89
- data/bridge/sdk-core/core/src/core_tests/workers.rs +2 -2
- data/bridge/sdk-core/core/src/core_tests/workflow_cancels.rs +1 -1
- data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +47 -27
- data/bridge/sdk-core/core/src/lib.rs +139 -32
- data/bridge/sdk-core/core/src/protosext/mod.rs +1 -1
- data/bridge/sdk-core/core/src/replay/mod.rs +185 -41
- data/bridge/sdk-core/core/src/telemetry/log_export.rs +190 -0
- data/bridge/sdk-core/core/src/telemetry/metrics.rs +184 -139
- data/bridge/sdk-core/core/src/telemetry/mod.rs +310 -315
- data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +4 -3
- data/bridge/sdk-core/core/src/test_help/mod.rs +23 -9
- data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +12 -6
- data/bridge/sdk-core/core/src/worker/activities.rs +40 -23
- data/bridge/sdk-core/core/src/worker/client/mocks.rs +1 -1
- data/bridge/sdk-core/core/src/worker/client.rs +30 -4
- data/bridge/sdk-core/core/src/worker/mod.rs +23 -19
- data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +10 -19
- data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +99 -25
- data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +3 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +2 -6
- data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +24 -22
- data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +12 -38
- data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +178 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +8 -2
- data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +1 -5
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +1 -1
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +233 -217
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +1 -6
- data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +4 -4
- data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +13 -5
- data/bridge/sdk-core/core/src/worker/workflow/mod.rs +86 -29
- data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +2 -2
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +56 -11
- data/bridge/sdk-core/core-api/Cargo.toml +4 -3
- data/bridge/sdk-core/core-api/src/lib.rs +1 -43
- data/bridge/sdk-core/core-api/src/telemetry.rs +147 -0
- data/bridge/sdk-core/core-api/src/worker.rs +13 -0
- data/bridge/sdk-core/etc/deps.svg +115 -140
- data/bridge/sdk-core/etc/regen-depgraph.sh +5 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-23_history.bin +0 -0
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-85_history.bin +0 -0
- data/bridge/sdk-core/protos/api_upstream/buf.yaml +0 -3
- data/bridge/sdk-core/protos/api_upstream/build/go.mod +7 -0
- data/bridge/sdk-core/protos/api_upstream/build/go.sum +5 -0
- data/bridge/sdk-core/protos/api_upstream/{temporal/api/update/v1/message.proto → build/tools.go} +6 -23
- data/bridge/sdk-core/protos/api_upstream/go.mod +6 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +12 -9
- data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +20 -19
- data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +4 -4
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +5 -3
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +23 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/{cluster.proto → interaction_type.proto} +10 -11
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +2 -13
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +26 -19
- data/bridge/sdk-core/protos/api_upstream/temporal/api/interaction/v1/message.proto +87 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +21 -61
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +2 -21
- data/bridge/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +110 -31
- data/bridge/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +4 -4
- data/bridge/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +60 -16
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +17 -3
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +2 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +8 -1
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +2 -2
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +2 -2
- data/bridge/sdk-core/sdk/Cargo.toml +2 -2
- data/bridge/sdk-core/sdk/src/interceptors.rs +36 -3
- data/bridge/sdk-core/sdk/src/lib.rs +7 -5
- data/bridge/sdk-core/sdk/src/workflow_context.rs +13 -2
- data/bridge/sdk-core/sdk/src/workflow_future.rs +3 -7
- data/bridge/sdk-core/sdk-core-protos/Cargo.toml +1 -1
- data/bridge/sdk-core/sdk-core-protos/build.rs +0 -1
- data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +65 -18
- data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +22 -22
- data/bridge/sdk-core/sdk-core-protos/src/lib.rs +104 -44
- data/bridge/sdk-core/test-utils/Cargo.toml +2 -1
- data/bridge/sdk-core/test-utils/src/lib.rs +81 -29
- data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +5 -2
- data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +37 -0
- data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +0 -13
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +167 -13
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +53 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +106 -20
- data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +18 -8
- data/bridge/sdk-core/tests/main.rs +6 -4
- data/bridge/src/connection.rs +81 -62
- data/bridge/src/lib.rs +92 -33
- data/bridge/src/runtime.rs +9 -2
- data/bridge/src/worker.rs +53 -2
- data/lib/bridge.so +0 -0
- data/lib/gen/temporal/api/batch/v1/message_pb.rb +8 -6
- data/lib/gen/temporal/api/command/v1/message_pb.rb +17 -9
- data/lib/gen/temporal/api/common/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +2 -1
- data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +3 -1
- data/lib/gen/temporal/api/enums/v1/common_pb.rb +2 -1
- data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +3 -2
- data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +7 -1
- data/lib/gen/temporal/api/enums/v1/interaction_type_pb.rb +25 -0
- data/lib/gen/temporal/api/enums/v1/namespace_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/query_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/reset_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/schedule_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/task_queue_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/update_pb.rb +1 -6
- data/lib/gen/temporal/api/enums/v1/workflow_pb.rb +1 -1
- data/lib/gen/temporal/api/errordetails/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/failure/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/filter/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/history/v1/message_pb.rb +19 -18
- data/lib/gen/temporal/api/interaction/v1/message_pb.rb +49 -0
- data/lib/gen/temporal/api/namespace/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +11 -51
- data/lib/gen/temporal/api/operatorservice/v1/service_pb.rb +1 -1
- data/lib/gen/temporal/api/query/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/replication/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/schedule/v1/message_pb.rb +22 -1
- data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +2 -2
- data/lib/gen/temporal/api/version/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/workflow/v1/message_pb.rb +2 -1
- data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +27 -10
- data/lib/gen/temporal/api/workflowservice/v1/service_pb.rb +1 -1
- data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +1 -0
- data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +5 -1
- data/lib/temporalio/activity/context.rb +97 -0
- data/lib/temporalio/activity/info.rb +67 -0
- data/lib/temporalio/activity.rb +85 -0
- data/lib/temporalio/bridge/error.rb +8 -0
- data/lib/temporalio/bridge.rb +14 -0
- data/lib/{temporal → temporalio}/client/implementation.rb +49 -48
- data/lib/{temporal → temporalio}/client/workflow_handle.rb +35 -35
- data/lib/{temporal → temporalio}/client.rb +19 -32
- data/lib/{temporal → temporalio}/connection.rb +238 -223
- data/lib/{temporal → temporalio}/data_converter.rb +76 -35
- data/lib/{temporal → temporalio}/error/failure.rb +6 -6
- data/lib/{temporal → temporalio}/error/workflow_failure.rb +4 -2
- data/lib/{temporal → temporalio}/errors.rb +19 -1
- data/lib/{temporal → temporalio}/failure_converter/base.rb +5 -5
- data/lib/{temporal → temporalio}/failure_converter/basic.rb +58 -52
- data/lib/temporalio/failure_converter.rb +7 -0
- data/lib/{temporal → temporalio}/interceptor/chain.rb +2 -1
- data/lib/{temporal → temporalio}/interceptor/client.rb +22 -1
- data/lib/{temporal → temporalio}/payload_codec/base.rb +5 -5
- data/lib/{temporal → temporalio}/payload_converter/base.rb +3 -3
- data/lib/{temporal → temporalio}/payload_converter/bytes.rb +4 -3
- data/lib/{temporal → temporalio}/payload_converter/composite.rb +7 -5
- data/lib/{temporal → temporalio}/payload_converter/encoding_base.rb +4 -4
- data/lib/{temporal → temporalio}/payload_converter/json.rb +4 -3
- data/lib/{temporal → temporalio}/payload_converter/nil.rb +4 -3
- data/lib/temporalio/payload_converter.rb +14 -0
- data/lib/{temporal → temporalio}/retry_policy.rb +4 -4
- data/lib/{temporal → temporalio}/retry_state.rb +1 -1
- data/lib/temporalio/runtime.rb +25 -0
- data/lib/{temporal → temporalio}/timeout_type.rb +2 -2
- data/lib/temporalio/version.rb +3 -0
- data/lib/temporalio/worker/activity_runner.rb +92 -0
- data/lib/temporalio/worker/activity_worker.rb +138 -0
- data/lib/temporalio/worker/reactor.rb +46 -0
- data/lib/temporalio/worker/runner.rb +63 -0
- data/lib/temporalio/worker/sync_worker.rb +88 -0
- data/lib/temporalio/worker/thread_pool_executor.rb +51 -0
- data/lib/temporalio/worker.rb +198 -0
- data/lib/{temporal → temporalio}/workflow/execution_info.rb +4 -4
- data/lib/{temporal → temporalio}/workflow/execution_status.rb +1 -1
- data/lib/{temporal → temporalio}/workflow/id_reuse_policy.rb +6 -6
- data/lib/{temporal → temporalio}/workflow/query_reject_condition.rb +5 -5
- data/lib/temporalio.rb +12 -3
- data/temporalio.gemspec +7 -3
- metadata +79 -56
- data/bridge/sdk-core/bridge-ffi/Cargo.toml +0 -24
- data/bridge/sdk-core/bridge-ffi/LICENSE.txt +0 -23
- data/bridge/sdk-core/bridge-ffi/build.rs +0 -25
- data/bridge/sdk-core/bridge-ffi/include/sdk-core-bridge.h +0 -249
- data/bridge/sdk-core/bridge-ffi/src/lib.rs +0 -825
- data/bridge/sdk-core/bridge-ffi/src/wrappers.rs +0 -211
- data/bridge/sdk-core/core/src/log_export.rs +0 -62
- data/bridge/sdk-core/core/src/worker/workflow/machines/mutable_side_effect_state_machine.rs +0 -127
- data/bridge/sdk-core/core/src/worker/workflow/machines/side_effect_state_machine.rs +0 -71
- data/bridge/sdk-core/protos/api_upstream/temporal/api/cluster/v1/message.proto +0 -83
- data/bridge/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +0 -210
- data/bridge/sdk-core/sdk/src/conversions.rs +0 -8
- data/lib/gen/temporal/api/cluster/v1/message_pb.rb +0 -67
- data/lib/gen/temporal/api/enums/v1/cluster_pb.rb +0 -26
- data/lib/gen/temporal/api/update/v1/message_pb.rb +0 -26
- data/lib/temporal/bridge.rb +0 -14
- data/lib/temporal/failure_converter.rb +0 -8
- data/lib/temporal/payload_converter.rb +0 -14
- data/lib/temporal/runtime.rb +0 -22
- data/lib/temporal/version.rb +0 -3
- data/lib/temporal.rb +0 -8
@@ -1,4 +1,4 @@
|
|
1
|
-
use crate::telemetry::
|
1
|
+
use crate::telemetry::default_resource;
|
2
2
|
use hyper::{
|
3
3
|
header::CONTENT_TYPE,
|
4
4
|
service::{make_service_fn, service_fn},
|
@@ -7,7 +7,7 @@ use hyper::{
|
|
7
7
|
use opentelemetry::{
|
8
8
|
metrics::MetricsError,
|
9
9
|
sdk::{
|
10
|
-
export::metrics::aggregation::TemporalitySelector,
|
10
|
+
export::metrics::{aggregation::TemporalitySelector, AggregatorSelector},
|
11
11
|
metrics::{controllers, processors},
|
12
12
|
},
|
13
13
|
};
|
@@ -24,10 +24,11 @@ pub(super) struct PromServer {
|
|
24
24
|
impl PromServer {
|
25
25
|
pub fn new(
|
26
26
|
addr: SocketAddr,
|
27
|
+
aggregation: impl AggregatorSelector + Send + Sync + 'static,
|
27
28
|
temporality: impl TemporalitySelector + Send + Sync + 'static,
|
28
29
|
) -> Result<Self, MetricsError> {
|
29
30
|
let controller =
|
30
|
-
controllers::basic(processors::factory(
|
31
|
+
controllers::basic(processors::factory(aggregation, temporality).with_memory(true))
|
31
32
|
.with_resource(default_resource())
|
32
33
|
.build();
|
33
34
|
let exporter = ExporterBuilder::new(controller).try_init()?;
|
@@ -5,8 +5,11 @@ use crate::{
|
|
5
5
|
protosext::ValidPollWFTQResponse,
|
6
6
|
replay::TestHistoryBuilder,
|
7
7
|
sticky_q_name_for_worker,
|
8
|
+
telemetry::metrics::MetricsContext,
|
8
9
|
worker::{
|
9
|
-
client::{
|
10
|
+
client::{
|
11
|
+
mocks::mock_workflow_client, MockWorkerClient, WorkerClient, WorkflowTaskCompletion,
|
12
|
+
},
|
10
13
|
new_wft_poller,
|
11
14
|
},
|
12
15
|
TaskToken, Worker, WorkerConfig, WorkerConfigBuilder,
|
@@ -26,7 +29,6 @@ use std::{
|
|
26
29
|
task::{Context, Poll},
|
27
30
|
time::Duration,
|
28
31
|
};
|
29
|
-
use temporal_client::WorkflowTaskCompletion;
|
30
32
|
use temporal_sdk_core_api::Worker as WorkerTrait;
|
31
33
|
use temporal_sdk_core_protos::{
|
32
34
|
coresdk::{
|
@@ -57,6 +59,7 @@ pub fn test_worker_cfg() -> WorkerConfigBuilder {
|
|
57
59
|
wcb.namespace("default")
|
58
60
|
.task_queue(TEST_Q)
|
59
61
|
.worker_build_id("test_bin_id")
|
62
|
+
.ignore_evicts_on_shutdown(true)
|
60
63
|
// Serial polling since it makes mocking much easier.
|
61
64
|
.max_concurrent_wft_polls(1_usize);
|
62
65
|
wcb
|
@@ -133,13 +136,18 @@ pub(crate) fn build_fake_worker(
|
|
133
136
|
|
134
137
|
pub(crate) fn mock_worker(mocks: MocksHolder) -> Worker {
|
135
138
|
let sticky_q = sticky_q_name_for_worker("unit-test", &mocks.inputs.config);
|
139
|
+
let act_poller = if mocks.inputs.config.no_remote_activities {
|
140
|
+
None
|
141
|
+
} else {
|
142
|
+
mocks.inputs.act_poller
|
143
|
+
};
|
136
144
|
Worker::new_with_pollers(
|
137
145
|
mocks.inputs.config,
|
138
146
|
sticky_q,
|
139
147
|
mocks.client,
|
140
148
|
mocks.inputs.wft_stream,
|
141
|
-
|
142
|
-
|
149
|
+
act_poller,
|
150
|
+
MetricsContext::no_op(),
|
143
151
|
CancellationToken::new(),
|
144
152
|
)
|
145
153
|
}
|
@@ -209,7 +217,7 @@ impl MockWorkerInputs {
|
|
209
217
|
}
|
210
218
|
pub fn new_from_poller(wf_poller: BoxedWFPoller) -> Self {
|
211
219
|
Self {
|
212
|
-
wft_stream: new_wft_poller(wf_poller,
|
220
|
+
wft_stream: new_wft_poller(wf_poller, MetricsContext::no_op()).boxed(),
|
213
221
|
act_poller: None,
|
214
222
|
config: test_worker_cfg().build().unwrap(),
|
215
223
|
}
|
@@ -371,6 +379,7 @@ pub(crate) struct MockPollCfg {
|
|
371
379
|
/// early with no work, since we cannot know the exact number of times polling will happen.
|
372
380
|
/// Instead, they will just block forever.
|
373
381
|
pub using_rust_sdk: bool,
|
382
|
+
pub make_poll_stream_interminable: bool,
|
374
383
|
}
|
375
384
|
|
376
385
|
impl MockPollCfg {
|
@@ -388,6 +397,7 @@ impl MockPollCfg {
|
|
388
397
|
expect_fail_wft_matcher: Box::new(|_, _, _| true),
|
389
398
|
completion_asserts: None,
|
390
399
|
using_rust_sdk: false,
|
400
|
+
make_poll_stream_interminable: false,
|
391
401
|
}
|
392
402
|
}
|
393
403
|
pub fn from_resp_batches(
|
@@ -409,6 +419,7 @@ impl MockPollCfg {
|
|
409
419
|
expect_fail_wft_matcher: Box::new(|_, _, _| true),
|
410
420
|
completion_asserts: None,
|
411
421
|
using_rust_sdk: false,
|
422
|
+
make_poll_stream_interminable: false,
|
412
423
|
}
|
413
424
|
}
|
414
425
|
}
|
@@ -498,7 +509,7 @@ pub(crate) fn build_mock_pollers(mut cfg: MockPollCfg) -> MocksHolder {
|
|
498
509
|
.into_iter()
|
499
510
|
.map(|response| {
|
500
511
|
let cur_attempt = attempts_at_task_num.entry(response.hashable()).or_insert(1);
|
501
|
-
let mut r = hist_to_poll_resp(&hist.hist, hist.wf_id.clone(), response
|
512
|
+
let mut r = hist_to_poll_resp(&hist.hist, hist.wf_id.clone(), response);
|
502
513
|
r.attempt = *cur_attempt;
|
503
514
|
*cur_attempt += 1;
|
504
515
|
r
|
@@ -604,11 +615,15 @@ pub(crate) fn build_mock_pollers(mut cfg: MockPollCfg) -> MocksHolder {
|
|
604
615
|
Ok(Default::default())
|
605
616
|
});
|
606
617
|
|
607
|
-
MocksHolder {
|
618
|
+
let mut mh = MocksHolder {
|
608
619
|
client: Arc::new(cfg.mock_client),
|
609
620
|
inputs: mock_worker,
|
610
621
|
outstanding_task_map: Some(outstanding_wf_task_tokens),
|
622
|
+
};
|
623
|
+
if cfg.make_poll_stream_interminable {
|
624
|
+
mh.make_wft_stream_interminable();
|
611
625
|
}
|
626
|
+
mh
|
612
627
|
}
|
613
628
|
|
614
629
|
pub struct QueueResponse<T> {
|
@@ -649,7 +664,6 @@ pub fn hist_to_poll_resp(
|
|
649
664
|
t: &TestHistoryBuilder,
|
650
665
|
wf_id: impl Into<String>,
|
651
666
|
response_type: ResponseType,
|
652
|
-
task_queue: impl Into<String>,
|
653
667
|
) -> QueueResponse<PollWorkflowTaskQueueResponse> {
|
654
668
|
let run_id = t.get_orig_run_id();
|
655
669
|
let wf = WorkflowExecution {
|
@@ -678,7 +692,7 @@ pub fn hist_to_poll_resp(
|
|
678
692
|
}
|
679
693
|
}
|
680
694
|
};
|
681
|
-
let mut resp = hist_info.as_poll_wft_response(
|
695
|
+
let mut resp = hist_info.as_poll_wft_response();
|
682
696
|
resp.workflow_execution = Some(wf);
|
683
697
|
QueueResponse { resp, delay_until }
|
684
698
|
}
|
@@ -179,7 +179,7 @@ impl LocalActivityManager {
|
|
179
179
|
Self::new(
|
180
180
|
max_concurrent,
|
181
181
|
"fake_ns".to_string(),
|
182
|
-
MetricsContext::
|
182
|
+
MetricsContext::no_op(),
|
183
183
|
)
|
184
184
|
}
|
185
185
|
|
@@ -323,11 +323,12 @@ impl LocalActivityManager {
|
|
323
323
|
}
|
324
324
|
NewOrRetry::Retry { in_flight, attempt } => (in_flight, attempt),
|
325
325
|
};
|
326
|
-
let
|
326
|
+
let la_info_for_in_flight_map = new_la.clone();
|
327
327
|
let id = ExecutingLAId {
|
328
328
|
run_id: new_la.workflow_exec_info.run_id.clone(),
|
329
329
|
seq_num: new_la.schedule_cmd.seq,
|
330
330
|
};
|
331
|
+
let orig_sched_time = new_la.schedule_cmd.original_schedule_time;
|
331
332
|
let sa = new_la.schedule_cmd;
|
332
333
|
|
333
334
|
let mut dat = self.dat.lock();
|
@@ -348,7 +349,7 @@ impl LocalActivityManager {
|
|
348
349
|
runtime: sat_for,
|
349
350
|
attempt,
|
350
351
|
backoff: None,
|
351
|
-
original_schedule_time:
|
352
|
+
original_schedule_time: orig_sched_time,
|
352
353
|
},
|
353
354
|
task: None,
|
354
355
|
});
|
@@ -363,7 +364,7 @@ impl LocalActivityManager {
|
|
363
364
|
dat.outstanding_activity_tasks.insert(
|
364
365
|
tt.clone(),
|
365
366
|
LocalInFlightActInfo {
|
366
|
-
la_info:
|
367
|
+
la_info: la_info_for_in_flight_map,
|
367
368
|
dispatch_time: Instant::now(),
|
368
369
|
attempt,
|
369
370
|
_permit: permit,
|
@@ -515,6 +516,7 @@ enum CancelOrTimeout {
|
|
515
516
|
},
|
516
517
|
}
|
517
518
|
|
519
|
+
#[allow(clippy::large_enum_variant)]
|
518
520
|
enum NewOrCancel {
|
519
521
|
New(NewOrRetry, OwnedMeteredSemPermit),
|
520
522
|
Cancel(CancelOrTimeout),
|
@@ -566,17 +568,21 @@ impl TimeoutBag {
|
|
566
568
|
let (schedule_to_close, start_to_close) =
|
567
569
|
new_la.schedule_cmd.close_timeouts.into_sched_and_start();
|
568
570
|
|
571
|
+
let sched_time = new_la
|
572
|
+
.schedule_cmd
|
573
|
+
.original_schedule_time
|
574
|
+
.unwrap_or(new_la.schedule_time);
|
569
575
|
let resolution = LocalActivityResolution {
|
570
576
|
seq: new_la.schedule_cmd.seq,
|
571
577
|
result: LocalActivityExecutionResult::timeout(TimeoutType::ScheduleToClose),
|
572
578
|
runtime: Default::default(),
|
573
579
|
attempt: new_la.schedule_cmd.attempt,
|
574
580
|
backoff: None,
|
575
|
-
original_schedule_time:
|
581
|
+
original_schedule_time: new_la.schedule_cmd.original_schedule_time,
|
576
582
|
};
|
577
583
|
// Remove any time already elapsed since the scheduling time
|
578
584
|
let schedule_to_close = schedule_to_close
|
579
|
-
.map(|s2c| s2c.saturating_sub(
|
585
|
+
.map(|s2c| s2c.saturating_sub(sched_time.elapsed().unwrap_or_default()));
|
580
586
|
if let Some(ref s2c) = schedule_to_close {
|
581
587
|
if s2c.is_zero() {
|
582
588
|
return Err(resolution);
|
@@ -7,6 +7,7 @@ pub(crate) use local_activities::{
|
|
7
7
|
LocalInFlightActInfo, NewLocalAct,
|
8
8
|
};
|
9
9
|
|
10
|
+
use crate::telemetry::metrics::eager;
|
10
11
|
use crate::{
|
11
12
|
abstractions::{MeteredSemaphore, OwnedMeteredSemPermit},
|
12
13
|
pollers::BoxedActPoller,
|
@@ -41,6 +42,7 @@ use temporal_sdk_core_protos::{
|
|
41
42
|
},
|
42
43
|
};
|
43
44
|
use tokio::sync::Notify;
|
45
|
+
use tracing::Span;
|
44
46
|
|
45
47
|
#[derive(Debug, derive_more::Constructor)]
|
46
48
|
struct PendingActivityCancel {
|
@@ -48,11 +50,15 @@ struct PendingActivityCancel {
|
|
48
50
|
reason: ActivityCancelReason,
|
49
51
|
}
|
50
52
|
|
51
|
-
/// Contains
|
53
|
+
/// Contains details that core wants to store while an activity is running.
|
52
54
|
#[derive(Debug)]
|
53
55
|
struct InFlightActInfo {
|
54
56
|
pub activity_type: String,
|
55
57
|
pub workflow_type: String,
|
58
|
+
/// Only kept for logging reasons
|
59
|
+
pub workflow_id: String,
|
60
|
+
/// Only kept for logging reasons
|
61
|
+
pub workflow_run_id: String,
|
56
62
|
start_time: Instant,
|
57
63
|
}
|
58
64
|
|
@@ -71,19 +77,17 @@ struct RemoteInFlightActInfo {
|
|
71
77
|
_permit: OwnedMeteredSemPermit,
|
72
78
|
}
|
73
79
|
impl RemoteInFlightActInfo {
|
74
|
-
fn new(
|
75
|
-
|
76
|
-
workflow_type: String,
|
77
|
-
heartbeat_timeout: Option<prost_types::Duration>,
|
78
|
-
permit: OwnedMeteredSemPermit,
|
79
|
-
) -> Self {
|
80
|
+
fn new(poll_resp: &PollActivityTaskQueueResponse, permit: OwnedMeteredSemPermit) -> Self {
|
81
|
+
let wec = poll_resp.workflow_execution.clone().unwrap_or_default();
|
80
82
|
Self {
|
81
83
|
base: InFlightActInfo {
|
82
|
-
activity_type,
|
83
|
-
workflow_type,
|
84
|
+
activity_type: poll_resp.activity_type.clone().unwrap_or_default().name,
|
85
|
+
workflow_type: poll_resp.workflow_type.clone().unwrap_or_default().name,
|
86
|
+
workflow_id: wec.workflow_id,
|
87
|
+
workflow_run_id: wec.run_id,
|
84
88
|
start_time: Instant::now(),
|
85
89
|
},
|
86
|
-
heartbeat_timeout,
|
90
|
+
heartbeat_timeout: poll_resp.heartbeat_timeout.clone(),
|
87
91
|
issued_cancel_to_lang: false,
|
88
92
|
known_not_found: false,
|
89
93
|
_permit: permit,
|
@@ -202,7 +206,7 @@ impl WorkerActivityTasks {
|
|
202
206
|
cancel_task
|
203
207
|
}
|
204
208
|
task = self.non_poll_tasks.next() => {
|
205
|
-
Ok(Some(self.about_to_issue_task(task)))
|
209
|
+
Ok(Some(self.about_to_issue_task(task, true)))
|
206
210
|
}
|
207
211
|
(work, permit) = poll_with_semaphore => {
|
208
212
|
match work {
|
@@ -214,7 +218,7 @@ impl WorkerActivityTasks {
|
|
214
218
|
}
|
215
219
|
let work = self.about_to_issue_task(PermittedTqResp {
|
216
220
|
resp: work, permit
|
217
|
-
});
|
221
|
+
}, false);
|
218
222
|
Ok(Some(work))
|
219
223
|
}
|
220
224
|
None => {
|
@@ -234,12 +238,14 @@ impl WorkerActivityTasks {
|
|
234
238
|
) {
|
235
239
|
if let Some((_, act_info)) = self.outstanding_activity_tasks.remove(&task_token) {
|
236
240
|
let act_metrics = self.metrics.with_new_attrs([
|
237
|
-
activity_type(act_info.base.activity_type
|
238
|
-
workflow_type(act_info.base.workflow_type
|
241
|
+
activity_type(act_info.base.activity_type),
|
242
|
+
workflow_type(act_info.base.workflow_type),
|
239
243
|
]);
|
244
|
+
Span::current().record("workflow_id", act_info.base.workflow_id);
|
245
|
+
Span::current().record("run_id", act_info.base.workflow_run_id);
|
240
246
|
act_metrics.act_execution_latency(act_info.base.start_time.elapsed());
|
241
247
|
let known_not_found = act_info.known_not_found;
|
242
|
-
|
248
|
+
|
243
249
|
self.heartbeat_manager.evict(task_token.clone()).await;
|
244
250
|
self.complete_notify.notify_waiters();
|
245
251
|
|
@@ -369,19 +375,28 @@ impl WorkerActivityTasks {
|
|
369
375
|
}
|
370
376
|
|
371
377
|
/// Called when there is a new act task about to be bubbled up out of the manager
|
372
|
-
fn about_to_issue_task(&self, task: PermittedTqResp) -> ActivityTask {
|
378
|
+
fn about_to_issue_task(&self, task: PermittedTqResp, is_eager: bool) -> ActivityTask {
|
379
|
+
if let Some(ref act_type) = task.resp.activity_type {
|
380
|
+
if let Some(ref wf_type) = task.resp.workflow_type {
|
381
|
+
self.metrics
|
382
|
+
.with_new_attrs([
|
383
|
+
activity_type(act_type.name.clone()),
|
384
|
+
workflow_type(wf_type.name.clone()),
|
385
|
+
eager(is_eager),
|
386
|
+
])
|
387
|
+
.act_task_received();
|
388
|
+
}
|
389
|
+
}
|
390
|
+
// There could be an else statement here but since the response should always contain both
|
391
|
+
// activity_type and workflow_type, we won't bother.
|
392
|
+
|
373
393
|
if let Some(dur) = task.resp.sched_to_start() {
|
374
394
|
self.metrics.act_sched_to_start_latency(dur);
|
375
395
|
};
|
376
396
|
|
377
397
|
self.outstanding_activity_tasks.insert(
|
378
398
|
task.resp.task_token.clone().into(),
|
379
|
-
RemoteInFlightActInfo::new(
|
380
|
-
task.resp.activity_type.clone().unwrap_or_default().name,
|
381
|
-
task.resp.workflow_type.clone().unwrap_or_default().name,
|
382
|
-
task.resp.heartbeat_timeout.clone(),
|
383
|
-
task.permit,
|
384
|
-
),
|
399
|
+
RemoteInFlightActInfo::new(&task.resp, task.permit),
|
385
400
|
);
|
386
401
|
|
387
402
|
ActivityTask::start_from_poll_resp(task.resp)
|
@@ -411,6 +426,8 @@ impl ActivitiesFromWFTsHandle {
|
|
411
426
|
/// from WFT completion)
|
412
427
|
pub(crate) fn add_tasks(&self, tasks: impl IntoIterator<Item = PermittedTqResp>) {
|
413
428
|
for t in tasks.into_iter() {
|
429
|
+
// Technically we should be reporting `activity_task_received` here, but for simplicity
|
430
|
+
// and time insensitivity, that metric is tracked in `about_to_issue_task`.
|
414
431
|
self.tx.try_send(t).expect("Receive half cannot be dropped");
|
415
432
|
}
|
416
433
|
}
|
@@ -449,7 +466,7 @@ mod tests {
|
|
449
466
|
Some(2.0),
|
450
467
|
poller,
|
451
468
|
Arc::new(mock_manual_workflow_client()),
|
452
|
-
MetricsContext::
|
469
|
+
MetricsContext::no_op(),
|
453
470
|
Duration::from_secs(1),
|
454
471
|
Duration::from_secs(1),
|
455
472
|
);
|
@@ -16,7 +16,7 @@ pub(crate) fn mock_manual_workflow_client() -> MockManualWorkerClient {
|
|
16
16
|
// results. This is really annoying b/c of the async trait stuff. Need
|
17
17
|
// https://github.com/asomers/mockall/issues/189 to be fixed for it to go away.
|
18
18
|
mockall::mock! {
|
19
|
-
pub ManualWorkerClient {}
|
19
|
+
pub(crate) ManualWorkerClient {}
|
20
20
|
#[allow(unused)]
|
21
21
|
impl WorkerClient for ManualWorkerClient {
|
22
22
|
fn poll_workflow_task<'a, 'b>(&'a self, task_queue: String, is_sticky: bool)
|
@@ -2,15 +2,16 @@
|
|
2
2
|
|
3
3
|
pub(crate) mod mocks;
|
4
4
|
|
5
|
-
use temporal_client::{Client, RetryClient, WorkflowService
|
5
|
+
use temporal_client::{Client, RetryClient, WorkflowService};
|
6
6
|
use temporal_sdk_core_protos::{
|
7
7
|
coresdk::workflow_commands::QueryResult,
|
8
8
|
temporal::api::{
|
9
|
+
command::v1::Command,
|
9
10
|
common::v1::{Payloads, WorkflowExecution},
|
10
11
|
enums::v1::{TaskQueueKind, WorkflowTaskFailedCause},
|
11
12
|
failure::v1::Failure,
|
12
13
|
query::v1::WorkflowQueryResult,
|
13
|
-
taskqueue::v1::{TaskQueue, TaskQueueMetadata},
|
14
|
+
taskqueue::v1::{StickyExecutionAttributes, TaskQueue, TaskQueueMetadata, VersionId},
|
14
15
|
workflowservice::v1::*,
|
15
16
|
},
|
16
17
|
TaskToken,
|
@@ -133,7 +134,9 @@ impl WorkerClient for WorkerClientBag {
|
|
133
134
|
} else {
|
134
135
|
self.worker_build_id.clone()
|
135
136
|
},
|
136
|
-
|
137
|
+
worker_versioning_id: Some(VersionId {
|
138
|
+
worker_build_id: self.versioning_build_id(),
|
139
|
+
}),
|
137
140
|
};
|
138
141
|
|
139
142
|
Ok(self
|
@@ -159,7 +162,9 @@ impl WorkerClient for WorkerClientBag {
|
|
159
162
|
task_queue_metadata: max_tasks_per_sec.map(|tps| TaskQueueMetadata {
|
160
163
|
max_tasks_per_second: Some(tps),
|
161
164
|
}),
|
162
|
-
|
165
|
+
worker_versioning_id: Some(VersionId {
|
166
|
+
worker_build_id: self.versioning_build_id(),
|
167
|
+
}),
|
163
168
|
};
|
164
169
|
|
165
170
|
Ok(self
|
@@ -181,6 +186,9 @@ impl WorkerClient for WorkerClientBag {
|
|
181
186
|
sticky_attributes: request.sticky_attributes,
|
182
187
|
return_new_workflow_task: request.return_new_workflow_task,
|
183
188
|
force_create_new_workflow_task: request.force_create_new_workflow_task,
|
189
|
+
worker_versioning_id: Some(VersionId {
|
190
|
+
worker_build_id: self.versioning_build_id(),
|
191
|
+
}),
|
184
192
|
binary_checksum: self.worker_build_id.clone(),
|
185
193
|
query_results: request
|
186
194
|
.query_responses
|
@@ -345,3 +353,21 @@ impl WorkerClient for WorkerClientBag {
|
|
345
353
|
.into_inner())
|
346
354
|
}
|
347
355
|
}
|
356
|
+
|
357
|
+
/// A version of [RespondWorkflowTaskCompletedRequest] that will finish being filled out by the
|
358
|
+
/// server client
|
359
|
+
#[derive(Debug, Clone, PartialEq)]
|
360
|
+
pub(crate) struct WorkflowTaskCompletion {
|
361
|
+
/// The task token that would've been received from polling for a workflow activation
|
362
|
+
pub task_token: TaskToken,
|
363
|
+
/// A list of new commands to send to the server, such as starting a timer.
|
364
|
+
pub commands: Vec<Command>,
|
365
|
+
/// If set, indicate that next task should be queued on sticky queue with given attributes.
|
366
|
+
pub sticky_attributes: Option<StickyExecutionAttributes>,
|
367
|
+
/// Responses to queries in the `queries` field of the workflow task.
|
368
|
+
pub query_responses: Vec<QueryResult>,
|
369
|
+
/// Indicate that the task completion should return a new WFT if one is available
|
370
|
+
pub return_new_workflow_task: bool,
|
371
|
+
/// Force a new WFT to be created after this completion
|
372
|
+
pub force_create_new_workflow_task: bool,
|
373
|
+
}
|
@@ -74,7 +74,7 @@ impl WorkerTrait for Worker {
|
|
74
74
|
self.next_workflow_activation().await
|
75
75
|
}
|
76
76
|
|
77
|
-
#[instrument(
|
77
|
+
#[instrument(skip(self))]
|
78
78
|
async fn poll_activity_task(&self) -> Result<ActivityTask, PollActivityError> {
|
79
79
|
loop {
|
80
80
|
match self.activity_poll().await.transpose() {
|
@@ -94,7 +94,6 @@ impl WorkerTrait for Worker {
|
|
94
94
|
self.complete_workflow_activation(completion).await
|
95
95
|
}
|
96
96
|
|
97
|
-
#[instrument(level = "debug", skip(self, completion), fields(completion=%&completion))]
|
98
97
|
async fn complete_activity_task(
|
99
98
|
&self,
|
100
99
|
completion: ActivityTaskCompletion,
|
@@ -135,7 +134,11 @@ impl WorkerTrait for Worker {
|
|
135
134
|
if let Some(atm) = self.at_task_mgr.as_ref() {
|
136
135
|
atm.notify_shutdown();
|
137
136
|
}
|
138
|
-
info!(
|
137
|
+
info!(
|
138
|
+
task_queue=%self.config.task_queue,
|
139
|
+
namespace=%self.config.namespace,
|
140
|
+
"Initiated shutdown",
|
141
|
+
);
|
139
142
|
}
|
140
143
|
|
141
144
|
async fn shutdown(&self) {
|
@@ -155,7 +158,9 @@ impl Worker {
|
|
155
158
|
client: Arc<dyn WorkerClient>,
|
156
159
|
metrics: MetricsContext,
|
157
160
|
) -> Self {
|
158
|
-
info!(task_queue
|
161
|
+
info!(task_queue=%config.task_queue,
|
162
|
+
namespace=%config.namespace,
|
163
|
+
"Initializing worker");
|
159
164
|
metrics.worker_registered();
|
160
165
|
|
161
166
|
let shutdown_token = CancellationToken::new();
|
@@ -224,7 +229,7 @@ impl Worker {
|
|
224
229
|
|
225
230
|
#[cfg(test)]
|
226
231
|
pub(crate) fn new_test(config: WorkerConfig, client: impl WorkerClient + 'static) -> Self {
|
227
|
-
Self::new(config, None, Arc::new(client),
|
232
|
+
Self::new(config, None, Arc::new(client), MetricsContext::no_op())
|
228
233
|
}
|
229
234
|
|
230
235
|
pub(crate) fn new_with_pollers(
|
@@ -264,6 +269,7 @@ impl Worker {
|
|
264
269
|
metrics,
|
265
270
|
namespace: config.namespace.clone(),
|
266
271
|
task_queue: config.task_queue.clone(),
|
272
|
+
ignore_evicts_on_shutdown: config.ignore_evicts_on_shutdown,
|
267
273
|
},
|
268
274
|
sticky_queue_name.map(|sq| StickyExecutionAttributes {
|
269
275
|
worker_task_queue: Some(TaskQueue {
|
@@ -317,6 +323,10 @@ impl Worker {
|
|
317
323
|
}
|
318
324
|
}
|
319
325
|
|
326
|
+
pub(crate) fn shutdown_token(&self) -> CancellationToken {
|
327
|
+
self.shutdown_token.clone()
|
328
|
+
}
|
329
|
+
|
320
330
|
/// Returns number of currently cached workflows
|
321
331
|
pub async fn cached_workflows(&self) -> usize {
|
322
332
|
self.workflows
|
@@ -394,6 +404,9 @@ impl Worker {
|
|
394
404
|
}
|
395
405
|
}
|
396
406
|
|
407
|
+
#[instrument(skip(self, task_token, status),
|
408
|
+
fields(task_token=%&task_token, status=%&status,
|
409
|
+
task_queue=%self.config.task_queue, workflow_id, run_id))]
|
397
410
|
pub(crate) async fn complete_activity(
|
398
411
|
&self,
|
399
412
|
task_token: TaskToken,
|
@@ -433,13 +446,14 @@ impl Worker {
|
|
433
446
|
Ok(())
|
434
447
|
}
|
435
448
|
|
436
|
-
#[instrument(
|
449
|
+
#[instrument(skip(self), fields(run_id, workflow_id, task_queue=%self.config.task_queue))]
|
437
450
|
pub(crate) async fn next_workflow_activation(&self) -> Result<WorkflowActivation, PollWfError> {
|
438
451
|
self.workflows.next_workflow_activation().await
|
439
452
|
}
|
440
453
|
|
441
|
-
#[instrument(
|
442
|
-
|
454
|
+
#[instrument(skip(self, completion),
|
455
|
+
fields(completion=%&completion, run_id=%completion.run_id, workflow_id,
|
456
|
+
task_queue=%self.config.task_queue))]
|
443
457
|
pub(crate) async fn complete_workflow_activation(
|
444
458
|
&self,
|
445
459
|
completion: WorkflowActivationCompletion,
|
@@ -470,16 +484,6 @@ impl Worker {
|
|
470
484
|
self.post_activate_hook = Some(Box::new(callback))
|
471
485
|
}
|
472
486
|
|
473
|
-
/// Used for replay workers - causes the worker to shutdown when the given run reaches the
|
474
|
-
/// given event number
|
475
|
-
pub(crate) fn set_shutdown_on_run_reaches_event(&mut self, run_id: String, last_event: i64) {
|
476
|
-
self.set_post_activate_hook(move |worker, activated_run_id, last_processed_event| {
|
477
|
-
if activated_run_id == run_id && last_processed_event >= last_event as usize {
|
478
|
-
worker.initiate_shutdown();
|
479
|
-
}
|
480
|
-
});
|
481
|
-
}
|
482
|
-
|
483
487
|
fn complete_local_act(
|
484
488
|
&self,
|
485
489
|
la_res: LocalActivityExecutionResult,
|
@@ -494,7 +498,7 @@ impl Worker {
|
|
494
498
|
runtime: info.dispatch_time.elapsed(),
|
495
499
|
attempt: info.attempt,
|
496
500
|
backoff,
|
497
|
-
original_schedule_time:
|
501
|
+
original_schedule_time: info.la_info.schedule_cmd.original_schedule_time,
|
498
502
|
}),
|
499
503
|
)
|
500
504
|
}
|
@@ -1,9 +1,7 @@
|
|
1
|
-
use crate::worker::workflow::{WFCommand, WorkflowStartedInfo};
|
1
|
+
use crate::worker::workflow::{OutgoingJob, WFCommand, WorkflowStartedInfo};
|
2
|
+
use prost_types::Timestamp;
|
2
3
|
use temporal_sdk_core_protos::{
|
3
|
-
coresdk::workflow_activation::{
|
4
|
-
start_workflow_from_attribs, workflow_activation_job, CancelWorkflow, SignalWorkflow,
|
5
|
-
WorkflowActivationJob,
|
6
|
-
},
|
4
|
+
coresdk::workflow_activation::{start_workflow_from_attribs, WorkflowActivationJob},
|
7
5
|
temporal::api::history::v1::WorkflowExecutionStartedEventAttributes,
|
8
6
|
utilities::TryIntoOrNone,
|
9
7
|
};
|
@@ -14,7 +12,7 @@ pub struct DrivenWorkflow {
|
|
14
12
|
started_attrs: Option<WorkflowStartedInfo>,
|
15
13
|
fetcher: Box<dyn WorkflowFetcher>,
|
16
14
|
/// Outgoing activation jobs that need to be sent to the lang sdk
|
17
|
-
outgoing_wf_activation_jobs: Vec<
|
15
|
+
outgoing_wf_activation_jobs: Vec<OutgoingJob>,
|
18
16
|
}
|
19
17
|
|
20
18
|
impl<WF> From<Box<WF>> for DrivenWorkflow
|
@@ -36,6 +34,7 @@ impl DrivenWorkflow {
|
|
36
34
|
&mut self,
|
37
35
|
workflow_id: String,
|
38
36
|
randomness_seed: u64,
|
37
|
+
start_time: Timestamp,
|
39
38
|
attribs: WorkflowExecutionStartedEventAttributes,
|
40
39
|
) {
|
41
40
|
debug!(run_id = %attribs.original_execution_run_id, "Driven WF start");
|
@@ -49,7 +48,9 @@ impl DrivenWorkflow {
|
|
49
48
|
search_attrs: attribs.search_attributes.clone(),
|
50
49
|
retry_policy: attribs.retry_policy.clone(),
|
51
50
|
};
|
52
|
-
self.send_job(
|
51
|
+
self.send_job(
|
52
|
+
start_workflow_from_attribs(attribs, workflow_id, randomness_seed, start_time).into(),
|
53
|
+
);
|
53
54
|
self.started_attrs = Some(started_info);
|
54
55
|
}
|
55
56
|
|
@@ -59,12 +60,12 @@ impl DrivenWorkflow {
|
|
59
60
|
}
|
60
61
|
|
61
62
|
/// Enqueue a new job to be sent to the driven workflow
|
62
|
-
pub fn send_job(&mut self, job:
|
63
|
+
pub(super) fn send_job(&mut self, job: OutgoingJob) {
|
63
64
|
self.outgoing_wf_activation_jobs.push(job);
|
64
65
|
}
|
65
66
|
|
66
67
|
/// Observe pending jobs
|
67
|
-
pub fn peek_pending_jobs(&self) -> &[
|
68
|
+
pub(super) fn peek_pending_jobs(&self) -> &[OutgoingJob] {
|
68
69
|
self.outgoing_wf_activation_jobs.as_slice()
|
69
70
|
}
|
70
71
|
|
@@ -75,16 +76,6 @@ impl DrivenWorkflow {
|
|
75
76
|
.map(Into::into)
|
76
77
|
.collect()
|
77
78
|
}
|
78
|
-
|
79
|
-
/// Signal the workflow
|
80
|
-
pub fn signal(&mut self, signal: SignalWorkflow) {
|
81
|
-
self.send_job(workflow_activation_job::Variant::SignalWorkflow(signal));
|
82
|
-
}
|
83
|
-
|
84
|
-
/// Cancel the workflow
|
85
|
-
pub fn cancel(&mut self, attribs: CancelWorkflow) {
|
86
|
-
self.send_job(workflow_activation_job::Variant::CancelWorkflow(attribs));
|
87
|
-
}
|
88
79
|
}
|
89
80
|
|
90
81
|
#[async_trait::async_trait]
|