Skip to content

Commit

Permalink
mvp Message::ConfigFile processing
Browse files Browse the repository at this point in the history
  • Loading branch information
fnichol committed Mar 22, 2016
1 parent 41adce7 commit 3399ec8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 3 additions & 3 deletions components/bldr/src/config_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ impl fmt::Display for ServiceGroup {
/// The config file struct.
#[derive(Clone, Debug, Eq, RustcDecodable, RustcEncodable)]
pub struct ConfigFile {
service_group: ServiceGroup,
file_name: String,
pub service_group: ServiceGroup,
pub file_name: String,
body: Vec<u8>,
checksum: String,
version_number: u64,
Expand Down Expand Up @@ -164,7 +164,7 @@ impl ConfigFileList {
}
}

pub fn process(&mut self, mut remote_cf: ConfigFile) -> bool {
pub fn process(&mut self, remote_cf: ConfigFile) -> bool {
if let Some(mut current_cf) = self.get_mut(&remote_cf.service_group, &remote_cf.file_name) {
return current_cf.update_via(remote_cf);
}
Expand Down
16 changes: 16 additions & 0 deletions components/bldr/src/gossip/rumor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,22 @@ impl RumorList {
}
}

pub fn prune_config_files_for(&mut self, config_file: &ConfigFile) {
let mut prune_list: Vec<RumorId> = Vec::new();
for (rid, rumor) in self.rumors.iter() {
if let Message::ConfigFile(ref cf) = rumor.payload {
if config_file.service_group == cf.service_group &&
config_file.file_name == cf.file_name {
prune_list.push(rid.clone());
}
}
}
for rid in prune_list.iter() {
self.rumors.remove(&rid);
}
}


pub fn remove_rumor(&mut self, rumor_id: &RumorId) {
self.rumors.remove(rumor_id);
for (_member, mut rumor_map) in self.heat.iter_mut() {
Expand Down
3 changes: 2 additions & 1 deletion components/bldr/src/gossip/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ pub fn process_rumors(remote_rumors: RumorList,
};
if processed {
let mut rl = rumor_list.write().unwrap();
// TODO: something magical and amazing happens here
rl.prune_config_files_for(&config_file);
rl.add_rumor(Rumor::config_file(config_file));
}
}
Message::Blank => {}
Expand Down

1 comment on commit 3399ec8

@chef-delivery
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.