Skip to content

Commit

Permalink
Merge branch 'main' into chore/gen-to-md1
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddOnTop committed Aug 26, 2024
2 parents ecf07e4 + 452648e commit 379315e
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 109 deletions.
2 changes: 0 additions & 2 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod command;
mod error;
mod fmt;
pub mod generator;
#[cfg(feature = "js")]
Expand All @@ -11,5 +10,4 @@ pub mod server;
mod tc;
pub mod telemetry;
pub(crate) mod update_checker;
pub use error::CLIError;
pub use tc::run::run;
7 changes: 3 additions & 4 deletions src/cli/runtime/file.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use tokio::io::{AsyncReadExt, AsyncWriteExt};

use crate::cli::CLIError;
use crate::core::FileIO;
use crate::core::{Errata, FileIO};

#[derive(Clone)]
pub struct NativeFileIO {}
Expand Down Expand Up @@ -29,7 +28,7 @@ async fn write<'a>(path: &'a str, content: &'a [u8]) -> anyhow::Result<()> {
impl FileIO for NativeFileIO {
async fn write<'a>(&'a self, path: &'a str, content: &'a [u8]) -> anyhow::Result<()> {
write(path, content).await.map_err(|err| {
CLIError::new(format!("Failed to write file: {}", path).as_str())
Errata::new(format!("Failed to write file: {}", path).as_str())
.description(err.to_string())
})?;
tracing::info!("File write: {} ... ok", path);
Expand All @@ -38,7 +37,7 @@ impl FileIO for NativeFileIO {

async fn read<'a>(&'a self, path: &'a str) -> anyhow::Result<String> {
let content = read(path).await.map_err(|err| {
CLIError::new(format!("Failed to read file: {}", path).as_str())
Errata::new(format!("Failed to read file: {}", path).as_str())
.description(err.to_string())
})?;
tracing::info!("File read: {} ... ok", path);
Expand Down
6 changes: 3 additions & 3 deletions src/cli/server/http_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use hyper::service::{make_service_fn, service_fn};
use tokio::sync::oneshot;

use super::server_config::ServerConfig;
use crate::cli::CLIError;
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,7 +31,7 @@ pub async fn start_http_1(
}
});
let builder = hyper::Server::try_bind(&addr)
.map_err(CLIError::from)?
.map_err(Errata::from)?
.http1_pipeline_flush(sc.app_ctx.blueprint.server.pipeline_flush);
super::log_launch(sc.as_ref());

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

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

Ok(result?)
}
4 changes: 2 additions & 2 deletions src/cli/server/http_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use rustls_pki_types::{CertificateDer, PrivateKeyDer};
use tokio::sync::oneshot;

use super::server_config::ServerConfig;
use crate::cli::CLIError;
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 +60,7 @@ pub async fn start_http_2(
builder.serve(make_svc_single_req).await
};

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

Ok(result?)
}
4 changes: 2 additions & 2 deletions src/cli/server/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use super::http_1::start_http_1;
use super::http_2::start_http_2;
use super::server_config::ServerConfig;
use crate::cli::telemetry::init_opentelemetry;
use crate::cli::CLIError;
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 +32,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(CLIError::from)?;
let blueprint = Blueprint::try_from(&self.config_module).map_err(Errata::from)?;
let endpoints = self.config_module.extensions().endpoint_set.clone();
let server_config = Arc::new(ServerConfig::new(blueprint.clone(), endpoints).await?);

Expand Down
4 changes: 2 additions & 2 deletions src/cli/tc/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use anyhow::Result;

use super::helpers::{display_schema, log_endpoint_set};
use crate::cli::fmt::Fmt;
use crate::cli::CLIError;
use crate::core::blueprint::Blueprint;
use crate::core::config::reader::ConfigReader;
use crate::core::config::Source;
use crate::core::runtime::TargetRuntime;
use crate::core::Errata;

pub(super) struct CheckParams {
pub(super) file_paths: Vec<String>,
Expand All @@ -24,7 +24,7 @@ pub(super) async fn check_command(params: CheckParams, config_reader: &ConfigRea
if let Some(format) = format {
Fmt::display(format.encode(&config_module)?);
}
let blueprint = Blueprint::try_from(&config_module).map_err(CLIError::from);
let blueprint = Blueprint::try_from(&config_module).map_err(Errata::from);

match blueprint {
Ok(blueprint) => {
Expand Down
6 changes: 3 additions & 3 deletions src/cli/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::{Layer, Registry};

use super::metrics::init_metrics;
use crate::cli::CLIError;
use crate::core::blueprint::telemetry::{OtlpExporter, Telemetry, TelemetryExporter};
use crate::core::runtime::TargetRuntime;
use crate::core::tracing::{
default_tracing, default_tracing_tailcall, get_log_level, tailcall_filter_target,
};
use crate::core::Errata;

static RESOURCE: Lazy<Resource> = Lazy::new(|| {
Resource::default().merge(&Resource::new(vec![
Expand Down Expand Up @@ -206,8 +206,8 @@ pub fn init_opentelemetry(config: Telemetry, runtime: &TargetRuntime) -> anyhow:
| global::Error::Log(LogError::Other(_)),
) {
tracing::subscriber::with_default(default_tracing_tailcall(), || {
let cli = crate::cli::CLIError::new("Open Telemetry Error")
.caused_by(vec![CLIError::new(error.to_string().as_str())])
let cli = crate::core::Errata::new("Open Telemetry Error")
.caused_by(vec![Errata::new(error.to_string().as_str())])
.trace(vec!["schema".to_string(), "@telemetry".to_string()]);
tracing::error!("{}", cli.color(true));
});
Expand Down
Loading

0 comments on commit 379315e

Please sign in to comment.