1
1
use {
2
2
crate :: {
3
- aggregate:: AggregationEvent ,
4
3
config:: RunOptions ,
5
4
state:: State ,
6
5
} ,
14
13
ipnet:: IpNet ,
15
14
serde_qs:: axum:: QsQueryConfig ,
16
15
std:: sync:: Arc ,
17
- tokio:: sync:: broadcast:: Sender ,
18
16
tower_http:: cors:: CorsLayer ,
19
17
utoipa:: OpenApi ,
20
18
utoipa_swagger_ui:: SwaggerUi ,
@@ -27,21 +25,19 @@ pub mod types;
27
25
mod ws;
28
26
29
27
pub struct ApiState < S = State > {
30
- pub state : Arc < S > ,
31
- pub ws : Arc < ws:: WsState > ,
32
- pub metrics : Arc < metrics_middleware:: Metrics > ,
33
- pub update_tx : Sender < AggregationEvent > ,
28
+ pub state : Arc < S > ,
29
+ pub ws : Arc < ws:: WsState > ,
30
+ pub metrics : Arc < metrics_middleware:: Metrics > ,
34
31
}
35
32
36
33
/// Manually implement `Clone` as the derive macro will try and slap `Clone` on
37
34
/// `State` which should not be Clone.
38
35
impl < S > Clone for ApiState < S > {
39
36
fn clone ( & self ) -> Self {
40
37
Self {
41
- state : self . state . clone ( ) ,
42
- ws : self . ws . clone ( ) ,
43
- metrics : self . metrics . clone ( ) ,
44
- update_tx : self . update_tx . clone ( ) ,
38
+ state : self . state . clone ( ) ,
39
+ ws : self . ws . clone ( ) ,
40
+ metrics : self . metrics . clone ( ) ,
45
41
}
46
42
}
47
43
}
@@ -51,7 +47,6 @@ impl ApiState<State> {
51
47
state : Arc < State > ,
52
48
ws_whitelist : Vec < IpNet > ,
53
49
requester_ip_header_name : String ,
54
- update_tx : Sender < AggregationEvent > ,
55
50
) -> Self {
56
51
Self {
57
52
metrics : Arc :: new ( metrics_middleware:: Metrics :: new ( state. clone ( ) ) ) ,
@@ -61,24 +56,18 @@ impl ApiState<State> {
61
56
state. clone ( ) ,
62
57
) ) ,
63
58
state,
64
- update_tx,
65
59
}
66
60
}
67
61
}
68
62
69
- #[ tracing:: instrument( skip( opts, state, update_tx) ) ]
70
- pub async fn spawn (
71
- opts : RunOptions ,
72
- state : Arc < State > ,
73
- update_tx : Sender < AggregationEvent > ,
74
- ) -> Result < ( ) > {
63
+ #[ tracing:: instrument( skip( opts, state) ) ]
64
+ pub async fn spawn ( opts : RunOptions , state : Arc < State > ) -> Result < ( ) > {
75
65
let state = {
76
66
let opts = opts. clone ( ) ;
77
67
ApiState :: new (
78
68
state,
79
69
opts. rpc . ws_whitelist ,
80
70
opts. rpc . requester_ip_header_name ,
81
- update_tx,
82
71
)
83
72
} ;
84
73
0 commit comments