Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
hubertshelley committed Jun 26, 2023
1 parent 8400c81 commit c8bbab5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
28 changes: 14 additions & 14 deletions clients/luoshu_rust_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ impl LuoshuClient {
self.name.clone(),
Service::new("127.0.0.1".to_string(), self.port),
)
.into(),
.into(),
)
.into();
.into();
self.connection.write_frame(&frame).await?;
let time_sleep = || async {
tokio::time::sleep(Duration::from_secs(5)).await;
Expand Down Expand Up @@ -142,9 +142,9 @@ impl LuoshuClient {
callback: F,
namespace: Option<String>,
) -> LuoshuClientResult<()>
where
F: Fn(C) + Send + 'static,
C: Serialize + for<'a> Deserialize<'a>,
where
F: Fn(C) + Send + 'static,
C: Serialize + for<'a> Deserialize<'a>,
{
let subscribe = Subscribe::new(namespace.unwrap_or_else(|| String::from("default")), name);
let subscribe_str = subscribe.to_string();
Expand Down Expand Up @@ -183,9 +183,9 @@ impl LuoshuClient {
callback: F,
namespace: Option<String>,
) -> LuoshuClientResult<()>
where
F: Fn(C) + Send + 'static,
C: Serialize + for<'a> Deserialize<'a>,
where
F: Fn(C) + Send + 'static,
C: Serialize + for<'a> Deserialize<'a>,
{
let namespace = namespace.unwrap_or_else(|| String::from("default"));
self.connection
Expand All @@ -196,9 +196,9 @@ impl LuoshuClient {
name.clone(),
serde_json::from_slice(&serde_json::to_vec(&config)?)?,
)
.into(),
)
.into(),
)
.into(),
)
.await?;
self.subscribe_config(name, callback, Some(namespace)).await
Expand All @@ -211,8 +211,8 @@ impl LuoshuClient {
config: C,
namespace: Option<String>,
) -> LuoshuClientResult<()>
where
C: Serialize + for<'a> Deserialize<'a>,
where
C: Serialize + for<'a> Deserialize<'a>,
{
let namespace = namespace.unwrap_or_else(|| String::from("default"));
self.connection
Expand All @@ -223,9 +223,9 @@ impl LuoshuClient {
name,
serde_json::from_slice(&serde_json::to_vec(&config)?)?,
)
.into(),
)
.into(),
)
.into(),
)
.await
.map_err(|e| e.into())
Expand Down
31 changes: 16 additions & 15 deletions luoshu/src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ mod resp;
mod service;

use async_trait::async_trait;
use salvo::prelude::{TcpListener};
use salvo::prelude::TcpListener;
use salvo::serve_static::StaticDir;
use salvo::{Depot, FlowCtrl, Handler, Request, Response, Router, Server};
use std::sync::Arc;
use salvo::serve_static::StaticDir;
use tokio::sync::RwLock;

use crate::data::LuoshuSledData;
Expand All @@ -20,19 +20,20 @@ use service::get_routers as get_service_routers;
pub async fn run_server(addr: &str, data: Arc<RwLock<LuoshuSledData>>) {
let set_store = SetStore(data);

let router = Router::with_hoop(set_store).push(
Router::with_path("api")
.push(get_service_routers())
.push(get_namespace_routers())
.push(get_configuration_routers())
)
.push(Router::with_path("<**path>").get(
StaticDir::new([
"luoshu-frontend/dist",
])
.with_defaults("index.html")
.with_listing(true),
));
let router = Router::with_hoop(set_store)
.push(
Router::with_path("api")
.push(get_service_routers())
.push(get_namespace_routers())
.push(get_configuration_routers()),
)
.push(
Router::with_path("<**path>").get(
StaticDir::new(["luoshu-frontend/dist"])
.with_defaults("index.html")
.with_listing(true),
),
);

tracing::info!("admin listening on: http://{}", addr);

Expand Down

0 comments on commit c8bbab5

Please sign in to comment.