Skip to content

Commit

Permalink
remove useless HttpProxy, HttpsProxy, add TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Apr 5, 2023
1 parent d12920e commit 4472332
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
1 change: 1 addition & 0 deletions command/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ impl ListenerBuilder {
.parse_public_address()
.with_context(|| "wrong public address")?;

// TODO: make sure the timeouts are passed from the builder, not the case here
let configuration = HttpListenerConfig {
address: self.address.clone(),
public_address: self.public_address.clone(),
Expand Down
5 changes: 1 addition & 4 deletions command/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@ pub struct ProxyDestinations {
pub to_tcp_proxy: bool,
}

pub fn default_sticky_name() -> String {
String::from("SOZUBALANCEID")
}

impl RequestHttpFrontend {
/// convert a requested frontend to a usable one by parsing its address
pub fn to_frontend(self) -> anyhow::Result<HttpFrontend> {
Expand Down Expand Up @@ -287,6 +283,7 @@ impl FromStr for LoadBalancingAlgorithms {
}
}


pub fn is_false(b: &bool) -> bool {
!*b
}
Expand Down
4 changes: 4 additions & 0 deletions command/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ pub enum ResponseContent {
CertificateByFingerprint(Option<(String, Vec<String>)>),
}

// TODO: the types HttpFrontend, TcpFrontend and Backend are not present,
// and not meant to be present in proto::command. Find a fix, like using the type HttpRequestFrontend
#[derive(Default, Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ClusterInformation {
pub configuration: Option<Cluster>,
Expand Down Expand Up @@ -228,6 +230,7 @@ impl Into<RequestTcpFrontend> for TcpFrontend {
}
}

// TODO: should contain HttpFrontendConfig and TcpFrontendConfig, or types written in protobuf
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
pub struct ListedFrontends {
pub http_frontends: Vec<HttpFrontend>,
Expand Down Expand Up @@ -291,6 +294,7 @@ impl fmt::Display for RunState {
}
}

// TODO: remove the SocketAddr type
/// a backend event that happened on a proxy
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(tag = "type", content = "data", rename_all = "SCREAMING_SNAKE_CASE")]
Expand Down
18 changes: 3 additions & 15 deletions command/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,8 @@ use crate::{
/// To use throughout Sōzu
pub type ClusterId = String;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct HttpProxy {
address: SocketAddr,
fronts: HashMap<ClusterId, Vec<HttpFrontend>>,
backends: HashMap<ClusterId, Vec<Backend>>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct HttpsProxy {
address: SocketAddr,
certificates: HashMap<Fingerprint, CertificateAndKey>,
fronts: HashMap<ClusterId, Vec<HttpFrontend>>,
backends: HashMap<ClusterId, Vec<Backend>>,
}

// TODO: HttpFrontend and TcpFrontend and Backend are not present or meant to be
// translated in protobuf, find a fix
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ConfigState {
pub clusters: BTreeMap<ClusterId, Cluster>,
Expand All @@ -53,6 +40,7 @@ pub struct ConfigState {
/// indexed by (address, hostname, path)
pub https_fronts: BTreeMap<String, HttpFrontend>,
pub tcp_fronts: HashMap<ClusterId, Vec<TcpFrontend>>,
// TODO: create an intermediate type to remove the nested maps
/// certificate and names
pub certificates: HashMap<SocketAddr, HashMap<Fingerprint, CertificateAndKey>>,
}
Expand Down

0 comments on commit 4472332

Please sign in to comment.