Skip to content

Commit

Permalink
isolate method ConfigState::list_listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed May 19, 2023
1 parent c85f65f commit 9085a20
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
15 changes: 6 additions & 9 deletions bin/src/command/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use sozu_command_lib::{
parser::parse_several_commands,
proto::command::{
request::RequestType, response_content::ContentType, AggregatedMetrics, AvailableMetrics,
ClusterHashes, ClusterInformations, FrontendFilters, ListenersList,
MetricsConfiguration, Request, Response, ResponseContent, ResponseStatus,
ReturnListenSockets, RunState, SoftStop, Status, WorkerInfo, WorkerInfos, WorkerResponses,
ClusterHashes, ClusterInformations, FrontendFilters, MetricsConfiguration, Request,
Response, ResponseContent, ResponseStatus, ReturnListenSockets, RunState, SoftStop, Status,
WorkerInfo, WorkerInfos, WorkerResponses,
},
request::WorkerRequest,
scm_socket::Listeners,
Expand Down Expand Up @@ -346,13 +346,10 @@ impl CommandServer {
}

fn list_listeners(&self) -> anyhow::Result<Option<Success>> {
let listeners_list = self.state.list_listeners();

Ok(Some(Success::ListListeners(
ContentType::ListenersList(ListenersList {
http_listeners: self.state.http_listeners.clone(),
https_listeners: self.state.https_listeners.clone(),
tcp_listeners: self.state.tcp_listeners.clone(),
})
.into(),
ContentType::ListenersList(listeners_list).into(),
)))
}

Expand Down
12 changes: 10 additions & 2 deletions command/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use crate::{
proto::command::{
request::RequestType, ActivateListener, AddBackend, AddCertificate, CertificateAndKey,
CertificateWithNames, Cluster, ClusterInformation, DeactivateListener, FrontendFilters,
HttpListenerConfig, HttpsListenerConfig, ListedFrontends, ListenerType, PathRule,
RemoveBackend, RemoveCertificate, RemoveListener, ReplaceCertificate, Request,
HttpListenerConfig, HttpsListenerConfig, ListedFrontends, ListenerType, ListenersList,
PathRule, RemoveBackend, RemoveCertificate, RemoveListener, ReplaceCertificate, Request,
RequestHttpFrontend, RequestTcpFrontend, TcpListenerConfig,
},
response::{Backend, HttpFrontend, TcpFrontend},
Expand Down Expand Up @@ -1281,6 +1281,14 @@ impl ConfigState {

listed_frontends
}

pub fn list_listeners(&self) -> ListenersList {
ListenersList {
http_listeners: self.http_listeners.clone(),
https_listeners: self.https_listeners.clone(),
tcp_listeners: self.tcp_listeners.clone(),
}
}
}

fn domain_check(
Expand Down

0 comments on commit 9085a20

Please sign in to comment.