kabu_core_components/
traits.rs1use crate::{BuilderContext, Component};
2use eyre::Result;
3use std::future::Future;
4
5pub trait PoolBuilder<State>: Send {
7 type Pool: Component;
9
10 fn build_pool(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::Pool>> + Send;
12}
13
14pub trait NetworkBuilder<State>: Send {
16 type Network: Component;
18
19 fn build_network(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::Network>> + Send;
21}
22
23pub trait ExecutorBuilder<State>: Send {
25 type Executor: Component;
27
28 fn build_executor(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::Executor>> + Send;
30}
31
32pub trait StrategyBuilder<State>: Send {
34 type Strategy: Component;
36
37 fn build_strategy(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::Strategy>> + Send;
39}
40
41pub trait SignerBuilder<State>: Send {
43 type Signer: Component;
45
46 fn build_signer(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::Signer>> + Send;
48}
49
50pub trait MarketBuilder<State>: Send {
52 type Market: Component;
54
55 fn build_market(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::Market>> + Send;
57}
58
59pub trait BroadcasterBuilder<State>: Send {
61 type Broadcaster: Component;
63
64 fn build_broadcaster(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::Broadcaster>> + Send;
66}
67
68pub trait EstimatorBuilder<State>: Send {
70 type Estimator: Component;
72
73 fn build_estimator(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::Estimator>> + Send;
75}
76
77pub trait HealthMonitorBuilder<State>: Send {
79 type HealthMonitor: Component;
81
82 fn build_health_monitor(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::HealthMonitor>> + Send;
84}
85
86pub trait ConsensusBuilder<State>: Send {
88 type Consensus: Component;
90
91 fn build_consensus(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::Consensus>> + Send;
93}
94
95pub trait PayloadBuilder<State>: Send {
97 type PayloadBuilder: Component;
99
100 fn build_payload(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::PayloadBuilder>> + Send;
102}
103
104pub trait MevNodeComponentsBuilder<State>: Send {
106 type Pool: PoolBuilder<State>;
108 type Network: NetworkBuilder<State>;
110 type Executor: ExecutorBuilder<State>;
112 type Strategy: StrategyBuilder<State>;
114 type Signer: SignerBuilder<State>;
116 type Market: MarketBuilder<State>;
118 type Broadcaster: BroadcasterBuilder<State>;
120 type Estimator: EstimatorBuilder<State>;
122 type HealthMonitor: HealthMonitorBuilder<State>;
124
125 fn pool_builder(&self) -> Self::Pool;
127 fn network_builder(&self) -> Self::Network;
129 fn executor_builder(&self) -> Self::Executor;
131 fn strategy_builder(&self) -> Self::Strategy;
133 fn signer_builder(&self) -> Self::Signer;
135 fn market_builder(&self) -> Self::Market;
137 fn broadcaster_builder(&self) -> Self::Broadcaster;
139 fn estimator_builder(&self) -> Self::Estimator;
141 fn health_monitor_builder(&self) -> Self::HealthMonitor;
143}
144
145pub trait InitializerBuilder<State>: Send {
147 type Initializer: Component;
149
150 fn build_initializer(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::Initializer>> + Send;
152}
153
154pub trait MergerBuilder<State>: Send {
156 type Merger: Component;
158
159 fn build_merger(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::Merger>> + Send;
161}
162
163pub trait WebServerBuilder<State>: Send {
165 type WebServer: Component;
167
168 fn build_web_server(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::WebServer>> + Send;
170}
171
172pub trait MonitoringBuilder<State>: Send {
174 type Monitoring: Component;
176
177 fn build_monitoring(self, ctx: &BuilderContext<State>) -> impl Future<Output = Result<Self::Monitoring>> + Send;
179}
180
181pub trait NodeComponentsBuilder<State>: Send {
183 type Pool: PoolBuilder<State>;
185 type Network: NetworkBuilder<State>;
187 type Executor: ExecutorBuilder<State>;
189 type Strategy: StrategyBuilder<State>;
191
192 fn pool_builder(&self) -> Self::Pool;
194 fn network_builder(&self) -> Self::Network;
196 fn executor_builder(&self) -> Self::Executor;
198 fn strategy_builder(&self) -> Self::Strategy;
200}