Skip to content

Commit

Permalink
Merge branch 'main' into rustls
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai authored Apr 11, 2023
2 parents 97bce8b + 9e4c362 commit 2312cd2
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 55 deletions.
44 changes: 0 additions & 44 deletions shotover/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,47 +1,3 @@
use crate::message::Messages;
use std::{error, fmt};
use thiserror::Error;

#[derive(Error, Clone, Debug)]
pub enum RequestError {
#[error("Invalid header (expected {expected:?}, got {found:?})")]
InvalidHeader { expected: String, found: String },
#[error("Malform Request: {0}")]
MalformedRequest(String),

#[error("Could not process script: {0}")]
ScriptProcessingError(String),

#[error("Could not process chain: {0}")]
ChainProcessingError(String),
}

#[derive(Error, Debug)]
pub struct ConfigError {
pub message: String,
pub source: Option<Box<dyn error::Error + 'static>>,
}

impl ConfigError {
pub fn new(message: &str) -> Self {
ConfigError {
message: String::from(message),
source: None,
}
}

pub fn from(error: Box<dyn error::Error + 'static>) -> Self {
ConfigError {
message: error.to_string(),
source: Some(error),
}
}
}

impl fmt::Display for ConfigError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "An error occured: {:}", self.message)
}
}

pub type ChainResponse = anyhow::Result<Messages>;
6 changes: 3 additions & 3 deletions shotover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
#![deny(clippy::print_stderr)]

pub mod codec;
pub mod config;
mod config;
pub mod error;
pub mod frame;
pub mod message;
pub mod message_value;
mod observability;
pub mod runner;
mod server;
pub mod sources;
mod sources;
pub mod tcp;
pub mod tls;
pub mod tracing_panic_handler;
mod tracing_panic_handler;
pub mod transforms;
2 changes: 1 addition & 1 deletion shotover/src/message_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ pub(crate) fn serialize_with_length_prefix(
.copy_from_slice(&(bytes_len as CInt).to_be_bytes());
}

pub fn serialize_len(cursor: &mut Cursor<&mut Vec<u8>>, len: usize) {
pub(crate) fn serialize_len(cursor: &mut Cursor<&mut Vec<u8>>, len: usize) {
let len = len as CInt;
cursor.write_all(&len.to_be_bytes()).unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion shotover/src/observability/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::{net::SocketAddr, sync::Arc};
use tracing::{error, trace};

/// Exports metrics over HTTP.
pub struct LogFilterHttpExporter {
pub(crate) struct LogFilterHttpExporter {
recorder_handle: PrometheusHandle,
address: SocketAddr,
tracing_handle: ReloadHandle,
Expand Down
10 changes: 5 additions & 5 deletions shotover/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use tracing_subscriber::{EnvFilter, Registry};

#[derive(Parser, Clone)]
#[clap(version = crate_version!(), author = "Instaclustr")]
pub struct ConfigOpts {
struct ConfigOpts {
#[clap(short, long, default_value = "config/topology.yaml")]
pub topology_file: String,

Expand All @@ -48,7 +48,7 @@ pub struct ConfigOpts {
}

#[derive(clap::ValueEnum, Clone, Copy)]
pub enum LogFormat {
enum LogFormat {
Human,
Json,
}
Expand Down Expand Up @@ -190,7 +190,7 @@ impl Shotover {
}
}

pub struct TracingState {
struct TracingState {
/// Once this is dropped tracing logs are ignored
_guard: WorkerGuard,
handle: ReloadHandle,
Expand Down Expand Up @@ -276,7 +276,7 @@ type Formatter<A, B> = Layered<Layer<Registry, A, Format<B>, NonBlocking>, Regis
// * https://github.com/tokio-rs/tracing/pull/1035
// * https://github.com/linkerd/linkerd2-proxy/blob/6c484f6dcdeebda18b68c800b4494263bf98fcdc/linkerd/app/core/src/trace.rs#L19-L36
#[derive(Clone)]
pub enum ReloadHandle {
pub(crate) enum ReloadHandle {
Json(Handle<EnvFilter, Formatter<JsonFields, Json>>),
Human(Handle<EnvFilter, Formatter<DefaultFields, Full>>),
}
Expand All @@ -290,7 +290,7 @@ impl ReloadHandle {
}
}

pub async fn run(
async fn run(
topology: Topology,
config: Config,
trigger_shutdown_rx: watch::Receiver<bool>,
Expand Down
2 changes: 1 addition & 1 deletion shotover/src/transforms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,4 +487,4 @@ pub trait Transform: Send {
fn set_pushed_messages_tx(&mut self, _pushed_messages_tx: mpsc::UnboundedSender<Messages>) {}
}

pub type ResponseFuture = Pin<Box<dyn Future<Output = Result<util::Response>> + Send + Sync>>;
type ResponseFuture = Pin<Box<dyn Future<Output = Result<util::Response>> + Send + Sync>>;

0 comments on commit 2312cd2

Please sign in to comment.