Update Task Heartbeat to include Job_id (#594)

This commit is contained in:
nharper285
2021-02-26 10:36:10 -08:00
committed by GitHub
parent 6a049db3a3
commit 06f45f338c
4 changed files with 10 additions and 3 deletions

View File

@ -47,7 +47,7 @@ impl CommonConfig {
pub async fn init_heartbeat(&self) -> Result<Option<TaskHeartbeatClient>> {
match &self.heartbeat_queue {
Some(url) => {
let hb = init_task_heartbeat(url.clone(), self.task_id).await?;
let hb = init_task_heartbeat(url.clone(), self.task_id, self.job_id).await?;
Ok(Some(hb))
}
None => Ok(None),

View File

@ -26,18 +26,24 @@ struct Heartbeat {
#[derive(Clone)]
pub struct TaskContext {
task_id: Uuid,
job_id: Uuid,
machine_id: Uuid,
machine_name: String,
}
pub type TaskHeartbeatClient = HeartbeatClient<TaskContext, HeartbeatData>;
pub async fn init_task_heartbeat(queue_url: Url, task_id: Uuid) -> Result<TaskHeartbeatClient> {
pub async fn init_task_heartbeat(
queue_url: Url,
task_id: Uuid,
job_id: Uuid,
) -> Result<TaskHeartbeatClient> {
let machine_id = get_machine_id().await?;
let machine_name = get_machine_name().await?;
let hb = HeartbeatClient::init_heartbeat(
TaskContext {
task_id,
job_id,
machine_id,
machine_name,
},