diff --git a/contracts/src/provider_proxy_selector.rs b/contracts/src/provider_proxy_selector.rs index 2a2d5738..f0790fb3 100644 --- a/contracts/src/provider_proxy_selector.rs +++ b/contracts/src/provider_proxy_selector.rs @@ -11,7 +11,9 @@ use crate::{entity::Entity, provider_proxy::ProviderProxyFactory}; #[async_trait] pub trait ProviderProxySelector { /// Registers a `ProviderProxyFactory` with this selector. - fn register(&mut self) -> Result<(), ProviderProxySelectorError>; + fn register( + &mut self, + ) -> Result<(), ProviderProxySelectorError>; /// Updates an existing proxy for an entity if possible, /// otherwise creates a new proxy to handle that entity. diff --git a/freyja/src/cartographer.rs b/freyja/src/cartographer.rs index 07c53da2..a7e85c8c 100644 --- a/freyja/src/cartographer.rs +++ b/freyja/src/cartographer.rs @@ -214,7 +214,8 @@ mod cartographer_tests { CheckForWorkResponse, GetMappingResponse, MappingClientError, SendInventoryRequest, SendInventoryResponse, }, - provider_proxy_selector::ProviderProxySelectorError, provider_proxy::ProviderProxyFactory, + provider_proxy::ProviderProxyFactory, + provider_proxy_selector::ProviderProxySelectorError, }; mock! { diff --git a/freyja/src/emitter.rs b/freyja/src/emitter.rs index 5e577105..7eec67f4 100644 --- a/freyja/src/emitter.rs +++ b/freyja/src/emitter.rs @@ -230,8 +230,9 @@ mod emitter_tests { use freyja_contracts::{ cloud_adapter::{CloudAdapterError, CloudAdapterErrorKind}, entity::Entity, + provider_proxy::ProviderProxyFactory, provider_proxy_selector::ProviderProxySelectorError, - signal::{Emission, EmissionPolicy}, provider_proxy::ProviderProxyFactory, + signal::{Emission, EmissionPolicy}, }; mock! { diff --git a/freyja/src/lib.rs b/freyja/src/lib.rs index dd00fe3b..5d19d460 100644 --- a/freyja/src/lib.rs +++ b/freyja/src/lib.rs @@ -24,7 +24,8 @@ use emitter::Emitter; use freyja_common::signal_store::SignalStore; use freyja_contracts::{ cloud_adapter::CloudAdapter, digital_twin_adapter::DigitalTwinAdapter, - mapping_client::MappingClient, provider_proxy::SignalValue, provider_proxy_selector::ProviderProxySelector, + mapping_client::MappingClient, provider_proxy::SignalValue, + provider_proxy_selector::ProviderProxySelector, }; use provider_proxy_selector::provider_proxy_selector_impl::ProviderProxySelectorImpl; diff --git a/provider_proxies/grpc/v1/src/grpc_provider_proxy.rs b/provider_proxies/grpc/v1/src/grpc_provider_proxy.rs index a455c9bd..29ffc253 100644 --- a/provider_proxies/grpc/v1/src/grpc_provider_proxy.rs +++ b/provider_proxies/grpc/v1/src/grpc_provider_proxy.rs @@ -97,8 +97,7 @@ impl ProviderProxy for GRPCProviderProxy { .serve(addr); tokio::spawn(async move { - let _ = server_future - .await; + let _ = server_future.await; }); info!("Started a GRPCProviderProxy!"); diff --git a/provider_proxies/grpc/v1/src/grpc_provider_proxy_factory.rs b/provider_proxies/grpc/v1/src/grpc_provider_proxy_factory.rs index 43240706..ce78719e 100644 --- a/provider_proxies/grpc/v1/src/grpc_provider_proxy_factory.rs +++ b/provider_proxies/grpc/v1/src/grpc_provider_proxy_factory.rs @@ -20,7 +20,7 @@ pub struct GRPCProviderProxyFactory {} impl ProviderProxyFactory for GRPCProviderProxyFactory { /// Create a new `GRPCProviderProxyFactory` fn new() -> Self { - Self { } + Self {} } /// Check to see whether this factory can create a proxy for the requested entity. diff --git a/provider_proxies/http_mock_provider_proxy/src/http_mock_provider_proxy.rs b/provider_proxies/http_mock_provider_proxy/src/http_mock_provider_proxy.rs index cc6db24a..610af2f1 100644 --- a/provider_proxies/http_mock_provider_proxy/src/http_mock_provider_proxy.rs +++ b/provider_proxies/http_mock_provider_proxy/src/http_mock_provider_proxy.rs @@ -155,9 +155,7 @@ impl ProviderProxy for HttpMockProviderProxy { .map_err(ProviderProxyError::communication)?; tokio::spawn(async move { - let _ = builder - .serve(router.into_make_service()) - .await; + let _ = builder.serve(router.into_make_service()).await; }); info!( diff --git a/provider_proxies/http_mock_provider_proxy/src/http_mock_provider_proxy_factory.rs b/provider_proxies/http_mock_provider_proxy/src/http_mock_provider_proxy_factory.rs index 5b31c122..0c3e6b86 100644 --- a/provider_proxies/http_mock_provider_proxy/src/http_mock_provider_proxy_factory.rs +++ b/provider_proxies/http_mock_provider_proxy/src/http_mock_provider_proxy_factory.rs @@ -21,7 +21,7 @@ pub struct HttpMockProviderProxyFactory {} impl ProviderProxyFactory for HttpMockProviderProxyFactory { /// Create a new `GRPCProviderProxyFactory` fn new() -> Self { - Self { } + Self {} } /// Check to see whether this factory can create a proxy for the requested entity. diff --git a/provider_proxies/in_memory_mock_provider_proxy/src/in_memory_mock_provider_proxy.rs b/provider_proxies/in_memory_mock_provider_proxy/src/in_memory_mock_provider_proxy.rs index 9f0e5eb2..623debd6 100644 --- a/provider_proxies/in_memory_mock_provider_proxy/src/in_memory_mock_provider_proxy.rs +++ b/provider_proxies/in_memory_mock_provider_proxy/src/in_memory_mock_provider_proxy.rs @@ -120,7 +120,7 @@ impl ProviderProxy for InMemoryMockProviderProxy { async fn start(&self) -> Result<(), ProviderProxyError> { let entity_operation_map = self.entity_operation_map.clone(); let signal_values_queue = self.signal_values_queue.clone(); - let signal_update_frequency = self.signal_update_frequency.clone(); + let signal_update_frequency = self.signal_update_frequency; let data = self.data.clone(); tokio::spawn(async move { @@ -140,11 +140,8 @@ impl ProviderProxy for InMemoryMockProviderProxy { let data = data.lock().await; for entity_id in entities_with_subscribe { - let _ = Self::generate_signal_value( - &entity_id, - signal_values_queue.clone(), - &data, - ); + let _ = + Self::generate_signal_value(&entity_id, signal_values_queue.clone(), &data); } tokio::time::sleep(signal_update_frequency).await; @@ -178,11 +175,7 @@ impl ProviderProxy for InMemoryMockProviderProxy { let data = self.data.lock().await; if operation == GET_OPERATION { - let _ = Self::generate_signal_value( - entity_id, - self.signal_values_queue.clone(), - &data, - ); + let _ = Self::generate_signal_value(entity_id, self.signal_values_queue.clone(), &data); } Ok(()) diff --git a/provider_proxies/in_memory_mock_provider_proxy/src/in_memory_mock_provider_proxy_factory.rs b/provider_proxies/in_memory_mock_provider_proxy/src/in_memory_mock_provider_proxy_factory.rs index 557eb316..cd7a6c1b 100644 --- a/provider_proxies/in_memory_mock_provider_proxy/src/in_memory_mock_provider_proxy_factory.rs +++ b/provider_proxies/in_memory_mock_provider_proxy/src/in_memory_mock_provider_proxy_factory.rs @@ -21,7 +21,7 @@ pub struct InMemoryMockProviderProxyFactory {} impl ProviderProxyFactory for InMemoryMockProviderProxyFactory { /// Create a new `GRPCProviderProxyFactory` fn new() -> Self { - Self { } + Self {} } /// Check to see whether this factory can create a proxy for the requested entity. diff --git a/provider_proxies/mqtt/README.md b/provider_proxies/mqtt/README.md index bba87d14..792a1685 100644 --- a/provider_proxies/mqtt/README.md +++ b/provider_proxies/mqtt/README.md @@ -8,7 +8,7 @@ This proxy supports the following configuration settings: - `keep_alive_interval_s`: The keep alive interval for MQTT communications, in seconds -This adapter supports [config overrides](../../../docs/config-overrides.md). The override filename is `mqtt_proxy_config.json`, and the default config is located at `res/mqtt_proxy_config.default.json`. +This adapter supports [config overrides](../../docs/config-overrides.md). The override filename is `mqtt_proxy_config.json`, and the default config is located at `res/mqtt_proxy_config.default.json`. ## Integrating with this Proxy diff --git a/provider_proxies/mqtt/src/mqtt_provider_proxy.rs b/provider_proxies/mqtt/src/mqtt_provider_proxy.rs index c999212e..97ef917e 100644 --- a/provider_proxies/mqtt/src/mqtt_provider_proxy.rs +++ b/provider_proxies/mqtt/src/mqtt_provider_proxy.rs @@ -24,7 +24,6 @@ const MQTT_CLIENT_ID_PREFIX: &str = "freyja-mqtt-proxy"; /// Interfaces with providers which support GRPC. Based on the Ibeji mixed sample. /// Note that the current implementation works on the assumption that there is a /// one-to-one mapping of topic to entity id. -/// TODO: can this deadlock? pub struct MqttProviderProxy { /// The proxy config config: Config, @@ -112,7 +111,6 @@ impl ProviderProxy for MqttProviderProxy { if let Some(m) = msg { let subsciptions = subscriptions.lock().await; let entity_id = subsciptions.get(m.topic()).unwrap().clone(); - // TODO: additional parsing for value? let value = message_utils::parse_value(m.payload_str().to_string()); signal_values_queue.push(SignalValue { entity_id, value }); } else { diff --git a/provider_proxies/mqtt/src/mqtt_provider_proxy_factory.rs b/provider_proxies/mqtt/src/mqtt_provider_proxy_factory.rs index b3fb6bb5..a11c6bae 100644 --- a/provider_proxies/mqtt/src/mqtt_provider_proxy_factory.rs +++ b/provider_proxies/mqtt/src/mqtt_provider_proxy_factory.rs @@ -18,7 +18,7 @@ pub struct MqttProviderProxyFactory {} impl ProviderProxyFactory for MqttProviderProxyFactory { /// Create a new `GRPCProviderProxyFactory` fn new() -> Self { - Self { } + Self {} } /// Check to see whether this factory can create a proxy for the requested entity. diff --git a/provider_proxy_selector/src/provider_proxy_selector_impl.rs b/provider_proxy_selector/src/provider_proxy_selector_impl.rs index d0cb9cec..e095e0a2 100644 --- a/provider_proxy_selector/src/provider_proxy_selector_impl.rs +++ b/provider_proxy_selector/src/provider_proxy_selector_impl.rs @@ -62,7 +62,9 @@ impl ProviderProxySelectorImpl { #[async_trait] impl ProviderProxySelector for ProviderProxySelectorImpl { /// Registers a `ProviderProxyFactory` with this selector. - fn register(&mut self) -> Result<(), ProviderProxySelectorError> { + fn register( + &mut self, + ) -> Result<(), ProviderProxySelectorError> { self.factories.push(Box::new(TFactory::new()) as _); Ok(()) }