1use std::time::Duration;
2
3use datum::StreamInstrumentationRegistry;
4
5use crate::{AgentResult, JobRegistry, JobRegistryHandle};
6
7#[derive(Debug, Clone)]
9pub struct AgentConfig {
10 pub poll_interval: Duration,
12 pub event_buffer: usize,
14 pub instrumentation: StreamInstrumentationRegistry,
16}
17
18impl Default for AgentConfig {
19 fn default() -> Self {
20 Self {
21 poll_interval: Duration::from_millis(10),
22 event_buffer: 1_024,
23 instrumentation: StreamInstrumentationRegistry::new(),
24 }
25 }
26}
27
28pub struct Agent;
30
31impl Agent {
32 pub fn start() -> AgentResult<AgentHandle> {
33 Self::start_with_config(AgentConfig::default())
34 }
35
36 pub fn start_with_config(config: AgentConfig) -> AgentResult<AgentHandle> {
37 let instrumentation = config.instrumentation.clone();
38 Ok(AgentHandle {
39 registry: JobRegistry::start(config)?,
40 instrumentation,
41 })
42 }
43}
44
45#[derive(Clone)]
47pub struct AgentHandle {
48 registry: JobRegistryHandle,
49 instrumentation: StreamInstrumentationRegistry,
50}
51
52impl AgentHandle {
53 #[must_use]
54 pub fn registry(&self) -> &JobRegistryHandle {
55 &self.registry
56 }
57
58 #[must_use]
59 pub fn instrumentation_registry(&self) -> &StreamInstrumentationRegistry {
60 &self.instrumentation
61 }
62
63 pub fn into_registry(self) -> JobRegistryHandle {
64 self.registry
65 }
66}