From ba03a9e4eaaa9890e53f31496c1be7dd3121936f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=BA=E7=8F=8F?= Date: Tue, 12 Dec 2023 18:25:00 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=F0=9F=8E=A8=20fix=20format=20lint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/datasource/adapters/ds_apollo.rs | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/sentinel-core/src/datasource/adapters/ds_apollo.rs b/sentinel-core/src/datasource/adapters/ds_apollo.rs index 0798d89..13a8817 100644 --- a/sentinel-core/src/datasource/adapters/ds_apollo.rs +++ b/sentinel-core/src/datasource/adapters/ds_apollo.rs @@ -1,11 +1,11 @@ use super::*; use crate::{logging, utils::sleep_for_ms}; use apollo_client::conf::{requests::WatchRequest, ApolloConfClient}; +use futures_util::{future, pin_mut, stream::StreamExt}; use std::sync::{ atomic::{AtomicBool, Ordering}, Arc, }; -use futures_util::{future, pin_mut, stream::StreamExt}; pub struct ApolloDatasource> { ds: DataSourceBase, @@ -16,8 +16,12 @@ pub struct ApolloDatasource> ApolloDatasource { - pub fn new(client: ApolloConfClient, property: String, watch_request: WatchRequest, - handlers: Vec>) -> Self { + pub fn new( + client: ApolloConfClient, + property: String, + watch_request: WatchRequest, + handlers: Vec>, + ) -> Self { let mut ds = DataSourceBase::default(); for h in handlers { ds.add_property_handler(h); @@ -41,8 +45,10 @@ impl> Apol self.property ); - let stream = self.client.watch(self.watch_request.clone()) - .take_while(|_| future::ready(!self.closed.load(Ordering::SeqCst))); + let stream = self + .client + .watch(self.watch_request.clone()) + .take_while(|_| future::ready(!self.closed.load(Ordering::SeqCst))); pin_mut!(stream); @@ -58,11 +64,14 @@ impl> Apol if let Err(e) = self.ds.update(rule) { logging::error!("[Apollo] Failed to update rules, {:?}", e); } - }, - Err(e) => logging::error!("[Apollo] Fail to fetch response from apollo, {:?}", e), + } + Err(e) => logging::error!( + "[Apollo] Fail to fetch response from apollo, {:?}", + e + ), }; } - }, + } // retry Err(e) => { logging::error!("[Apollo] Client yield an error, {:?}", e); @@ -85,9 +94,9 @@ impl> Apol } impl> DataSource -for ApolloDatasource + for ApolloDatasource { fn get_base(&mut self) -> &mut DataSourceBase { &mut self.ds } -} \ No newline at end of file +}