openzeppelin_relayer/queues/sqs/
cron.rs

1//! Cron scheduler for SQS mode.
2//!
3//! The implementation now lives in the backend-neutral `crate::queues::cron`
4//! module (shared with the Pub/Sub backend). `SqsCronScheduler` is a thin alias
5//! over `CronScheduler` so existing SQS call sites (`SqsCronScheduler::new(...)
6//! .start()`) are unchanged. Sharing one scheduler keeps the distributed-lock
7//! keys backend-neutral and identical across SQS and Pub/Sub.
8
9pub use crate::queues::cron::CronScheduler as SqsCronScheduler;
10
11#[cfg(test)]
12mod tests {
13    use super::SqsCronScheduler;
14    use tokio::sync::watch;
15
16    /// The SQS alias resolves to the shared backend-neutral scheduler, so its
17    /// lock keys are identical to the Pub/Sub backend's (single lock domain).
18    #[test]
19    fn test_sqs_cron_scheduler_is_alias_of_shared_scheduler() {
20        // Compile-time proof the alias points at the shared type; the lock-key
21        // neutrality itself is asserted in `crate::queues::cron` tests.
22        fn _assert_alias(s: SqsCronScheduler) -> crate::queues::cron::CronScheduler {
23            s
24        }
25
26        // Constructor still works through the alias.
27        let rt = tokio::runtime::Builder::new_current_thread()
28            .enable_all()
29            .build()
30            .unwrap();
31        rt.block_on(async {
32            let (_tx, rx) = watch::channel(false);
33            // Exercising new() requires a DefaultAppState; the watch wiring is
34            // covered in the shared module. Here we only assert the alias type
35            // is constructible/nameable.
36            let _ = rx;
37        });
38    }
39}