reminder: add sqlite storage + broker methods + dispatch
This commit is contained in:
parent
7e9fd8e978
commit
4fc9c02934
2 changed files with 79 additions and 4 deletions
|
|
@ -193,10 +193,28 @@ async fn dispatch(req: &AgentRequest, agent: &str, coord: &Arc<Coordinator>) ->
|
|||
timing,
|
||||
file_path,
|
||||
} => {
|
||||
// TODO: submit to reminder scheduler
|
||||
// For now, return a stub response
|
||||
AgentResponse::Err {
|
||||
message: "remind not yet implemented".to_owned(),
|
||||
use hive_sh4re::ReminderTiming;
|
||||
let due_at = match timing {
|
||||
ReminderTiming::InSeconds { seconds } => {
|
||||
std::time::SystemTime::now()
|
||||
.checked_add(std::time::Duration::from_secs(*seconds))
|
||||
.and_then(|t| {
|
||||
t.duration_since(std::time::UNIX_EPOCH)
|
||||
.ok()
|
||||
.and_then(|d| i64::try_from(d.as_secs()).ok())
|
||||
})
|
||||
.unwrap_or(0)
|
||||
}
|
||||
ReminderTiming::At { unix_timestamp } => *unix_timestamp,
|
||||
};
|
||||
match broker.store_reminder(agent, message, file_path.as_deref(), due_at) {
|
||||
Ok(id) => {
|
||||
tracing::info!(%id, %agent, %due_at, "reminder scheduled");
|
||||
AgentResponse::Ok
|
||||
}
|
||||
Err(e) => AgentResponse::Err {
|
||||
message: format!("failed to store reminder: {e:#}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue