Skip to content

Commit

Permalink
rewrite use statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Apr 13, 2023
1 parent b125338 commit edb6863
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 63 deletions.
4 changes: 2 additions & 2 deletions bin/src/acme.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::BTreeMap, fs::File, io::Write, iter, net::SocketAddr, thread, time};
use std::{fs::File, io::Write, iter, net::SocketAddr, thread, time};

use acme_lib::{create_p384_key, persist::FilePersist, Directory, DirectoryUrl};
use anyhow::{bail, Context};
Expand All @@ -12,7 +12,7 @@ use sozu_command_lib::{
config::Config,
proto::command::{
AddBackend, AddCertificate, CertificateAndKey, PathRule, RemoveBackend, ReplaceCertificate,
RequestHttpFrontend, RulePosition, TlsVersion,
RequestHttpFrontend, TlsVersion,
},
request::Request,
response::{Response, ResponseStatus},
Expand Down
3 changes: 1 addition & 2 deletions bin/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use sozu_command_lib::{
channel::Channel,
config::Config,
logging::target_to_backend,
proto::command::{RunState, WorkerInfo},
ready::Ready,
request::{Request, WorkerRequest},
response::WorkerResponse,
Expand All @@ -47,8 +48,6 @@ use sozu_command_lib::{

use crate::{logging, util};

use sozu_command_lib::proto::command::{RunState, WorkerInfo};

/// An instance of Sōzu, as seen from the main process
pub struct Worker {
pub id: u32,
Expand Down
2 changes: 1 addition & 1 deletion command/src/proto/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub mod command;
pub mod command;
12 changes: 7 additions & 5 deletions command/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,14 @@ mod tests {
use std::collections::BTreeMap;

use super::*;
use crate::certificate::split_certificate_chain;
use crate::proto::command::{
CertificateAndKey, LoadBalancingParams, PathRule, ProxyProtocolConfig, RulePosition,
TlsVersion,
use crate::{
certificate::split_certificate_chain,
proto::command::{
CertificateAndKey, LoadBalancingParams, PathRule, ProxyProtocolConfig, RulePosition,
TlsVersion,
},
response::HttpFrontend,
};
use crate::response::HttpFrontend;
use serde_json;

#[test]
Expand Down
4 changes: 2 additions & 2 deletions e2e/src/sozu/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use sozu_command::{
config::{Config, ConfigBuilder, FileConfig},
logging::{Logger, LoggerBackend},
proto::command::{
AddBackend, Cluster, LoadBalancingAlgorithms, LoadBalancingParams, PathRule,
RequestHttpFrontend, RequestTcpFrontend, RulePosition,
AddBackend, Cluster, LoadBalancingParams, PathRule, RequestHttpFrontend,
RequestTcpFrontend, RulePosition,
},
request::{Request, WorkerRequest},
response::WorkerResponse,
Expand Down
5 changes: 2 additions & 3 deletions lib/examples/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ extern crate sozu_lib as sozu;
extern crate sozu_command_lib as sozu_command;
extern crate time;

use std::collections::BTreeMap;
use std::{env, io::stdout, thread};

use anyhow::Context;
use sozu_command::config::ListenerBuilder;

use sozu_command::{
channel::Channel,
config::ListenerBuilder,
logging::{Logger, LoggerBackend},
proto::command::{
AddBackend, AddCertificate, CertificateAndKey, LoadBalancingParams, PathRule,
RequestHttpFrontend, RulePosition,
RequestHttpFrontend,
},
request::{Request, WorkerRequest},
};
Expand Down
2 changes: 1 addition & 1 deletion lib/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use sozu_command::{
request::{Request, WorkerRequest},
response::{HttpFrontend, WorkerResponse},
scm_socket::{Listeners, ScmSocket},
state::ClusterId,
};

use crate::{
Expand All @@ -43,7 +44,6 @@ use super::{
router::Route,
server::{ListenSession, ListenToken, ProxyChannel, Server, SessionManager},
socket::server_bind,
sozu_command::state::ClusterId,
AcceptError, Protocol, ProxyConfiguration, ProxySession, Readiness, SessionMetrics,
StateResult,
};
Expand Down
7 changes: 3 additions & 4 deletions lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,14 @@ use std::{
use anyhow::{bail, Context};
use mio::{net::TcpStream, Interest, Token};
use protocol::http::parser::Method;
use sozu_command::state::ClusterId;
use time::{Duration, Instant};

use crate::sozu_command::{
use sozu_command::{
proto::command::{Cluster, LoadBalancingParams},
ready::Ready,
request::WorkerRequest,
response::{Event, WorkerResponse},
state::ClusterId,
};
use time::{Duration, Instant};

use self::{backends::BackendMap, retry::RetryPolicy, router::Route};

Expand Down
3 changes: 1 addition & 2 deletions lib/src/load_balancing.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::fmt::Debug;
use std::{cell::RefCell, rc::Rc};
use std::{cell::RefCell, fmt::Debug, rc::Rc};

use rand::{
distributions::{Distribution, WeightedIndex},
Expand Down
10 changes: 4 additions & 6 deletions lib/src/metrics/local_drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ use std::{collections::BTreeMap, str, time::Instant};
use anyhow::Context;
use hdrhistogram::Histogram;
use sozu_command::{
proto::command::{filtered_metrics, AvailableMetrics, BackendMetrics},
proto::command::{
filtered_metrics, AvailableMetrics, BackendMetrics, ClusterMetrics, FilteredMetrics,
MetricsConfiguration, Percentiles, QueryMetricsOptions, WorkerMetrics,
},
response::ResponseContent,
};

use crate::sozu_command::proto::command::{
ClusterMetrics, FilteredMetrics, MetricsConfiguration, Percentiles, QueryMetricsOptions,
WorkerMetrics,
};

use super::{MetricData, Subscriber};

/// This is how the metrics are stored in the local drain
Expand Down
7 changes: 3 additions & 4 deletions lib/src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ use std::{

use anyhow::Context;
use mio::net::UdpSocket;
use sozu_command::response::ResponseContent;

use crate::sozu_command::proto::command::{
FilteredMetrics, MetricsConfiguration, QueryMetricsOptions,
use sozu_command::{
proto::command::{FilteredMetrics, MetricsConfiguration, QueryMetricsOptions},
response::ResponseContent,
};

use self::{local_drain::LocalDrain, network_drain::NetworkDrain};
Expand Down
4 changes: 2 additions & 2 deletions lib/src/protocol/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use crate::{
timer::TimeoutContainer,
util::UnwrapLog,
Backend, BackendConnectAction, BackendConnectionStatus, L7ListenerHandler, L7Proxy,
ListenerHandler, LogDuration, ProxySession, SessionIsToBeClosed,
{Protocol, Readiness, SessionMetrics, StateResult},
ListenerHandler, LogDuration, Protocol, ProxySession, Readiness, SessionIsToBeClosed,
SessionMetrics, StateResult,
};

use self::parser::{
Expand Down
14 changes: 7 additions & 7 deletions lib/src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ pub mod pipe;
pub mod proxy_protocol;
pub mod rustls;

use std::cell::RefCell;
use std::rc::Rc;
use std::{cell::RefCell, rc::Rc};

use mio::Token;
use sozu_command::ready::Ready;
Expand All @@ -66,11 +65,12 @@ use crate::{
L7Proxy, ProxySession, SessionIsToBeClosed, SessionMetrics, SessionResult, StateResult,
};

pub use self::http::{Http, StickySession};
pub use self::pipe::Pipe;
pub use self::proxy_protocol::send::SendProxyProtocol;

pub use self::rustls::TlsHandshake;
pub use self::{
http::{Http, StickySession},
pipe::Pipe,
proxy_protocol::send::SendProxyProtocol,
rustls::TlsHandshake,
};

/// All States should satisfy this trait in order to receive and handle Session events
pub trait SessionState {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/protocol/proxy_protocol/expect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ mod expect_test {
use super::*;
use mio::net::TcpListener;
use rusty_ulid::Ulid;
use std::io::Write;
use std::net::TcpStream as StdTcpStream;
use std::{
io::Write,
net::TcpStream as StdTcpStream,
net::{IpAddr, Ipv4Addr, SocketAddr},
sync::{Arc, Barrier},
thread::{self, JoinHandle},
Expand Down
6 changes: 4 additions & 2 deletions lib/src/protocol/proxy_protocol/parser.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::convert::From;
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6};
use std::{
convert::From,
net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6},
};

use nom::{
bytes::streaming::{tag, take},
Expand Down
19 changes: 10 additions & 9 deletions lib/src/splice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,16 @@ pub fn splice_out(pipe: Pipe, stream: &dyn AsRawFd) -> Option<usize> {
mod tests {
use super::*;
use libc::c_int;
use std::io::{Error, Read, Write};
use std::net::SocketAddr;
use std::net::{TcpListener, TcpStream};
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::ptr;
use std::str;
use std::str::FromStr;
use std::sync::{Arc, Barrier};
use std::thread;
use std::{
io::{Error, Read, Write},
net::SocketAddr,
net::{TcpListener, TcpStream},
os::unix::io::{AsRawFd, FromRawFd},
ptr, str,
str::FromStr,
sync::{Arc, Barrier},
thread,
};

#[test]
fn zerocopy() {
Expand Down
20 changes: 11 additions & 9 deletions lib/src/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1625,15 +1625,17 @@ pub fn start_tcp_worker(
#[cfg(test)]
mod tests {
use super::*;
use crate::sozu_command::channel::Channel;
use crate::sozu_command::proto::command::LoadBalancingParams;
use crate::sozu_command::scm_socket::Listeners;
use std::io::{Read, Write};
use std::net::{Shutdown, TcpListener, TcpStream};
use std::os::unix::io::IntoRawFd;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Barrier};
use std::{str, thread};
use crate::sozu_command::{
channel::Channel, proto::command::LoadBalancingParams, scm_socket::Listeners,
};
use std::{
io::{Read, Write},
net::{Shutdown, TcpListener, TcpStream},
os::unix::io::IntoRawFd,
sync::atomic::{AtomicBool, Ordering},
sync::{Arc, Barrier},
{str, thread},
};
static TEST_FINISHED: AtomicBool = AtomicBool::new(false);

/*
Expand Down

0 comments on commit edb6863

Please sign in to comment.