From 04aab0cc2ab92198bb3931158ae561a832cfcacc Mon Sep 17 00:00:00 2001 From: Mehul Mathur Date: Sat, 15 Jun 2024 07:47:56 +0000 Subject: [PATCH] lint --- benches/data_loader_bench.rs | 3 +-- benches/impl_path_string_for_evaluation_context.rs | 3 +-- src/cli/javascript/mod.rs | 4 +--- src/cli/runtime/mod.rs | 9 +-------- src/cli/telemetry.rs | 3 +-- src/core/http/response.rs | 3 +-- src/core/ir/error.rs | 4 +--- src/core/mod.rs | 6 +++++- src/core/runtime.rs | 8 +++++--- tailcall-cloudflare/src/runtime.rs | 5 +---- tests/core/parse.rs | 12 ++++++------ tests/server_spec.rs | 8 +++++--- 12 files changed, 29 insertions(+), 39 deletions(-) diff --git a/benches/data_loader_bench.rs b/benches/data_loader_bench.rs index 1a8c5baff2..5505fa0ff2 100644 --- a/benches/data_loader_bench.rs +++ b/benches/data_loader_bench.rs @@ -10,8 +10,7 @@ use criterion::Criterion; use hyper::body::Bytes; use reqwest::Request; use tailcall::core::config::Batch; -use tailcall::core::error::file; -use tailcall::core::error::http; +use tailcall::core::error::{file, http}; use tailcall::core::http::{DataLoaderRequest, HttpDataLoader, Response}; use tailcall::core::ir::IoId; use tailcall::core::runtime::TargetRuntime; diff --git a/benches/impl_path_string_for_evaluation_context.rs b/benches/impl_path_string_for_evaluation_context.rs index 9ba53a4cf7..552c6f469d 100644 --- a/benches/impl_path_string_for_evaluation_context.rs +++ b/benches/impl_path_string_for_evaluation_context.rs @@ -17,8 +17,7 @@ use reqwest::{Client, Request}; use reqwest_middleware::{ClientBuilder, ClientWithMiddleware}; use tailcall::core::blueprint::{Server, Upstream}; use tailcall::core::cache::InMemoryCache; -use tailcall::core::error::file; -use tailcall::core::error::http; +use tailcall::core::error::{file, http}; use tailcall::core::http::{RequestContext, Response}; use tailcall::core::ir::{EvaluationContext, ResolverContextLike}; use tailcall::core::path::PathString; diff --git a/src/cli/javascript/mod.rs b/src/cli/javascript/mod.rs index eb21da2e99..11559b2487 100644 --- a/src/cli/javascript/mod.rs +++ b/src/cli/javascript/mod.rs @@ -12,9 +12,7 @@ pub use runtime::Runtime; use crate::cli::Result; use crate::core::{blueprint, WorkerIO}; -pub fn init_worker_io( - script: blueprint::Script, -) -> Arc + Send + Sync> +pub fn init_worker_io(script: blueprint::Script) -> Arc + Send + Sync> where Runtime: WorkerIO, { diff --git a/src/cli/runtime/mod.rs b/src/cli/runtime/mod.rs index ba9441cad9..b5e3d59246 100644 --- a/src/cli/runtime/mod.rs +++ b/src/cli/runtime/mod.rs @@ -37,14 +37,7 @@ fn init_http_worker_io( fn init_resolver_worker_io( script: Option, -) -> Option< - Arc< - dyn WorkerIO< - async_graphql::Value, - async_graphql::Value, - >, - >, -> { +) -> Option>> { #[cfg(feature = "js")] return Some(super::javascript::init_worker_io(script?)); #[cfg(not(feature = "js"))] diff --git a/src/cli/telemetry.rs b/src/cli/telemetry.rs index 676112523e..4601b0b5f1 100644 --- a/src/cli/telemetry.rs +++ b/src/cli/telemetry.rs @@ -87,8 +87,7 @@ fn set_trace_provider( .install_batch(runtime::Tokio)? .provider() .ok_or(TraceError::Other( - Error::TelemetryTrace("Failed to instantiate OTLP provider".to_string()) - .into(), + Error::TelemetryTrace("Failed to instantiate OTLP provider".to_string()).into(), ))?, // Prometheus works only with metrics TelemetryExporter::Prometheus(_) => return Ok(None), diff --git a/src/core/http/response.rs b/src/core/http/response.rs index 1d1ad51c0c..95bb119766 100644 --- a/src/core/http/response.rs +++ b/src/core/http/response.rs @@ -7,8 +7,7 @@ use prost::Message; use tonic::Status; use tonic_types::Status as GrpcStatus; -use crate::core::error::http; -use crate::core::error::Error as CoreError; +use crate::core::error::{http, Error as CoreError}; use crate::core::grpc::protobuf::ProtobufOperation; use crate::core::ir::Error; diff --git a/src/core/ir/error.rs b/src/core/ir/error.rs index aadc04f081..c444d817ff 100644 --- a/src/core/ir/error.rs +++ b/src/core/ir/error.rs @@ -4,9 +4,7 @@ use std::sync::Arc; use async_graphql::{ErrorExtensions, Value as ConstValue}; use crate::core::auth; -use crate::core::error::http; -use crate::core::error::worker; -use crate::core::error::Error as CoreError; +use crate::core::error::{http, worker, Error as CoreError}; #[derive(Debug, thiserror::Error, Clone)] pub enum Error { diff --git a/src/core/mod.rs b/src/core/mod.rs index 7b67721e39..82531477de 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -67,7 +67,11 @@ pub trait HttpIO: Sync + Send + 'static { #[async_trait::async_trait] pub trait FileIO: Send + Sync { - async fn write<'a>(&'a self, path: &'a str, content: &'a [u8]) -> Result<(), error::file::Error>; + async fn write<'a>( + &'a self, + path: &'a str, + content: &'a [u8], + ) -> Result<(), error::file::Error>; async fn read<'a>(&'a self, path: &'a str) -> Result; } diff --git a/src/core/runtime.rs b/src/core/runtime.rs index 52a8eec13a..982ed6cd02 100644 --- a/src/core/runtime.rs +++ b/src/core/runtime.rs @@ -31,8 +31,7 @@ pub struct TargetRuntime { /// Worker middleware for handling HTTP requests. pub cmd_worker: Option>>, /// Worker middleware for resolving data. - pub worker: - Option>>, + pub worker: Option>>, } impl TargetRuntime { @@ -151,7 +150,10 @@ pub mod test { Ok(()) } - async fn read<'a>(&'a self, path: &'a str) -> crate::core::Result { + async fn read<'a>( + &'a self, + path: &'a str, + ) -> crate::core::Result { let mut file = tokio::fs::File::open(path).await?; let mut buffer = Vec::new(); file.read_to_end(&mut buffer).await?; diff --git a/tailcall-cloudflare/src/runtime.rs b/tailcall-cloudflare/src/runtime.rs index f05f6a7b5a..a0b84d00bb 100644 --- a/tailcall-cloudflare/src/runtime.rs +++ b/tailcall-cloudflare/src/runtime.rs @@ -13,10 +13,7 @@ fn init_env(env: Rc) -> Arc { Arc::new(env::CloudflareEnv::init(env)) } -fn init_file( - env: Rc, - bucket_id: &str, -) -> anyhow::Result> { +fn init_file(env: Rc, bucket_id: &str) -> anyhow::Result> { Ok(Arc::new(file::CloudflareFileIO::init(env, bucket_id)?)) } diff --git a/tests/core/parse.rs b/tests/core/parse.rs index f88b1cc9df..10fef0528a 100644 --- a/tests/core/parse.rs +++ b/tests/core/parse.rs @@ -284,12 +284,12 @@ impl ExecutionSpec { None }; - let worker: Option>> = - if let Some(script) = script { - Some(javascript::init_worker_io(script)) - } else { - None - }; + let worker: Option>> = if let Some(script) = script + { + Some(javascript::init_worker_io(script)) + } else { + None + }; let runtime = TargetRuntime { http, diff --git a/tests/server_spec.rs b/tests/server_spec.rs index 41479f4efd..e4ea3b2516 100644 --- a/tests/server_spec.rs +++ b/tests/server_spec.rs @@ -15,11 +15,10 @@ pub mod test { use tailcall::core::blueprint::{Script, Upstream}; use tailcall::core::cache::InMemoryCache; use tailcall::core::error::file; - use tailcall::core::error; use tailcall::core::http::Response; use tailcall::core::runtime::TargetRuntime; use tailcall::core::worker::{Command, Event}; - use tailcall::core::{EnvIO, FileIO, HttpIO}; + use tailcall::core::{error, EnvIO, FileIO, HttpIO}; use tailcall_http_cache::HttpCacheManager; use tokio::io::{AsyncReadExt, AsyncWriteExt}; @@ -75,7 +74,10 @@ pub mod test { #[async_trait::async_trait] impl HttpIO for TestHttp { - async fn execute(&self, request: reqwest::Request) -> Result, error::http::Error> { + async fn execute( + &self, + request: reqwest::Request, + ) -> Result, error::http::Error> { let response = self.client.execute(request).await; Response::from_reqwest( response?