forked from the-distro/ofborg
Actually collect metadata in the log collector...
This commit is contained in:
parent
10ecd201b3
commit
2ad0edc741
|
@ -158,20 +158,30 @@ impl worker::SimpleWorker for LogMessageCollector {
|
||||||
body: &Vec<u8>,
|
body: &Vec<u8>,
|
||||||
) -> Result<Self::J, String> {
|
) -> Result<Self::J, String> {
|
||||||
|
|
||||||
let decode = serde_json::from_slice(body);
|
let message: Either<BuildLogStart, BuildLogMsg>;
|
||||||
if let Err(e) = decode {
|
let attempt_id: String;
|
||||||
return Err(format!("failed to decode job: {:?}", e));
|
|
||||||
|
let decode_msg: Result<BuildLogMsg, _> = serde_json::from_slice(body);
|
||||||
|
if let Ok(msg) = decode_msg {
|
||||||
|
attempt_id = msg.attempt_id.clone();
|
||||||
|
message = Right(msg);
|
||||||
|
} else {
|
||||||
|
let decode_msg: Result<BuildLogStart, _> = serde_json::from_slice(body);
|
||||||
|
if let Ok(msg) = decode_msg {
|
||||||
|
attempt_id = msg.attempt_id.clone();
|
||||||
|
message = Left(msg);
|
||||||
|
} else {
|
||||||
|
return Err(format!("failed to decode job: {:?}", decode_msg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let message: BuildLogMsg = decode.unwrap();
|
return Ok(LogMessage {
|
||||||
|
|
||||||
Ok(LogMessage {
|
|
||||||
from: LogFrom {
|
from: LogFrom {
|
||||||
routing_key: deliver.routing_key.clone(),
|
routing_key: deliver.routing_key.clone(),
|
||||||
attempt_id: message.attempt_id.clone(),
|
attempt_id: attempt_id,
|
||||||
},
|
},
|
||||||
message: Right(message),
|
message: message
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn consumer(&mut self, job: &LogMessage) -> worker::Actions {
|
fn consumer(&mut self, job: &LogMessage) -> worker::Actions {
|
||||||
|
|
Loading…
Reference in a new issue