-
Notifications
You must be signed in to change notification settings - Fork 142
Enable Worker heartbeating, plumb plugin names to core, update Core to 45b1d7e #1818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 11 commits
f824e24
0a9c2ff
ab66408
15f08a5
f5c1584
4ea1c1a
de87933
9dce77a
3dce033
afb9c9f
826a363
ebed34d
3eb05da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -166,6 +166,9 @@ pub fn worker_complete_workflow_activation( | |
| ), | ||
| } | ||
| } | ||
| CompleteWfError::WorkflowNotEnabled => { | ||
| BridgeError::UnexpectedError(err.to_string()) | ||
| } | ||
| }) | ||
| }) | ||
| } | ||
|
|
@@ -225,6 +228,9 @@ pub fn worker_complete_activity_task( | |
| field: None, | ||
| message: format!("Malformed Activity Completion: {reason:?}"), | ||
| }, | ||
| CompleteActivityError::ActivityNotEnabled => { | ||
| BridgeError::UnexpectedError(err.to_string()) | ||
| } | ||
| }) | ||
| }) | ||
| } | ||
|
|
@@ -296,7 +302,7 @@ pub fn worker_complete_nexus_task( | |
| .await | ||
| .map_err(|err| match err { | ||
| CompleteNexusError::NexusNotEnabled => { | ||
| BridgeError::UnexpectedError(format!("{err}")) | ||
| BridgeError::UnexpectedError(err.to_string()) | ||
| } | ||
| CompleteNexusError::MalformedNexusCompletion { reason } => BridgeError::TypeError { | ||
| field: None, | ||
|
|
@@ -466,6 +472,7 @@ mod config { | |
| use std::{sync::Arc, time::Duration}; | ||
|
|
||
| use temporalio_common::protos::temporal::api::enums::v1::VersioningBehavior as CoreVersioningBehavior; | ||
| use temporalio_common::protos::temporal::api::worker::v1::PluginInfo; | ||
| use temporalio_common::worker::{ | ||
| ActivitySlotKind, LocalActivitySlotKind, NexusSlotKind, | ||
| PollerBehavior as CorePollerBehavior, SlotKind, WorkerConfig, WorkerConfigBuilder, | ||
|
|
@@ -499,14 +506,15 @@ mod config { | |
| workflow_task_poller_behavior: PollerBehavior, | ||
| activity_task_poller_behavior: PollerBehavior, | ||
| nexus_task_poller_behavior: PollerBehavior, | ||
| enable_non_local_activities: bool, | ||
| task_types: WorkerTaskTypes, | ||
| sticky_queue_schedule_to_start_timeout: Duration, | ||
| max_cached_workflows: usize, | ||
| max_heartbeat_throttle_interval: Duration, | ||
| default_heartbeat_throttle_interval: Duration, | ||
| max_activities_per_second: Option<f64>, | ||
| max_task_queue_activities_per_second: Option<f64>, | ||
| shutdown_grace_time: Option<Duration>, | ||
| plugins: Vec<String>, | ||
| } | ||
|
|
||
| #[derive(TryFromJs)] | ||
|
|
@@ -540,6 +548,26 @@ mod config { | |
| AutoUpgrade, | ||
| } | ||
|
|
||
| #[derive(TryFromJs)] | ||
| #[allow(clippy::struct_excessive_bools)] | ||
| pub struct WorkerTaskTypes { | ||
| enable_workflows: bool, | ||
| enable_local_activities: bool, | ||
| enable_remote_activities: bool, | ||
| enable_nexus: bool, | ||
| } | ||
|
|
||
| impl From<&WorkerTaskTypes> for temporalio_common::worker::WorkerTaskTypes { | ||
| fn from(t: &WorkerTaskTypes) -> Self { | ||
| Self { | ||
| enable_workflows: t.enable_workflows, | ||
| enable_local_activities: t.enable_local_activities, | ||
| enable_remote_activities: t.enable_remote_activities, | ||
| enable_nexus: t.enable_nexus, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl BridgeWorkerOptions { | ||
| pub(crate) fn into_core_config(self) -> Result<WorkerConfig, WorkerConfigBuilderError> { | ||
| // Set all other options | ||
|
|
@@ -566,14 +594,23 @@ mod config { | |
| .workflow_task_poller_behavior(self.workflow_task_poller_behavior) | ||
| .activity_task_poller_behavior(self.activity_task_poller_behavior) | ||
| .nexus_task_poller_behavior(self.nexus_task_poller_behavior) | ||
| .no_remote_activities(!self.enable_non_local_activities) | ||
| .task_types(&self.task_types) | ||
| .sticky_queue_schedule_to_start_timeout(self.sticky_queue_schedule_to_start_timeout) | ||
| .max_cached_workflows(self.max_cached_workflows) | ||
| .max_heartbeat_throttle_interval(self.max_heartbeat_throttle_interval) | ||
| .default_heartbeat_throttle_interval(self.default_heartbeat_throttle_interval) | ||
| .max_task_queue_activities_per_second(self.max_task_queue_activities_per_second) | ||
| .max_worker_activities_per_second(self.max_activities_per_second) | ||
| .graceful_shutdown_period(self.shutdown_grace_time) | ||
| .plugins( | ||
| self.plugins | ||
| .into_iter() | ||
| .map(|name| PluginInfo { | ||
| name, | ||
| version: String::new(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for my own knowledge, is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question, I don't know. haha. The API was originally implemented with version, but not sure what the intent was. Will follow up on this. |
||
| }) | ||
| .collect::<Vec<_>>(), | ||
| ) | ||
| .build() | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1078,6 +1078,8 @@ function nexusServiceRegistryFromOptions(opts: WorkerOptions): nexus.ServiceRegi | |
| } | ||
|
|
||
| export function toNativeWorkerOptions(opts: CompiledWorkerOptionsWithBuildId): native.WorkerOptions { | ||
| const enableWorkflows = opts.workflowBundle !== undefined || opts.workflowsPath !== undefined; | ||
| const enableLocalActivities = enableWorkflows && opts.activities.size > 0; | ||
| return { | ||
| identity: opts.identity, | ||
| buildId: opts.buildId, // eslint-disable-line deprecation/deprecation | ||
|
|
@@ -1090,14 +1092,20 @@ export function toNativeWorkerOptions(opts: CompiledWorkerOptionsWithBuildId): n | |
| workflowTaskPollerBehavior: toNativeTaskPollerBehavior(opts.workflowTaskPollerBehavior), | ||
| activityTaskPollerBehavior: toNativeTaskPollerBehavior(opts.activityTaskPollerBehavior), | ||
| nexusTaskPollerBehavior: toNativeTaskPollerBehavior(opts.nexusTaskPollerBehavior), | ||
| enableNonLocalActivities: opts.enableNonLocalActivities, | ||
| taskTypes: { | ||
| enableWorkflows, | ||
| enableLocalActivities, | ||
| enableRemoteActivities: opts.enableNonLocalActivities && opts.activities.size > 0, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's basically saying: Which is incorrect. We don't need workflows to enable remote activities. I'm surprised tests passed with this.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that's right, you're referring to |
||
| enableNexus: opts.nexusServiceRegistry !== undefined, | ||
| }, | ||
| stickyQueueScheduleToStartTimeout: msToNumber(opts.stickyQueueScheduleToStartTimeout), | ||
| maxCachedWorkflows: opts.maxCachedWorkflows, | ||
| maxHeartbeatThrottleInterval: msToNumber(opts.maxHeartbeatThrottleInterval), | ||
| defaultHeartbeatThrottleInterval: msToNumber(opts.defaultHeartbeatThrottleInterval), | ||
| maxTaskQueueActivitiesPerSecond: opts.maxTaskQueueActivitiesPerSecond ?? null, | ||
| maxActivitiesPerSecond: opts.maxActivitiesPerSecond ?? null, | ||
| shutdownGraceTime: msToNumber(opts.shutdownGraceTime), | ||
| plugins: opts.plugins?.map((p) => p.name) ?? [], | ||
| }; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should consider deduping plugins if we don't already. Depending on plugin implementation, it may be very normal to configure multiple of the same plugin on the same worker (maybe each has different settings).
This should be done in every SDK IMO too if we don't already (could consider making that Vec a Set on the Core side).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, a set would ensure deduping. Created temporalio/sdk-core#1072