MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / with_resolver

Method with_resolver

nodedb/src/bridge/dispatch.rs:226–268  ·  view source on GitHub ↗

Like `new`, but accepts a custom `DatabasePriorityResolver`.

(
        num_cores: usize,
        queue_capacity: usize,
        priority_resolver: Box<dyn DatabasePriorityResolver>,
    )

Source from the content-addressed store, hash-verified

224
225 /// Like `new`, but accepts a custom `DatabasePriorityResolver`.
226 pub fn with_resolver(
227 num_cores: usize,
228 queue_capacity: usize,
229 priority_resolver: Box<dyn DatabasePriorityResolver>,
230 ) -> (Self, Vec<CoreChannelDataSide>) {
231 let mut cores = Vec::with_capacity(num_cores);
232 let mut data_sides = Vec::with_capacity(num_cores);
233
234 for _ in 0..num_cores {
235 let (req_tx, req_rx) = RingBuffer::channel::<BridgeRequest>(queue_capacity);
236 let (resp_tx, resp_rx) = RingBuffer::channel::<BridgeResponse>(queue_capacity);
237
238 cores.push(CoreChannel {
239 request_tx: req_tx,
240 response_rx: resp_rx,
241 backpressure: BackpressureController::new(BackpressureConfig::default()),
242 wfq: WeightedFairQueue::new(queue_capacity, queue_capacity),
243 db_pressure: HashMap::new(),
244 wake_notifier: None,
245 });
246
247 data_sides.push(CoreChannelDataSide {
248 request_rx: req_rx,
249 response_tx: resp_tx,
250 });
251 }
252
253 let router = VShardRouter::round_robin(num_cores);
254 let total_capacity = num_cores * queue_capacity;
255
256 (
257 Self {
258 cores,
259 router,
260 tenant_inflight: HashMap::new(),
261 request_tenant: HashMap::new(),
262 max_per_tenant_inflight: total_capacity as u32,
263 per_core_capacity: queue_capacity as u32,
264 priority_resolver,
265 },
266 data_sides,
267 )
268 }
269
270 /// Dispatch a request to the correct Data Plane core.
271 ///

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected