Skip to main content

DataSource

Trait DataSource 

Source
pub trait DataSource {
    // Required methods
    fn poll(&mut self) -> Result<Snapshot, SourceError>;
    fn signal_process(
        &mut self,
        pid: u32,
        signal: ProcessSignal,
    ) -> Result<(), SourceError>;

    // Provided methods
    fn set_interval(&mut self, _interval: Duration) { ... }
    fn set_process_limit(&mut self, _limit: Option<usize>) { ... }
}
Expand description

A producer of snapshots, local or remote.

Required Methods§

Source

fn poll(&mut self) -> Result<Snapshot, SourceError>

Takes a new measurement.

Rates (CPU %, throughput, power) cover the time since the previous call, so callers should poll at a steady interval of at least MIN_POLL_INTERVAL.

Source

fn signal_process( &mut self, pid: u32, signal: ProcessSignal, ) -> Result<(), SourceError>

Sends signal to process pid on the monitored host, with the privileges of the user the source runs as.

Provided Methods§

Source

fn set_interval(&mut self, _interval: Duration)

Tells the source how often it will be polled. Remote sources forward this to the agent, which samples on its own schedule; local sources need nothing.

Source

fn set_process_limit(&mut self, _limit: Option<usize>)

Limits snapshots to the top limit processes by CPU (None: all). Remote sources use this to save bandwidth for hosts in an overview.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: DataSource + ?Sized> DataSource for Box<T>

Boxed sources, so front-ends can choose local or remote at run time.

Source§

fn poll(&mut self) -> Result<Snapshot, SourceError>

Source§

fn signal_process( &mut self, pid: u32, signal: ProcessSignal, ) -> Result<(), SourceError>

Source§

fn set_interval(&mut self, interval: Duration)

Source§

fn set_process_limit(&mut self, limit: Option<usize>)

Implementors§