Make logs routable by the comment filter

This commit is contained in:
Graham Christensen 2018-01-20 12:12:58 -05:00
parent 32a4397634
commit c6e629b4ae
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
3 changed files with 18 additions and 4 deletions

View file

@ -10,6 +10,7 @@ pub struct BuildJob {
pub pr: Pr,
pub subset: Option<Subset>,
pub attrs: Vec<String>,
pub logs: Option<(String, String)>, // (Exchange, Routing Key)
}
pub fn from(data: &Vec<u8>) -> Result<BuildJob, serde_json::error::Error> {

View file

@ -48,10 +48,14 @@ struct JobActions<'a, 'b> {
job: &'b buildjob::BuildJob,
line_counter: u64,
attempt_id: String,
log_exchange: String,
log_routing_key: String,
}
impl<'a, 'b> JobActions<'a, 'b> {
fn new(system: &str, identity: &str, job: &'b buildjob::BuildJob, receiver: &'a mut notifyworker::NotificationReceiver) -> JobActions<'a, 'b> {
let (log_exchange, log_routing_key) = job.logs.clone().unwrap_or((String::from("logs"), String::from("build.log")));
return JobActions {
system: system.to_owned(),
identity: identity.to_owned(),
@ -59,6 +63,8 @@ impl<'a, 'b> JobActions<'a, 'b> {
job: job,
line_counter: 0,
attempt_id: format!("{}", Uuid::new_v4()),
log_exchange: log_exchange,
log_routing_key: log_routing_key,
};
}
@ -97,9 +103,12 @@ impl<'a, 'b> JobActions<'a, 'b> {
attempt_id: self.attempt_id.clone(),
};
let log_exchange = Some(self.log_exchange.clone());
let log_routing_key = Some(self.log_routing_key.clone());
self.tell(worker::publish_serde_action(
Some("logs".to_owned()),
Some("build.log".to_owned()),
log_exchange,
log_routing_key,
&msg
));
}
@ -115,9 +124,12 @@ impl<'a, 'b> JobActions<'a, 'b> {
output: line.to_owned(),
};
let log_exchange = Some(self.log_exchange.clone());
let log_routing_key = Some(self.log_routing_key.clone());
self.tell(worker::publish_serde_action(
Some("logs".to_owned()),
Some("build.log".to_owned()),
log_exchange,
log_routing_key,
&msg
));
}

View file

@ -105,6 +105,7 @@ impl worker::SimpleWorker for GitHubCommentWorker {
pr: pr_msg.clone(),
subset: Some(subset),
attrs: attrs,
logs: Some(("logs".to_owned(), "build.log".to_owned()))
};
response.push(worker::publish_serde_action(