hive-c0re: optional reset-timer on manual fire-now for recurring schedules
This commit is contained in:
parent
513c828ab2
commit
b6aeaf0b57
4 changed files with 89 additions and 17 deletions
|
|
@ -77,19 +77,29 @@ pub(super) async fn post_schedule_new(
|
|||
}
|
||||
}
|
||||
|
||||
/// Optional JSON body for `fire-now`. Absent / empty body ⇒
|
||||
/// `reset_timer = false` (back-compat: cadence stays intact).
|
||||
#[derive(serde::Deserialize, Default)]
|
||||
pub(super) struct FireNowBody {
|
||||
#[serde(default)]
|
||||
reset_timer: bool,
|
||||
}
|
||||
|
||||
/// `POST /api/schedules/{id}/fire-now` — operator-initiated
|
||||
/// out-of-band fire of a scheduled prompt. Runs the
|
||||
/// per-target fan-out once immediately and reports per-target
|
||||
/// outcome counts. Does NOT touch `next_fire_at_unix` on
|
||||
/// recurring schedules (their cadence stays intact); one-shot
|
||||
/// schedules are consumed (cancelled) by a manual fire — the
|
||||
/// operator's intent is "send this now, the scheduled time was
|
||||
/// wrong."
|
||||
/// out-of-band fire of a scheduled prompt. Runs the per-target
|
||||
/// fan-out once immediately and reports per-target outcome counts.
|
||||
/// One-shot schedules are consumed (cancelled) by a manual fire —
|
||||
/// the operator's intent is "send this now, the scheduled time was
|
||||
/// wrong." For recurring schedules the cadence stays intact unless
|
||||
/// the body carries `{"reset_timer": true}`, in which case the
|
||||
/// countdown is re-armed from now (`next_fire_at = now + interval`).
|
||||
pub(super) async fn post_schedule_fire_now(
|
||||
State(state): State<AppState>,
|
||||
AxumPath(id): AxumPath<i64>,
|
||||
body: Option<axum::Json<FireNowBody>>,
|
||||
) -> Response {
|
||||
match crate::scheduled_prompts_worker::fire_now(&state.coord, id).await {
|
||||
let reset_timer = body.is_some_and(|axum::Json(b)| b.reset_timer);
|
||||
match crate::scheduled_prompts_worker::fire_now(&state.coord, id, reset_timer).await {
|
||||
Ok(report) => {
|
||||
state.coord.emit_schedules_snapshot();
|
||||
axum::Json(report).into_response()
|
||||
|
|
|
|||
Loading…
Reference in a new issue