Skip to content

Commit

Permalink
Allow removal of backends from config
Browse files Browse the repository at this point in the history
Signed-off-by: Lee Smet <[email protected]>
  • Loading branch information
LeeSmet committed Mar 15, 2021
1 parent f9d3dfa commit b53dca6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::{encryption::SymmetricKey, zdb::ZdbConnectionInfo};
use gray_codes::{InclusionExclusion, SetMutation};
use rand::seq::SliceRandom;
use serde::{Deserialize, Serialize};
use std::net::SocketAddr;

/// The full configuration for the data encoding and decoding. This included the etcd to save the
/// data to, as well as all backends which may or may not be used when data is written.
Expand Down Expand Up @@ -143,6 +144,18 @@ impl Config {
.collect()
}

/// Remove a shard from the config. If the shard is present multiple times, all instances will
/// be removed.
pub fn remove_shard(&mut self, address: &SocketAddr) {
for mut group in &mut self.groups {
group.backends = group
.backends
.drain(..)
.filter(|backend| backend.address() != address)
.collect();
}
}

/// Returns a list of 0-db's to use for storage of the data shards, in accordance to the
/// encoding profile and redundancy policies. If no valid configuration can be found, an error
/// is returned. If multiple valid configurations are found, one is selected at random.
Expand Down

0 comments on commit b53dca6

Please sign in to comment.