Skip to content

Commit

Permalink
refactor how balancer context is initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
dyc3 committed Dec 23, 2023
1 parent 534f31d commit 2b3631d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions crates/ott-balancer/src/balancer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,21 @@ pub struct BalancerContext {
pub monoliths_by_region: HashMap<String, Vec<MonolithId>>,
}

impl BalancerContext {
pub fn new() -> Self {
impl Default for BalancerContext {
fn default() -> Self {
Self {
clients: HashMap::new(),
monoliths: HashMap::new(),
rooms_to_monoliths: HashMap::new(),
monoliths_by_region: HashMap::new(),
clients: Default::default(),
monoliths: Default::default(),
rooms_to_monoliths: Default::default(),
monoliths_by_region: Default::default(),
}
}
}

impl BalancerContext {
pub fn new() -> Self {
Default::default()
}

#[instrument(skip(self, client), err, fields(client_id = %client.id, room = %client.room))]
pub async fn add_client(
Expand Down

0 comments on commit 2b3631d

Please sign in to comment.