@@ -8,23 +8,21 @@ use anyhow::Error;
8
8
use async_trait:: async_trait;
9
9
use meio:: task:: HeartBeatHandle ;
10
10
use meio:: { Actor , Context , InterruptedBy , StartedBy } ;
11
- use once_cell:: sync:: OnceCell ;
12
11
use rillrate:: prime:: * ;
13
12
use std:: sync:: Arc ;
14
13
use std:: time:: Duration ;
15
14
16
- // TODO: Use local fields instead
17
- static LATENCY : OnceCell < String > = OnceCell :: new ( ) ;
18
- static TAIL : OnceCell < String > = OnceCell :: new ( ) ;
19
- static INTERVAL : OnceCell < String > = OnceCell :: new ( ) ;
20
-
21
15
pub struct Watcher {
22
16
name : String ,
23
17
url : Arc < String > ,
24
18
latency : Pulse ,
25
19
tail : LiveTail ,
26
20
interval : Slider ,
27
21
handle : HeartBeatHandle ,
22
+
23
+ latency_entry : String ,
24
+ tail_entry : String ,
25
+ interval_entry : String ,
28
26
}
29
27
30
28
impl Actor for Watcher {
@@ -33,9 +31,9 @@ impl Actor for Watcher {
33
31
34
32
impl Watcher {
35
33
pub fn new ( name : String , url : String ) -> Self {
36
- LATENCY . set ( format ! ( "site.{}.latency.pulse" , name) ) . unwrap ( ) ;
34
+ let latency_entry = format ! ( "site.{}.latency.pulse" , name) ;
37
35
let latency = Pulse :: new (
38
- LATENCY . get ( ) . unwrap ( ) . as_ref ( ) ,
36
+ latency_entry . as_ref ( ) ,
39
37
Default :: default ( ) ,
40
38
PulseOpts :: default ( )
41
39
. retain ( 30u32 )
@@ -44,17 +42,15 @@ impl Watcher {
44
42
. higher ( true )
45
43
. suffix ( "ms" ) ,
46
44
) ;
47
- TAIL . set ( format ! ( "site.{}.latency.events" , name) ) . unwrap ( ) ;
45
+ let tail_entry = format ! ( "site.{}.latency.events" , name) ;
48
46
let tail = LiveTail :: new (
49
- TAIL . get ( ) . unwrap ( ) . as_ref ( ) ,
47
+ tail_entry . as_ref ( ) ,
50
48
Default :: default ( ) ,
51
49
LiveTailOpts :: default ( ) ,
52
50
) ;
53
- INTERVAL
54
- . set ( format ! ( "site.{}.settings.interval" , name) )
55
- . unwrap ( ) ;
51
+ let interval_entry = format ! ( "site.{}.settings.interval" , name) ;
56
52
let interval = Slider :: new (
57
- INTERVAL . get ( ) . unwrap ( ) . as_ref ( ) ,
53
+ interval_entry . as_ref ( ) ,
58
54
SliderOpts :: default ( )
59
55
. label ( "Slide Me!" )
60
56
. min ( 1 )
@@ -71,6 +67,9 @@ impl Watcher {
71
67
tail,
72
68
interval,
73
69
handle,
70
+ latency_entry,
71
+ tail_entry,
72
+ interval_entry,
74
73
}
75
74
}
76
75
}
0 commit comments