1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! Typed scheduled input.
//!
//! EventBridge Scheduler and scheduled rules deliver whatever payload the
//! schedule configures. Deserializing it into a real type is the whole job: a
//! schedule whose payload silently stopped matching the handler is otherwise
//! invisible until the wrong branch runs.
use Future;
use Arc;
use crate::;
/// Runs a scheduled handler over a typed payload.
///
/// Use `()` when the schedule has no payload, or [`serde_json::Value`] to
/// accept anything.
///
/// # Errors
///
/// Returns a [`RuntimeError`] only when the loop itself fails. A handler
/// error, or a payload that does not deserialize into `T`, is reported to
/// Lambda as an invocation error. Schedules invoke the function
/// asynchronously, so Lambda's asynchronous retries and the function's
/// on-failure destination or dead-letter queue act on it.
///
/// # Examples
///
/// ```no_run
/// use std::sync::Arc;
///
/// use davidrs::{Context, RuntimeError};
///
/// #[derive(serde::Deserialize)]
/// struct Purge { older_than_days: u32 }
///
/// async fn purge(_: Arc<()>, input: Purge, _: Context<()>) -> Result<(), RuntimeError> {
/// println!("purging items older than {} days", input.older_than_days);
/// Ok(())
/// }
///
/// # async fn start() -> Result<(), RuntimeError> {
/// davidrs::schedule::run(Arc::new(()), purge).await
/// # }
/// ```
pub async