Make build workers reply to the job-defined exchange/routing key

This commit is contained in:
Graham Christensen 2018-01-21 17:53:30 -05:00
parent cc62b0cf1c
commit 73ac0527ee
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
3 changed files with 18 additions and 2 deletions

View file

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

View file

@ -62,6 +62,8 @@ struct JobActions<'a, 'b> {
attempt_id: String,
log_exchange: Option<String>,
log_routing_key: Option<String>,
result_exchange: Option<String>,
result_routing_key: Option<String>,
}
impl<'a, 'b> JobActions<'a, 'b> {
@ -76,6 +78,12 @@ impl<'a, 'b> JobActions<'a, 'b> {
Some(String::from("build.log")),
));
let (result_exchange, result_routing_key) =
job.statusreport.clone().unwrap_or((
Some(String::from("build-results")),
None,
));
return JobActions {
system: system.to_owned(),
identity: identity.to_owned(),
@ -85,6 +93,8 @@ impl<'a, 'b> JobActions<'a, 'b> {
attempt_id: format!("{}", Uuid::new_v4()),
log_exchange: log_exchange,
log_routing_key: log_routing_key,
result_exchange: result_exchange,
result_routing_key: result_routing_key,
};
}
@ -106,9 +116,13 @@ impl<'a, 'b> JobActions<'a, 'b> {
success: false,
};
let result_exchange = self.result_exchange.clone();
let result_routing_key = self.result_routing_key.clone();
self.tell(worker::publish_serde_action(
Some("build-results".to_owned()),
None,
result_exchange,
result_routing_key,
&msg,
));
self.tell(worker::Action::Ack);

View file

@ -122,6 +122,7 @@ impl worker::SimpleWorker for GitHubCommentWorker {
subset: Some(subset),
attrs: attrs,
logs: Some((Some("logs".to_owned()), Some(logbackrk.to_lowercase()))),
statusreport: Some((Some("build-results".to_owned()), None)),
};
response.push(worker::publish_serde_action(