Skip to content

Commit

Permalink
create type ClusterHashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Apr 28, 2023
1 parent ae140f2 commit 2e26e76
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
11 changes: 6 additions & 5 deletions bin/src/command/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use sozu_command_lib::{
logging,
parser::parse_several_commands,
proto::command::{
request::RequestType, AggregatedMetrics, AvailableMetrics, FrontendFilters, ListenersList,
MetricsConfiguration, Request, ResponseStatus, ReturnListenSockets, RunState, SoftStop,
Status, WorkerInfo, WorkerInfos,
request::RequestType, AggregatedMetrics, AvailableMetrics, ClusterHashes, FrontendFilters,
ListenersList, MetricsConfiguration, Request, ResponseStatus, ReturnListenSockets,
RunState, SoftStop, Status, WorkerInfo, WorkerInfos,
},
request::WorkerRequest,
response::{ListedFrontends, Response, ResponseContent},
Expand Down Expand Up @@ -1080,8 +1080,9 @@ impl CommandServer {
let mut main_response_content = None;
match &request.request_type {
Some(RequestType::QueryClustersHashes(_)) => {
main_response_content =
Some(ResponseContent::ClustersHashes(self.state.hash_state()));
main_response_content = Some(ResponseContent::ClustersHashes(ClusterHashes {
map: self.state.hash_state(),
}));
}
Some(RequestType::QueryClusterById(cluster_id)) => {
main_response_content = Some(ResponseContent::Clusters(vec![self
Expand Down
2 changes: 1 addition & 1 deletion bin/src/ctl/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ pub fn print_query_response_data(
for metrics in data.values() {
//let m: u8 = metrics;
if let ResponseContent::ClustersHashes(clusters) = metrics {
for (key, value) in clusters.iter() {
for (key, value) in clusters.map.iter() {
query_data.entry(key).or_insert(Vec::new()).push(value);
}
}
Expand Down
5 changes: 5 additions & 0 deletions command/src/command.proto
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,11 @@ enum EventKind {
REMOVED_BACKEND_HAS_NO_CONNECTIONS = 3;
}

message ClusterHashes {
// cluster id -> hash of cluster information
map<string, uint64> map = 1;
}

enum ResponseStatus {
OK = 0;
PROCESSING = 1;
Expand Down
10 changes: 5 additions & 5 deletions command/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use std::{

use crate::{
proto::command::{
AddBackend, AggregatedMetrics, AvailableMetrics, CertificateSummary, Cluster, Event,
FilteredTimeSerie, ListenersList, LoadBalancingParams, PathRule, PathRuleKind,
RequestHttpFrontend, RequestTcpFrontend, ResponseStatus, RulePosition, RunState,
WorkerInfos, WorkerMetrics,
AddBackend, AggregatedMetrics, AvailableMetrics, CertificateSummary, Cluster,
ClusterHashes, Event, FilteredTimeSerie, ListenersList, LoadBalancingParams, PathRule,
PathRuleKind, RequestHttpFrontend, RequestTcpFrontend, ResponseStatus, RulePosition,
RunState, WorkerInfos, WorkerMetrics,
},
request::PROTOCOL_VERSION,
state::ClusterId,
Expand Down Expand Up @@ -69,7 +69,7 @@ pub enum ResponseContent {

Clusters(Vec<ClusterInformation>),
/// cluster id -> hash of cluster information
ClustersHashes(BTreeMap<String, u64>),
ClustersHashes(ClusterHashes),

/// a list of certificates for each socket address
Certificates(HashMap<SocketAddr, Vec<CertificateSummary>>),
Expand Down
10 changes: 6 additions & 4 deletions lib/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ use sozu_command::{
channel::Channel,
config::Config,
proto::command::{
request::RequestType, ActivateListener, AddBackend, Cluster, DeactivateListener, Event,
HttpListenerConfig, HttpsListenerConfig, ListenerType, LoadBalancingAlgorithms, LoadMetric,
MetricsConfiguration, RemoveBackend, ResponseStatus,
request::RequestType, ActivateListener, AddBackend, Cluster, ClusterHashes,
DeactivateListener, Event, HttpListenerConfig, HttpsListenerConfig, ListenerType,
LoadBalancingAlgorithms, LoadMetric, MetricsConfiguration, RemoveBackend, ResponseStatus,
TcpListenerConfig as CommandTcpListener,
},
ready::Ready,
Expand Down Expand Up @@ -882,7 +882,9 @@ impl Server {
Some(RequestType::QueryClustersHashes(_)) => {
push_queue(WorkerResponse::ok_with_content(
message.id.clone(),
ResponseContent::ClustersHashes(self.config_state.hash_state()),
ResponseContent::ClustersHashes(ClusterHashes {
map: self.config_state.hash_state(),
}),
));
return;
}
Expand Down

0 comments on commit 2e26e76

Please sign in to comment.