Skip to content

Commit

Permalink
Add XDS logic for cluster and endpoints (#112)
Browse files Browse the repository at this point in the history
* Add XDS logic for cluster and endpoints

This adds the logic to processes responses from
the XDS server and sends back acknowlegements according to
the protocol. Implementation to talk to the server
isn't included.

Work on #10

* include xds modules when running doctest
* exclude xds cluster in rustdoc, refactor
  • Loading branch information
iffyio authored Oct 22, 2020
1 parent 76c1ab7 commit f6abd60
Show file tree
Hide file tree
Showing 6 changed files with 1,074 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ authors = ["Mark Mandel <[email protected]>"]
edition = "2018"

[dependencies]
bytes = "0.5.6"
clap = "2.33.0"
humantime-serde = "1.0.0"
prometheus = { version = "0.9", default-features = false }
Expand Down
42 changes: 42 additions & 0 deletions src/cluster.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2020 Google LLC All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

use std::collections::HashMap;
use std::net::SocketAddr;

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Endpoint {
pub address: SocketAddr,
}

#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct Locality {
pub region: String,
pub zone: String,
pub sub_zone: String,
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct LocalityEndpoints {
pub endpoints: Vec<Endpoint>,
}

#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Cluster {
pub localities: HashMap<Option<Locality>, LocalityEndpoints>,
}

pub type ClusterLocalities = HashMap<Option<Locality>, LocalityEndpoints>;
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// nightly compiler. So we enable the feature only when needed.
#![cfg_attr(doctest, feature(external_doc))]

mod cluster;
pub mod config;
pub mod extensions;
mod load_balancer_policy;
Expand Down
Loading

0 comments on commit f6abd60

Please sign in to comment.