Skip to content

Commit

Permalink
removed Errata from enum variants
Browse files Browse the repository at this point in the history
  • Loading branch information
mehulmathur16 committed Jun 15, 2024
1 parent 04aab0c commit 7d9f95b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 27 deletions.
18 changes: 5 additions & 13 deletions src/cli/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use opentelemetry::metrics::MetricsError;
use opentelemetry::trace::TraceError;
use tokio::task::JoinError;

use crate::core::{rest, Errata};
use crate::core::rest;
use crate::core::valid::ValidationError;

#[derive(From, thiserror::Error, Debug)]
pub enum Error {
Expand All @@ -17,9 +18,6 @@ pub enum Error {
#[error("Rest Error")]
Rest(rest::error::Error),

#[error("Errata Error")]
Errata(Errata),

#[error("Serde Json Error")]
SerdeJson(serde_json::Error),

Expand Down Expand Up @@ -94,15 +92,9 @@ pub enum Error {

#[error("Reqwest error")]
Reqwest(reqwest::Error),

#[error("Validation Error : {0}")]
Validation(ValidationError<std::string::String>),
}

pub type Result<A> = std::result::Result<A, Error>;

impl From<rustls::Error> for Errata {
fn from(error: rustls::Error) -> Self {
let cli_error = Errata::new("Failed to create TLS Acceptor");
let message = error.to_string();

cli_error.description(message)
}
}
6 changes: 2 additions & 4 deletions src/cli/server/http_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use super::server_config::ServerConfig;
use crate::cli::{Error, Result};
use crate::core::async_graphql_hyper::{GraphQLBatchRequest, GraphQLRequest};
use crate::core::http::handle_request;
use crate::core::Errata;

pub async fn start_http_1(
sc: Arc<ServerConfig>,
Expand All @@ -31,8 +30,7 @@ pub async fn start_http_1(
}))
}
});
let builder = hyper::Server::try_bind(&addr)
.map_err(Errata::from)?
let builder = hyper::Server::try_bind(&addr)?
.http1_pipeline_flush(sc.app_ctx.blueprint.server.pipeline_flush);
super::log_launch(sc.as_ref());

Expand All @@ -47,7 +45,7 @@ pub async fn start_http_1(
builder.serve(make_svc_single_req).await
};

let result = server.map_err(Errata::from);
let result = server;

Ok(result?)
}
3 changes: 1 addition & 2 deletions src/cli/server/http_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use super::server_config::ServerConfig;
use crate::cli::{Error, Result};
use crate::core::async_graphql_hyper::{GraphQLBatchRequest, GraphQLRequest};
use crate::core::http::handle_request;
use crate::core::Errata;

pub async fn start_http_2(
sc: Arc<ServerConfig>,
Expand Down Expand Up @@ -60,7 +59,7 @@ pub async fn start_http_2(
builder.serve(make_svc_single_req).await
};

let result = server.map_err(Errata::from);
let result = server;

Ok(result?)
}
3 changes: 1 addition & 2 deletions src/cli/server/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::cli::telemetry::init_opentelemetry;
use crate::cli::Result;
use crate::core::blueprint::{Blueprint, Http};
use crate::core::config::ConfigModule;
use crate::core::Errata;

pub struct Server {
config_module: ConfigModule,
Expand All @@ -32,7 +31,7 @@ impl Server {

/// Starts the server in the current Runtime
pub async fn start(self) -> Result<()> {
let blueprint = Blueprint::try_from(&self.config_module).map_err(Errata::from)?;
let blueprint = Blueprint::try_from(&self.config_module)?;
let server_config = Arc::new(
ServerConfig::new(
blueprint.clone(),
Expand Down
4 changes: 2 additions & 2 deletions src/cli/tc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use crate::core::config::reader::ConfigReader;
use crate::core::error::Error;
use crate::core::generator::Generator;
use crate::core::http::API_URL_PREFIX;
use crate::core::print_schema;
use crate::core::rest::{EndpointSet, Unchecked};
use crate::core::{print_schema, Errata};
const FILE_NAME: &str = ".tailcallrc.graphql";
const YML_FILE_NAME: &str = ".graphqlrc.yml";
const JSON_FILE_NAME: &str = ".tailcallrc.schema.json";
Expand Down Expand Up @@ -60,7 +60,7 @@ pub async fn run() -> Result<(), Error> {
if let Some(format) = format {
Fmt::display(format.encode(&config_module)?);
}
let blueprint = Blueprint::try_from(&config_module).map_err(Errata::from);
let blueprint = Blueprint::try_from(&config_module);

match blueprint {
Ok(blueprint) => {
Expand Down
4 changes: 0 additions & 4 deletions src/core/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use super::grpc::error::Error as GrpcError;
use super::rest::error::Error as RestError;
use super::valid::ValidationError;
use crate::cli::error::Error as CLIError;
use crate::core::errata::Errata as ErrataError;

#[derive(From, thiserror::Error, Debug)]
pub enum Error {
Expand Down Expand Up @@ -114,9 +113,6 @@ pub enum Error {

#[error("Inquire Error")]
Inquire(InquireError),

#[error("Errata Error")]
Errata(ErrataError),
}

pub mod file {
Expand Down

1 comment on commit 7d9f95b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running 30s test @ http://localhost:8000/graphql

4 threads and 100 connections

Thread Stats Avg Stdev Max +/- Stdev
Latency 6.63ms 2.97ms 70.69ms 70.75%
Req/Sec 3.81k 191.14 4.08k 92.33%

455145 requests in 30.01s, 2.28GB read

Requests/sec: 15167.50

Transfer/sec: 77.85MB

Please sign in to comment.