Skip to content

Commit

Permalink
fix(command): Code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipponik committed Dec 18, 2024
1 parent eb34415 commit 5354494
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ async fn serve() -> Result<(), Error> {
}

async fn send_resource(url: &str) -> Result<(), Error> {
send_resource::send_resource(url).await.map_err(Error::SendResource)
send_resource::send_resource(url)
.await
.map_err(Error::SendResource)
}

async fn consume(url: &str) -> Result<(), Error> {
rabbitmq_consumer::consume(url).await.map_err(Error::Consume)
rabbitmq_consumer::consume(url)
.await
.map_err(Error::Consume)
}
8 changes: 6 additions & 2 deletions src/send_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ pub enum Error {

pub async fn send_resource(url: &str) -> Result<(), Error> {
let resource_vec: Vec<Value> =
serde_json::from_str(MANGALIB_STATIC_RESOURCE).map_err(|err| Error::Parse(err))?;
serde_json::from_str(MANGALIB_STATIC_RESOURCE).map_err(Error::Parse)?;

let mut handlers = Vec::new();
for res in resource_vec {
let res_cloned = res.clone();
let url_cloned = url.to_string();
let handler = tokio::spawn(async move {
let sending_result = Client::new().post(&url_cloned).json(&res_cloned).send().await;
let sending_result = Client::new()
.post(&url_cloned)
.json(&res_cloned)
.send()
.await;

match sending_result {
Ok(_) => {
Expand Down
8 changes: 6 additions & 2 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ pub async fn serve() -> Result<(), Error> {
.parse::<u16>()
.map_err(|err| Error::Config(ConfigErrorType::ParseInt(err)))?;

let state = AppState { port, chrome_max_count };
let state = AppState {
port,
chrome_max_count,
};
let address = &format!("0.0.0.0:{}", state.port.clone());
let listener = TcpListener::bind(address)
.await
Expand All @@ -49,7 +52,8 @@ pub async fn serve() -> Result<(), Error> {
.fallback(handle_404);

info!("Web server is up: {address}");
axum::serve(listener, router).await
axum::serve(listener, router)
.await
.map_err(Error::ServerError)?;

Ok(())
Expand Down

0 comments on commit 5354494

Please sign in to comment.