Implement pausing section runner from MQTT
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2ad00b4b69
commit
c7941372bf
@ -257,6 +257,7 @@ pub enum Request {
|
|||||||
RunSection(sections::RunSectionRequest),
|
RunSection(sections::RunSectionRequest),
|
||||||
CancelSection(sections::CancelSectionRequest),
|
CancelSection(sections::CancelSectionRequest),
|
||||||
CancelSectionRunId(sections::CancelSectionRunIdRequest),
|
CancelSectionRunId(sections::CancelSectionRunIdRequest),
|
||||||
|
PauseSectionRunner(sections::PauseSectionRunnerRequest),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IRequest for Request {
|
impl IRequest for Request {
|
||||||
@ -267,6 +268,7 @@ impl IRequest for Request {
|
|||||||
Request::RunSection(req) => req.exec_erased(ctx),
|
Request::RunSection(req) => req.exec_erased(ctx),
|
||||||
Request::CancelSection(req) => req.exec_erased(ctx),
|
Request::CancelSection(req) => req.exec_erased(ctx),
|
||||||
Request::CancelSectionRunId(req) => req.exec_erased(ctx),
|
Request::CancelSectionRunId(req) => req.exec_erased(ctx),
|
||||||
|
Request::PauseSectionRunner(req) => req.exec_erased(ctx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,3 +121,39 @@ impl IRequest for CancelSectionRunIdRequest {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct PauseSectionRunnerRequest {
|
||||||
|
pub paused: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct PauseSectionRunnerResponse {
|
||||||
|
pub message: String,
|
||||||
|
pub paused: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IRequest for PauseSectionRunnerRequest {
|
||||||
|
type Response = PauseSectionRunnerResponse;
|
||||||
|
fn exec(&mut self, ctx: &mut RequestContext) -> RequestFuture<Self::Response> {
|
||||||
|
let mut section_runner = ctx.section_runner.clone();
|
||||||
|
let paused = self.paused;
|
||||||
|
Box::pin(async move {
|
||||||
|
if paused {
|
||||||
|
section_runner.pause().await
|
||||||
|
} else {
|
||||||
|
section_runner.unpause().await
|
||||||
|
}
|
||||||
|
.wrap_err("could not pause/unpause section runner")?;
|
||||||
|
Ok(PauseSectionRunnerResponse {
|
||||||
|
message: format!(
|
||||||
|
"{} section runner",
|
||||||
|
if paused { "paused" } else { "unpaused" }
|
||||||
|
),
|
||||||
|
paused,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user