launchdarkly_server_sdk/events/
mod.rs1use launchdarkly_server_sdk_evaluation::Reference;
2use std::collections::HashSet;
3use std::num::NonZeroUsize;
4use std::sync::Arc;
5use std::time::Duration;
6
7use self::sender::EventSender;
8
9pub mod dispatcher;
10pub mod event;
11pub mod processor;
12pub mod processor_builders;
13pub mod sender;
14
15pub struct EventsConfiguration {
16 capacity: usize,
17 event_sender: Arc<dyn EventSender>,
18 flush_interval: Duration,
19 context_keys_capacity: NonZeroUsize,
20 context_keys_flush_interval: Duration,
21 all_attributes_private: bool,
22 private_attributes: HashSet<Reference>,
23 omit_anonymous_contexts: bool,
24}
25
26#[cfg(test)]
27fn create_events_configuration(
28 event_sender: sender::InMemoryEventSender,
29 flush_interval: Duration,
30) -> EventsConfiguration {
31 EventsConfiguration {
32 capacity: 5,
33 event_sender: Arc::new(event_sender),
34 flush_interval,
35 context_keys_capacity: NonZeroUsize::new(5).expect("5 > 0"),
36 context_keys_flush_interval: Duration::from_secs(100),
37 all_attributes_private: false,
38 private_attributes: HashSet::new(),
39 omit_anonymous_contexts: false,
40 }
41}
42
43#[cfg(test)]
44pub(super) fn create_event_sender() -> (
45 sender::InMemoryEventSender,
46 crossbeam_channel::Receiver<event::OutputEvent>,
47) {
48 let (event_tx, event_rx) = crossbeam_channel::unbounded();
49 (sender::InMemoryEventSender::new(event_tx), event_rx)
50}