12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
- use crate :: client:: cache :: ConfigurationSnapshot ;
15
+ use crate :: client:: configuration :: Configuration ;
16
16
pub use crate :: client:: feature_proxy:: FeatureProxy ;
17
17
use crate :: client:: feature_snapshot:: FeatureSnapshot ;
18
18
pub use crate :: client:: property_proxy:: PropertyProxy ;
@@ -33,7 +33,7 @@ use super::{AppConfigurationClient, ConfigurationId};
33
33
/// AppConfiguration client implementation that connects to a server
34
34
#[ derive( Debug ) ]
35
35
pub struct AppConfigurationClientHttp {
36
- latest_config_snapshot : Arc < Mutex < ConfigurationSnapshot > > ,
36
+ latest_config_snapshot : Arc < Mutex < Configuration > > ,
37
37
_thread_terminator : std:: sync:: mpsc:: Sender < ( ) > ,
38
38
}
39
39
@@ -56,7 +56,7 @@ impl AppConfigurationClientHttp {
56
56
let server_client = ServerClientImpl :: new ( service_address, token_provider) ?;
57
57
58
58
// Populate initial configuration
59
- let latest_config_snapshot: Arc < Mutex < ConfigurationSnapshot > > = Arc :: new ( Mutex :: new (
59
+ let latest_config_snapshot: Arc < Mutex < Configuration > > = Arc :: new ( Mutex :: new (
60
60
Self :: get_configuration_snapshot ( & server_client, & configuration_id) ?,
61
61
) ) ;
62
62
@@ -78,16 +78,16 @@ impl AppConfigurationClientHttp {
78
78
fn get_configuration_snapshot (
79
79
server_client : & ServerClientImpl ,
80
80
configuration_id : & ConfigurationId ,
81
- ) -> Result < ConfigurationSnapshot > {
81
+ ) -> Result < Configuration > {
82
82
let configuration = server_client. get_configuration ( configuration_id) ?;
83
- ConfigurationSnapshot :: new ( & configuration_id. environment_id , configuration)
83
+ Configuration :: new ( & configuration_id. environment_id , configuration)
84
84
}
85
85
86
86
fn wait_for_configuration_update (
87
87
socket : & mut WebSocket < MaybeTlsStream < TcpStream > > ,
88
88
server_client_impl : & ServerClientImpl ,
89
89
configuration_id : & ConfigurationId ,
90
- ) -> Result < ConfigurationSnapshot > {
90
+ ) -> Result < Configuration > {
91
91
loop {
92
92
// read() blocks until something happens.
93
93
match socket. read ( ) ? {
@@ -110,7 +110,7 @@ impl AppConfigurationClientHttp {
110
110
111
111
fn update_configuration_on_change (
112
112
mut socket : WebSocket < MaybeTlsStream < TcpStream > > ,
113
- latest_config_snapshot : Arc < Mutex < ConfigurationSnapshot > > ,
113
+ latest_config_snapshot : Arc < Mutex < Configuration > > ,
114
114
server_client_impl : ServerClientImpl ,
115
115
configuration_id : ConfigurationId ,
116
116
) -> std:: sync:: mpsc:: Sender < ( ) > {
@@ -146,7 +146,7 @@ impl AppConfigurationClientHttp {
146
146
}
147
147
148
148
fn update_cache_in_background (
149
- latest_config_snapshot : Arc < Mutex < ConfigurationSnapshot > > ,
149
+ latest_config_snapshot : Arc < Mutex < Configuration > > ,
150
150
server_client_impl : ServerClientImpl ,
151
151
configuration_id : ConfigurationId ,
152
152
) -> Result < std:: sync:: mpsc:: Sender < ( ) > > {
@@ -245,17 +245,17 @@ mod tests {
245
245
configuration_feature1_enabled, configuration_property1_enabled,
246
246
example_configuration_enterprise,
247
247
} ;
248
- use crate :: { models:: Configuration , Feature , Property } ;
248
+ use crate :: { models:: ConfigurationJson , Feature , Property } ;
249
249
use rstest:: rstest;
250
250
251
251
#[ rstest]
252
252
fn test_get_feature_persistence (
253
- example_configuration_enterprise : Configuration ,
254
- configuration_feature1_enabled : Configuration ,
253
+ example_configuration_enterprise : ConfigurationJson ,
254
+ configuration_feature1_enabled : ConfigurationJson ,
255
255
) {
256
256
let client = {
257
257
let configuration_snapshot =
258
- ConfigurationSnapshot :: new ( "dev" , example_configuration_enterprise) . unwrap ( ) ;
258
+ Configuration :: new ( "dev" , example_configuration_enterprise) . unwrap ( ) ;
259
259
260
260
let ( sender, _) = std:: sync:: mpsc:: channel ( ) ;
261
261
@@ -272,7 +272,7 @@ mod tests {
272
272
273
273
// We simulate an update of the configuration:
274
274
let configuration_snapshot =
275
- ConfigurationSnapshot :: new ( "environment_id" , configuration_feature1_enabled) . unwrap ( ) ;
275
+ Configuration :: new ( "environment_id" , configuration_feature1_enabled) . unwrap ( ) ;
276
276
* client. latest_config_snapshot . lock ( ) . unwrap ( ) = configuration_snapshot;
277
277
// The feature value should not have changed (as we did not retrieve it again)
278
278
let feature_value2 = feature. get_value ( & entity) . unwrap ( ) ;
@@ -287,12 +287,12 @@ mod tests {
287
287
288
288
#[ rstest]
289
289
fn test_get_property_persistence (
290
- example_configuration_enterprise : Configuration ,
291
- configuration_property1_enabled : Configuration ,
290
+ example_configuration_enterprise : ConfigurationJson ,
291
+ configuration_property1_enabled : ConfigurationJson ,
292
292
) {
293
293
let client = {
294
294
let configuration_snapshot =
295
- ConfigurationSnapshot :: new ( "dev" , example_configuration_enterprise) . unwrap ( ) ;
295
+ Configuration :: new ( "dev" , example_configuration_enterprise) . unwrap ( ) ;
296
296
297
297
let ( sender, _) = std:: sync:: mpsc:: channel ( ) ;
298
298
@@ -309,7 +309,7 @@ mod tests {
309
309
310
310
// We simulate an update of the configuration:
311
311
let configuration_snapshot =
312
- ConfigurationSnapshot :: new ( "environment_id" , configuration_property1_enabled) . unwrap ( ) ;
312
+ Configuration :: new ( "environment_id" , configuration_property1_enabled) . unwrap ( ) ;
313
313
* client. latest_config_snapshot . lock ( ) . unwrap ( ) = configuration_snapshot;
314
314
// The property value should not have changed (as we did not retrieve it again)
315
315
let property_value2 = property. get_value ( & entity) . unwrap ( ) ;
0 commit comments