Skip to main content

klukai_agent/agent/
mod.rs

1//! Agent module
2//!
3//! The agent runs input and output streams (with other agents and
4//! clients), manages cluster memberships, and applies propagated
5//! changesets to local data.
6
7mod bi;
8mod bootstrap;
9mod error;
10mod handlers;
11mod metrics;
12mod run_root;
13mod setup;
14mod uni;
15pub mod util;
16
17#[cfg(test)]
18mod tests;
19
20use bytes::Bytes;
21use klukai_types::api::QueryEventMeta;
22use std::{collections::HashMap, sync::Arc, time::Duration};
23use tokio::sync::{RwLock, broadcast::Sender};
24use uuid::Uuid;
25
26// Public exports
27pub use error::{SyncClientError, SyncRecvError};
28pub use run_root::start_with_config;
29pub use setup::{AgentOptions, setup};
30pub use uni::spawn_unipayload_handler;
31pub use util::process_multiple_changes;
32
33pub const ANNOUNCE_INTERVAL: Duration = Duration::from_secs(300);
34pub const RANDOM_NODES_CHOICES: usize = 10;
35
36pub const CHECK_EMPTIES_TO_INSERT_AFTER: Duration = Duration::from_secs(120);
37pub const TO_CLEAR_COUNT: usize = 1000;
38
39pub type BcastCache = Arc<RwLock<HashMap<Uuid, Sender<(Bytes, QueryEventMeta)>>>>;
40
41#[derive(Clone)]
42pub struct CountedExecutor;
43
44impl<F> hyper::rt::Executor<F> for CountedExecutor
45where
46    F: std::future::Future + Send + 'static,
47    F::Output: Send,
48{
49    fn execute(&self, fut: F) {
50        klukai_types::spawn::spawn_counted(fut);
51    }
52}