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
61
62
63
64
65
66
//! In-memory and RocksDB-backed event queues.
//!
//! # In-memory queue
//!
//! Use [`EventQueue`] when events only need to live in memory.
//!
//! ```
//! use arch_event_queues::EventQueue;
//!
//! #[derive(Debug, PartialEq, Eq)]
//! struct Event {
//! payload: String,
//! }
//!
//! let queue = EventQueue::<Event>::new();
//! queue
//! .push(Event {
//! payload: "created".to_string(),
//! })
//! .unwrap();
//!
//! assert_eq!(
//! queue.pop().unwrap(),
//! Some(Event {
//! payload: "created".to_string(),
//! })
//! );
//! ```
//!
//! # Durable queue
//!
//! Use [`DurableEventQueue`] when events must survive process restarts until
//! they are acknowledged.
//!
//! ```
//! use arch_event_queues::DurableEventQueue;
//! use borsh::{BorshDeserialize, BorshSerialize};
//!
//! #[derive(Clone, Debug, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
//! struct Event {
//! payload: String,
//! }
//!
//! let dir = tempfile::tempdir().unwrap();
//! let queue = DurableEventQueue::<Event>::open(dir.path()).unwrap();
//!
//! let queued = queue
//! .push(Event {
//! payload: "index block".to_string(),
//! })
//! .unwrap();
//!
//! let next = queue.pop().unwrap().expect("queued job");
//! assert_eq!(next.id, queued.id);
//!
//! queue.ack(next.id).unwrap();
//! ```
pub use ;
pub use ;