This repository was archived by the owner on Jan 27, 2026. It is now read-only.
refactor: refactor NodeStatusUpdater::process_nodes to run concurrently#585
Merged
Conversation
…or trait objects to use enums instead
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the node status updater to process nodes concurrently and replaces several trait-object–based plugin APIs with enum-based dispatch and standalone functions, enabling safe Send + 'static usage across tokio tasks.
- Run
NodeStatusUpdater::process_nodesin parallel viaFuturesUnordered - Replace
Box<dyn …Plugin>trait objects withStatusUpdatePluginandSchedulerPluginenums - Extract many plugin methods into standalone functions and update observer registration
Reviewed Changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/orchestrator/src/store/domains/task_store.rs | Changed task observers to NodeGroupsPlugin and removed trait |
| crates/orchestrator/src/status_update/mod.rs | Rewrote process_nodes to spawn and collect futures concurrently |
| crates/orchestrator/src/scheduler/mod.rs | Switched scheduler plugins from Box<dyn> to SchedulerPlugin enum |
| crates/orchestrator/src/plugins/webhook/mod.rs | Adjusted handle_status_change signature and removed trait impl |
| crates/orchestrator/src/plugins/traits.rs | Deleted trait definitions; plugins now use enums & functions |
| crates/orchestrator/src/plugins/node_groups/tests.rs | Updated node_groups tests to new API (add_observer, free fns) |
| crates/orchestrator/src/plugins/node_groups/status_update_impl.rs | Inlined handle_status_change into NodeGroupsPlugin impl |
| crates/orchestrator/src/plugins/node_groups/scheduler_impl.rs | Inlined filter_tasks into NodeGroupsPlugin impl |
| crates/orchestrator/src/plugins/node_groups/mod.rs | Extracted many methods to free functions; removed trait cruft |
| crates/orchestrator/src/plugins/newest_task/mod.rs | Made filter_tasks synchronous and updated its tests |
| crates/orchestrator/src/plugins/mod.rs | Introduced StatusUpdatePlugin and SchedulerPlugin enums |
| crates/orchestrator/src/main.rs | Updated plugin registration to use enums and add_observer |
| crates/orchestrator/src/lib.rs | Removed unused events module import |
| crates/orchestrator/src/events/mod.rs | Deleted TaskObserver trait definition |
| crates/orchestrator/src/discovery/monitor.rs | Changed status_change_handlers to use StatusUpdatePlugin enum |
| crates/orchestrator/src/api/routes/task.rs | Switched to free get_task_topologies function |
| crates/orchestrator/src/api/routes/storage.rs | Updated storage tests to use new plugin API |
| Cargo.toml | Added manual_let_else lint and removed duplicate entry |
Comments suppressed due to low confidence (6)
crates/orchestrator/src/store/domains/task_store.rs:17
- Restricting observers to
NodeGroupsPluginprevents other plugins from subscribing. Consider using a trait object or the new enum type to allow any observer.
observers: Arc<Mutex<Vec<Arc<NodeGroupsPlugin>>>>,
crates/orchestrator/src/status_update/mod.rs:144
- [nitpick] New concurrent processing in
process_nodesshould be backed by unit or integration tests to ensure error handling and performance behave as expected.
pub async fn process_nodes(&self) -> Result<(), anyhow::Error> {
crates/orchestrator/src/store/domains/task_store.rs:2
- The import path
crate::NodeGroupsPluginis incorrect;NodeGroupsPluginlives undercrate::plugins::node_groups. Update touse crate::plugins::node_groups::NodeGroupsPlugin;.
use crate::NodeGroupsPlugin;
crates/orchestrator/src/store/domains/task_store.rs:4
- The
futures::futureimport is unused after refactoring; consider removing it for clarity.
use futures::future;
crates/orchestrator/src/status_update/mod.rs:148
- The
FuturesUnorderedinstance is mutated later with.push(...)and must be declaredlet mut futures.
let futures = FuturesUnordered::new();
crates/orchestrator/src/status_update/mod.rs:200
- Missing import for
Instant; adduse std::time::Instant;at the top of the module.
let start_time = Instant::now();
JannikSt
approved these changes
Jul 8, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NodeStatusUpdater::process_nodesto run concurrently by storing tasks in aFuturesUnorderedcloses #566