Skip to main content

helix_driver_host/engine/
entrypoints.rs

1use helix_core::ports::{Clock, FileUploader, FrameSender, HttpRequester, Storage};
2use helix_core::{ExecutionShell, Tick};
3use tokio::sync::{mpsc, oneshot};
4
5use super::{run_engine_loop_inner, BatchSink, EngineDeps, TransportRegistration, TransportTable};
6use crate::tick_ingress::{
7    EngineTickReceiver, EngineTickSender, TickIngressReceiver, TickIngressSender,
8};
9
10#[allow(clippy::too_many_arguments)]
11pub async fn run_engine_loop<S, H, U, E, Tr, C>(
12    shell: ExecutionShell,
13    tick_rx: mpsc::Receiver<Tick>,
14    tick_tx: mpsc::Sender<Tick>,
15    deps: EngineDeps<S, H, U, E, C>,
16    shutdown_rx: oneshot::Receiver<()>,
17    transports: TransportTable<Tr>,
18    transport_rx: mpsc::UnboundedReceiver<TransportRegistration<Tr>>,
19) where
20    S: Storage + Send + Sync + 'static,
21    H: HttpRequester + Send + Sync + 'static,
22    U: FileUploader + Send + Sync + 'static,
23    E: BatchSink + Send + Sync + 'static,
24    Tr: FrameSender + Send + Sync + 'static,
25    C: Clock,
26{
27    run_engine_loop_inner(
28        shell,
29        EngineTickReceiver::Raw(tick_rx),
30        EngineTickSender::Raw(tick_tx),
31        deps,
32        shutdown_rx,
33        transports,
34        transport_rx,
35    )
36    .await;
37}
38
39/// 生产入口:Tick 与入队时间戳同处一个有界 channel 元素,容量与背压语义不变。
40#[allow(clippy::too_many_arguments)]
41pub async fn run_engine_loop_stamped<S, H, U, E, Tr, C>(
42    shell: ExecutionShell,
43    tick_rx: TickIngressReceiver,
44    tick_tx: TickIngressSender,
45    deps: EngineDeps<S, H, U, E, C>,
46    shutdown_rx: oneshot::Receiver<()>,
47    transports: TransportTable<Tr>,
48    transport_rx: mpsc::UnboundedReceiver<TransportRegistration<Tr>>,
49) where
50    S: Storage + Send + Sync + 'static,
51    H: HttpRequester + Send + Sync + 'static,
52    U: FileUploader + Send + Sync + 'static,
53    E: BatchSink + Send + Sync + 'static,
54    Tr: FrameSender + Send + Sync + 'static,
55    C: Clock,
56{
57    run_engine_loop_inner(
58        shell,
59        EngineTickReceiver::Stamped(tick_rx),
60        EngineTickSender::Stamped(tick_tx),
61        deps,
62        shutdown_rx,
63        transports,
64        transport_rx,
65    )
66    .await;
67}