@@ -56,6 +56,9 @@ pub struct ConfigBundle {
56
56
///
57
57
/// These are `drop()`ed when the bundle is dropped
58
58
_handles : Arc < AbortHandles > ,
59
+ /// The sender that is used to notify the receiver that the config has changed, this
60
+ /// must not be dropped until the receiver is dropped so we ensure it's kept alive
61
+ _changed_notifier : Arc < Sender < ( ) > > ,
59
62
}
60
63
61
64
impl Clone for ConfigBundle {
@@ -69,6 +72,7 @@ impl Clone for ConfigBundle {
69
72
merged_config : self . merged_config . clone ( ) ,
70
73
config_names : self . config_names . clone ( ) ,
71
74
changed_receiver,
75
+ _changed_notifier : self . _changed_notifier . clone ( ) ,
72
76
_handles : self . _handles . clone ( ) ,
73
77
}
74
78
}
@@ -98,17 +102,18 @@ impl ConfigBundle {
98
102
. unzip ( ) ;
99
103
// Now that we've set initial config, create the bundle and update the merged config with the latest values
100
104
let ( changed_notifier, changed_receiver) = watch:: channel ( ( ) ) ;
105
+ let changed_notifier = Arc :: new ( changed_notifier) ;
101
106
let mut bundle = ConfigBundle {
102
107
merged_config : Arc :: default ( ) ,
103
108
config_names : receivers. iter ( ) . map ( |r| r. name . clone ( ) ) . collect ( ) ,
104
109
changed_receiver,
110
+ _changed_notifier : changed_notifier. clone ( ) ,
105
111
_handles : Arc :: new ( AbortHandles {
106
112
handles : abort_handles,
107
113
} ) ,
108
114
} ;
109
115
let ordered_configs: Arc < Vec < Receiver < HashMap < String , String > > > > =
110
116
Arc :: new ( receivers. iter ( ) . map ( |r| r. receiver . clone ( ) ) . collect ( ) ) ;
111
- let changed_notifier = Arc :: new ( changed_notifier) ;
112
117
update_merge ( & bundle. merged_config , & changed_notifier, & ordered_configs) . await ;
113
118
// Move all the receivers into spawned tasks to update the config
114
119
for ConfigReceiver { name, mut receiver } in receivers {
0 commit comments