Skip to content

Commit dbc9d30

Browse files
committed
refactor(engine): replace long argument lists with params structs
Control-Plane gateway dispatch, graph traversal (BFS, BSP pagerank/WCC, cluster resolve, subgraph traverse), DDL neutral graph/tree ops, typed automation routing, and shuffle fan-out handlers took long positional argument lists. Bundle them into per-handler params structs and update call sites, matching the pattern already applied elsewhere in the engine.
1 parent c046fbf commit dbc9d30

19 files changed

Lines changed: 313 additions & 174 deletions

File tree

nodedb/src/control/gateway/dispatcher.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ pub async fn dispatch_route(
8787
}
8888
}
8989

90+
/// Parameters for [`dispatch_route_stream`].
91+
pub struct DispatchRouteStreamParams<'a> {
92+
pub route: TaskRoute,
93+
pub shared: &'a Arc<SharedState>,
94+
pub tenant_id: TenantId,
95+
pub database_id: DatabaseId,
96+
pub trace_id: TraceId,
97+
pub deadline_ms: u64,
98+
pub version_set: &'a GatewayVersionSet,
99+
}
100+
90101
/// Streaming sibling of [`dispatch_route`]: dispatch a single route and return
91102
/// a [`ResultStream`] of row batches.
92103
///
@@ -96,16 +107,18 @@ pub async fn dispatch_route(
96107
/// - `Remote` → [`dispatch_remote_stream`] (eager first frame + retry split).
97108
/// - `Broadcast` → unreachable (router splits broadcasts before dispatch).
98109
/// - `LeaderUnknown` → `NotLeader` so the gateway retry loop re-resolves.
99-
#[allow(clippy::too_many_arguments)]
100110
pub async fn dispatch_route_stream(
101-
route: TaskRoute,
102-
shared: &Arc<SharedState>,
103-
tenant_id: TenantId,
104-
database_id: DatabaseId,
105-
trace_id: TraceId,
106-
deadline_ms: u64,
107-
version_set: &GatewayVersionSet,
111+
args: DispatchRouteStreamParams<'_>,
108112
) -> Result<ResultStream, Error> {
113+
let DispatchRouteStreamParams {
114+
route,
115+
shared,
116+
tenant_id,
117+
database_id,
118+
trace_id,
119+
deadline_ms,
120+
version_set,
121+
} = args;
109122
match route.decision {
110123
// Cluster gateway route dispatch: no session-transaction context
111124
// crosses this boundary yet, so `None`. TRACKED: cross-node

nodedb/src/control/gateway/stream.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::control::server::result_stream::ResultStream;
1414
use nodedb_physical::physical_plan::PhysicalPlan;
1515

1616
use super::core::{Gateway, QueryContext};
17-
use super::dispatcher::{default_deadline_ms, dispatch_route_stream};
17+
use super::dispatcher::{DispatchRouteStreamParams, default_deadline_ms, dispatch_route_stream};
1818
use super::retry::retry_not_leader;
1919
use super::route::TaskRoute;
2020
use super::router::resolve_decision;
@@ -104,15 +104,15 @@ impl Gateway {
104104
decision,
105105
vshard_id: vshard_id_u32,
106106
};
107-
dispatch_route_stream(
107+
dispatch_route_stream(DispatchRouteStreamParams {
108108
route,
109-
&shared,
109+
shared: &shared,
110110
tenant_id,
111111
database_id,
112112
trace_id,
113113
deadline_ms,
114-
&version_set,
115-
)
114+
version_set: &version_set,
115+
})
116116
.await
117117
}
118118
})

nodedb/src/control/server/graph_dispatch/bfs.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,34 @@ use crate::types::{DatabaseId, TenantId};
2121
use super::helpers::{encode_path, ok_response};
2222
use super::hop::{NeighborHopParams, execute_neighbor_hop};
2323

24+
/// Parameters for [`cross_core_bfs_with_options`].
25+
pub struct CrossCoreBfsParams<'a> {
26+
pub tenant_id: TenantId,
27+
pub database_id: DatabaseId,
28+
pub start_nodes: Vec<String>,
29+
pub edge_label: Option<String>,
30+
pub direction: crate::engine::graph::edge_store::Direction,
31+
pub max_depth: usize,
32+
pub options: &'a GraphTraversalOptions,
33+
}
34+
2435
/// Cross-core BFS with explicit traversal options (fan-out limits, partial mode).
2536
///
2637
/// This is the cluster-aware entry point. Callers pass
2738
/// `&GraphTraversalOptions::default()` for standard traversal.
28-
#[allow(clippy::too_many_arguments)]
2939
pub async fn cross_core_bfs_with_options(
3040
shared: &SharedState,
31-
tenant_id: TenantId,
32-
database_id: DatabaseId,
33-
start_nodes: Vec<String>,
34-
edge_label: Option<String>,
35-
direction: crate::engine::graph::edge_store::Direction,
36-
max_depth: usize,
37-
options: &GraphTraversalOptions,
41+
params: CrossCoreBfsParams<'_>,
3842
) -> crate::Result<Response> {
43+
let CrossCoreBfsParams {
44+
tenant_id,
45+
database_id,
46+
start_nodes,
47+
edge_label,
48+
direction,
49+
max_depth,
50+
options,
51+
} = params;
3952
let mut visited: HashSet<String> = HashSet::new();
4053
let mut all_discovered: Vec<String> = Vec::new();
4154
let mut frontier: Vec<String> = start_nodes;

nodedb/src/control/server/graph_dispatch/bsp_pagerank/coord.rs

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use crate::engine::graph::algo::result::AlgoResultBatch;
4949
use crate::types::{DatabaseId, TenantId};
5050

5151
use super::enumerate::enumerate_shards;
52-
use super::scatter::{ShardDispatch, scatter_superstep};
52+
use super::scatter::{ScatterSuperstepParams, ShardDispatch, scatter_superstep};
5353

5454
/// Default max supersteps when the query carries no explicit `ITERATIONS`.
5555
/// Mirrors the single-node PageRank default iteration budget.
@@ -135,14 +135,16 @@ pub async fn run_bsp_pagerank(
135135
.collect();
136136
let counts = scatter_superstep(
137137
state,
138-
tenant_id,
139-
database_id,
140-
algorithm,
141-
&params,
142-
0,
143-
0, // count-only sentinel
144-
count_dispatches,
145-
deadline_ms,
138+
ScatterSuperstepParams {
139+
tenant_id,
140+
database_id,
141+
algorithm,
142+
params: &params,
143+
superstep: 0,
144+
global_n: 0, // count-only sentinel
145+
dispatches: count_dispatches,
146+
deadline_ms,
147+
},
146148
)
147149
.await?;
148150

@@ -233,14 +235,16 @@ pub async fn run_bsp_pagerank(
233235

234236
let results = scatter_superstep(
235237
state,
236-
tenant_id,
237-
database_id,
238-
algorithm,
239-
&params,
240-
superstep,
241-
global_n,
242-
dispatches,
243-
deadline_ms,
238+
ScatterSuperstepParams {
239+
tenant_id,
240+
database_id,
241+
algorithm,
242+
params: &params,
243+
superstep,
244+
global_n,
245+
dispatches,
246+
deadline_ms,
247+
},
244248
)
245249
.await?;
246250

nodedb/src/control/server/graph_dispatch/bsp_pagerank/scatter.rs

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use futures::future::join_all;
1717
use crate::bridge::envelope::{Payload, PhysicalPlan};
1818
use crate::control::gateway::version_set::GatewayVersionSet;
1919
use crate::control::server::graph_dispatch::cluster_resolve::{
20-
dispatch_superstep_to_node, gateway_shared,
20+
DispatchSuperstepParams, dispatch_superstep_to_node, gateway_shared,
2121
};
2222
use crate::types::{DatabaseId, TenantId};
2323
use nodedb_graph::{AlgoParams, GraphAlgorithm};
@@ -56,21 +56,35 @@ pub(super) struct ShardResult {
5656
pub(super) result: BspSuperstepResult,
5757
}
5858

59+
/// Parameters for [`scatter_superstep`].
60+
pub(super) struct ScatterSuperstepParams<'a> {
61+
pub(super) tenant_id: TenantId,
62+
pub(super) database_id: DatabaseId,
63+
pub(super) algorithm: GraphAlgorithm,
64+
pub(super) params: &'a AlgoParams,
65+
pub(super) superstep: u32,
66+
pub(super) global_n: usize,
67+
pub(super) dispatches: Vec<ShardDispatch>,
68+
pub(super) deadline_ms: u64,
69+
}
70+
5971
/// Dispatch one `BspSuperstep` to every owner node concurrently and decode each
6072
/// node's [`BspSuperstepResult`]. `global_n == 0` is the count-only phase
6173
/// (handler short-circuits after counting owned nodes).
62-
#[allow(clippy::too_many_arguments)]
6374
pub(super) async fn scatter_superstep(
6475
state: &crate::control::state::SharedState,
65-
tenant_id: TenantId,
66-
database_id: DatabaseId,
67-
algorithm: GraphAlgorithm,
68-
params: &AlgoParams,
69-
superstep: u32,
70-
global_n: usize,
71-
dispatches: Vec<ShardDispatch>,
72-
deadline_ms: u64,
76+
args: ScatterSuperstepParams<'_>,
7377
) -> crate::Result<Vec<ShardResult>> {
78+
let ScatterSuperstepParams {
79+
tenant_id,
80+
database_id,
81+
algorithm,
82+
params,
83+
superstep,
84+
global_n,
85+
dispatches,
86+
deadline_ms,
87+
} = args;
7488
let shared_arc = gateway_shared(state)?;
7589
let version_set = GatewayVersionSet::from_pairs(Vec::new());
7690

@@ -96,14 +110,16 @@ pub(super) async fn scatter_superstep(
96110
Box::pin(async move {
97111
let payload = dispatch_superstep_to_node(
98112
shared_arc,
99-
tenant_id,
100-
database_id,
101-
deadline_ms,
102-
node_id,
103-
is_local,
104-
route_vshard,
105-
plan,
106-
&version_set,
113+
DispatchSuperstepParams {
114+
tenant_id,
115+
database_id,
116+
deadline_ms,
117+
node_id,
118+
is_local,
119+
route_vshard,
120+
plan,
121+
version_set: &version_set,
122+
},
107123
)
108124
.await?;
109125
let result = decode_single_result_from_payload(node_id, payload)?;

nodedb/src/control/server/graph_dispatch/bsp_wcc/scatter.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::bridge::envelope::{Payload, PhysicalPlan};
1818
use crate::control::gateway::version_set::GatewayVersionSet;
1919
use crate::control::server::graph_dispatch::bsp_pagerank::enumerate::ShardTarget;
2020
use crate::control::server::graph_dispatch::cluster_resolve::{
21-
dispatch_superstep_to_node, gateway_shared,
21+
DispatchSuperstepParams, dispatch_superstep_to_node, gateway_shared,
2222
};
2323
use crate::types::{DatabaseId, TenantId};
2424
use nodedb_graph::AlgoParams;
@@ -60,14 +60,16 @@ pub(super) async fn scatter_wcc_round(
6060
Box::pin(async move {
6161
let payload = dispatch_superstep_to_node(
6262
&shared_arc,
63-
tenant_id,
64-
database_id,
65-
deadline_ms,
66-
node_id,
67-
is_local,
68-
route_vshard,
69-
plan,
70-
&version_set,
63+
DispatchSuperstepParams {
64+
tenant_id,
65+
database_id,
66+
deadline_ms,
67+
node_id,
68+
is_local,
69+
route_vshard,
70+
plan,
71+
version_set: &version_set,
72+
},
7173
)
7274
.await?;
7375
let result = decode_wcc_from_payload(node_id, payload)?;

nodedb/src/control/server/graph_dispatch/cluster_resolve.rs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,39 @@ pub(super) fn resolve_for_vshard(state: &SharedState, vshard_id: u32) -> RouteDe
4949
)
5050
}
5151

52+
/// Parameters for [`dispatch_superstep_to_node`].
53+
pub(in crate::control::server::graph_dispatch) struct DispatchSuperstepParams<'a> {
54+
pub(in crate::control::server::graph_dispatch) tenant_id: TenantId,
55+
pub(in crate::control::server::graph_dispatch) database_id: DatabaseId,
56+
pub(in crate::control::server::graph_dispatch) deadline_ms: u64,
57+
pub(in crate::control::server::graph_dispatch) node_id: u64,
58+
pub(in crate::control::server::graph_dispatch) is_local: bool,
59+
pub(in crate::control::server::graph_dispatch) route_vshard: u32,
60+
pub(in crate::control::server::graph_dispatch) plan: PhysicalPlan,
61+
pub(in crate::control::server::graph_dispatch) version_set: &'a GatewayVersionSet,
62+
}
63+
5264
/// Dispatch a single already-built graph-superstep `plan` to one owner node and
5365
/// return its node-level payload. The LOCAL node fans the plan across all its
5466
/// Data-Plane cores via `execute_plan_all_local_cores` (per-core results merged
5567
/// into one payload); a REMOTE node gets one `RouteDecision::Remote` dispatch via
5668
/// `dispatch_route`. An empty payload denotes a zero-vertex shard — the caller's
5769
/// decoder maps it to its result type's `::default()`. Shared by the PageRank and
5870
/// WCC per-node scatter paths.
59-
#[allow(clippy::too_many_arguments)]
6071
pub(in crate::control::server::graph_dispatch) async fn dispatch_superstep_to_node(
6172
shared_arc: &Arc<SharedState>,
62-
tenant_id: TenantId,
63-
database_id: DatabaseId,
64-
deadline_ms: u64,
65-
node_id: u64,
66-
is_local: bool,
67-
route_vshard: u32,
68-
plan: PhysicalPlan,
69-
version_set: &GatewayVersionSet,
73+
args: DispatchSuperstepParams<'_>,
7074
) -> crate::Result<Payload> {
75+
let DispatchSuperstepParams {
76+
tenant_id,
77+
database_id,
78+
deadline_ms,
79+
node_id,
80+
is_local,
81+
route_vshard,
82+
plan,
83+
version_set,
84+
} = args;
7185
if is_local {
7286
// Local node: fan across ALL local cores and merge. The per-core
7387
// owned-node sets are disjoint, so the merged result is correct without

nodedb/src/control/server/graph_dispatch/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ pub mod match_scatter;
2929
pub mod shortest_path;
3030
pub mod traverse_subgraph;
3131

32-
pub use bfs::cross_core_bfs_with_options;
32+
pub use bfs::{CrossCoreBfsParams, cross_core_bfs_with_options};
3333
pub use bsp_pagerank::run_bsp_pagerank;
3434
pub use bsp_wcc::run_bsp_wcc;
3535
pub use match_broadcast::{
3636
MatchBroadcastOutcome, broadcast_match_to_all_cores, unwrap_match_envelope,
3737
};
3838
pub use match_scatter::{MatchScatterOutcome, scatter_match};
3939
pub use shortest_path::cross_core_shortest_path;
40-
pub use traverse_subgraph::cross_core_traverse_subgraph;
40+
pub use traverse_subgraph::{CrossCoreTraverseSubgraphParams, cross_core_traverse_subgraph};

nodedb/src/control/server/graph_dispatch/traverse_subgraph.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ struct WireSubGraph<'a> {
5757
edges: Vec<WireEdge<'a>>,
5858
}
5959

60+
/// Parameters for [`cross_core_traverse_subgraph`].
61+
pub struct CrossCoreTraverseSubgraphParams<'a> {
62+
pub tenant_id: TenantId,
63+
pub database_id: DatabaseId,
64+
pub start: String,
65+
pub edge_label: Option<String>,
66+
pub direction: Direction,
67+
pub max_depth: usize,
68+
pub options: &'a GraphTraversalOptions,
69+
}
70+
6071
/// BFS that returns a `{nodes,edges}` JSON subgraph for `GRAPH TRAVERSE`.
6172
///
6273
/// Each hop expands every frontier node at the node that owns
@@ -66,17 +77,19 @@ struct WireSubGraph<'a> {
6677
/// * each `(src, label, dst)` edge the hop crossed where `src` is in the
6778
/// current frontier — fully attributed for BOTH the local-shard and
6879
/// remote-shard portions of the frontier.
69-
#[allow(clippy::too_many_arguments)]
7080
pub async fn cross_core_traverse_subgraph(
7181
shared: &SharedState,
72-
tenant_id: TenantId,
73-
database_id: DatabaseId,
74-
start: String,
75-
edge_label: Option<String>,
76-
direction: Direction,
77-
max_depth: usize,
78-
options: &GraphTraversalOptions,
82+
params: CrossCoreTraverseSubgraphParams<'_>,
7983
) -> crate::Result<Response> {
84+
let CrossCoreTraverseSubgraphParams {
85+
tenant_id,
86+
database_id,
87+
start,
88+
edge_label,
89+
direction,
90+
max_depth,
91+
options,
92+
} = params;
8093
// Per-node depth: the start node is at depth 0; subsequent nodes
8194
// are tagged with the hop index that first surfaced them.
8295
let mut depth_of: HashMap<String, u8> = HashMap::new();

0 commit comments

Comments
 (0)