elk_mq/
lib.rs

1//  Copyright 2022 Tijmen Menno Verhoef
2
3//  Licensed under the Apache License, Version 2.0 (the "License");
4//  you may not use this file except in compliance with the License.
5//  You may obtain a copy of the License at
6
7//      http://www.apache.org/licenses/LICENSE-2.0
8
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14
15mod name_generator;
16mod event_queue;
17
18#[cfg(feature="python_bindings")]
19mod python_bindings;
20
21pub use event_queue::{ EventQueue, EventQueueError, EventQueueResult, ServiceEvent, Timestamp, TimestampedEvent };
22
23#[cfg(test)]
24mod tests {
25    use super::*;
26
27    #[test]
28    fn test_basic_public_api_ok() {
29        let mut queue: EventQueue = EventQueue::new("lib_queue", "redis://127.0.0.1");
30
31        let event: ServiceEvent = ServiceEvent::new(10, "lib_test", None);
32
33        let timestamp: Timestamp = queue.enqueue(&event).unwrap();
34
35        let timestamped_event: TimestampedEvent = queue.dequeue().unwrap();
36
37        assert_eq!(timestamp, timestamped_event.timestamp());
38        assert_eq!(&event, timestamped_event.event());
39    }
40}