File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1
1
use std:: sync:: Arc ;
2
2
3
- use rocket:: { Shutdown , State } ;
4
3
use rocket:: response:: stream:: { Event , EventStream } ;
4
+ use rocket:: { Shutdown , State } ;
5
5
use serde_json:: json;
6
+ use std:: time:: Duration ;
6
7
use tokio:: select;
7
8
use tokio:: sync:: broadcast:: error:: RecvError ;
8
9
9
- use crate :: Context ;
10
10
use crate :: epsilon:: api:: common:: epsilon_events:: EpsilonEvent ;
11
+ use crate :: Context ;
11
12
12
13
#[ rocket:: get( "/ping" ) ]
13
14
pub async fn ping ( ) -> & ' static str {
@@ -20,7 +21,7 @@ pub async fn events(context: &State<Arc<Context>>, mut end: Shutdown) -> EventSt
20
21
21
22
let mut rx = epsilon_api. subscribe ( ) ;
22
23
23
- EventStream ! {
24
+ let stream = EventStream ! {
24
25
loop {
25
26
let event: EpsilonEvent = select! {
26
27
event = rx. recv( ) => match event {
@@ -44,5 +45,7 @@ pub async fn events(context: &State<Arc<Context>>, mut end: Shutdown) -> EventSt
44
45
}
45
46
}
46
47
}
47
- }
48
+ } ;
49
+
50
+ stream. heartbeat ( Duration :: from_secs ( 5 ) )
48
51
}
You can’t perform that action at this time.
0 commit comments