forked from the-distro/ofborg
Make logs routable by the comment filter
This commit is contained in:
parent
32a4397634
commit
c6e629b4ae
3 changed files with 18 additions and 4 deletions
|
@ -10,6 +10,7 @@ pub struct BuildJob {
|
||||||
pub pr: Pr,
|
pub pr: Pr,
|
||||||
pub subset: Option<Subset>,
|
pub subset: Option<Subset>,
|
||||||
pub attrs: Vec<String>,
|
pub attrs: Vec<String>,
|
||||||
|
pub logs: Option<(String, String)>, // (Exchange, Routing Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from(data: &Vec<u8>) -> Result<BuildJob, serde_json::error::Error> {
|
pub fn from(data: &Vec<u8>) -> Result<BuildJob, serde_json::error::Error> {
|
||||||
|
|
|
@ -48,10 +48,14 @@ struct JobActions<'a, 'b> {
|
||||||
job: &'b buildjob::BuildJob,
|
job: &'b buildjob::BuildJob,
|
||||||
line_counter: u64,
|
line_counter: u64,
|
||||||
attempt_id: String,
|
attempt_id: String,
|
||||||
|
log_exchange: String,
|
||||||
|
log_routing_key: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b> JobActions<'a, 'b> {
|
impl<'a, 'b> JobActions<'a, 'b> {
|
||||||
fn new(system: &str, identity: &str, job: &'b buildjob::BuildJob, receiver: &'a mut notifyworker::NotificationReceiver) -> 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 {
|
return JobActions {
|
||||||
system: system.to_owned(),
|
system: system.to_owned(),
|
||||||
identity: identity.to_owned(),
|
identity: identity.to_owned(),
|
||||||
|
@ -59,6 +63,8 @@ impl<'a, 'b> JobActions<'a, 'b> {
|
||||||
job: job,
|
job: job,
|
||||||
line_counter: 0,
|
line_counter: 0,
|
||||||
attempt_id: format!("{}", Uuid::new_v4()),
|
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(),
|
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(
|
self.tell(worker::publish_serde_action(
|
||||||
Some("logs".to_owned()),
|
log_exchange,
|
||||||
Some("build.log".to_owned()),
|
log_routing_key,
|
||||||
&msg
|
&msg
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -115,9 +124,12 @@ impl<'a, 'b> JobActions<'a, 'b> {
|
||||||
output: line.to_owned(),
|
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(
|
self.tell(worker::publish_serde_action(
|
||||||
Some("logs".to_owned()),
|
log_exchange,
|
||||||
Some("build.log".to_owned()),
|
log_routing_key,
|
||||||
&msg
|
&msg
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,7 @@ impl worker::SimpleWorker for GitHubCommentWorker {
|
||||||
pr: pr_msg.clone(),
|
pr: pr_msg.clone(),
|
||||||
subset: Some(subset),
|
subset: Some(subset),
|
||||||
attrs: attrs,
|
attrs: attrs,
|
||||||
|
logs: Some(("logs".to_owned(), "build.log".to_owned()))
|
||||||
};
|
};
|
||||||
|
|
||||||
response.push(worker::publish_serde_action(
|
response.push(worker::publish_serde_action(
|
||||||
|
|
Loading…
Reference in a new issue