Skip to main content

TaskOutput

Struct TaskOutput 

Source
pub struct TaskOutput<T> {
    pub value: T,
    pub metrics: Vec<(String, f64)>,
}
Expand description

The output of firing a task, including named metrics for pattern detection.

Fields§

§value: T

The primary output value.

§metrics: Vec<(String, f64)>

Named metrics extracted during firing, used by pattern detectors.

Implementations§

Source§

impl<T> TaskOutput<T>

Source

pub fn new(value: T, metrics: Vec<(String, f64)>) -> Self

Create a new task output with a value and metrics.

Examples found in repository?
examples/basic.rs (lines 14-21)
13    fn fire(&self) -> TaskOutput<Self::Output> {
14        TaskOutput::new(
15            self.value,
16            vec![
17                ("value".into(), self.value),
18                ("abs".into(), self.value.abs()),
19                ("squared".into(), self.value * self.value),
20            ],
21        )
22    }
More examples
Hide additional examples
examples/ci_patterns.rs (lines 15-22)
14    fn fire(&self) -> TaskOutput<Self::Output> {
15        TaskOutput::new(
16            self.duration_secs,
17            vec![
18                ("duration".into(), self.duration_secs),
19                ("test_count".into(), self.test_count),
20                ("duration_per_test".into(), self.duration_secs / self.test_count.max(1.0)),
21            ],
22        )
23    }
examples/api_monitoring.rs (lines 16-24)
15    fn fire(&self) -> TaskOutput<Self::Output> {
16        TaskOutput::new(
17            self.latency_ms,
18            vec![
19                ("latency_ms".into(), self.latency_ms),
20                ("response_bytes".into(), self.response_bytes),
21                ("is_error".into(), if self.status >= 400 { 1.0 } else { 0.0 }),
22                ("is_slow".into(), if self.latency_ms > 200.0 { 1.0 } else { 0.0 }),
23            ],
24        )
25    }
examples/event_stream_processor.rs (lines 32-48)
31    fn fire(&self) -> TaskOutput<Self::Output> {
32        TaskOutput::new(
33            self.processing_time_ms,
34            vec![
35                ("processing_time_ms".into(),     self.processing_time_ms),
36                ("throughput".into(),              self.throughput),
37                ("memory_mb".into(),               self.memory_mb),
38                ("error_rate".into(),              self.error_rate),
39                ("records_in".into(),              self.records_in),
40                ("records_out".into(),             self.records_out),
41                ("cpu_temp_c".into(),              self.cpu_temp_c),
42                ("latency_p99_ms".into(),          self.latency_p99_ms),
43                ("consumer_lag".into(),            self.consumer_lag),
44                ("gc_pause_ms".into(),             self.gc_pause_ms),
45                ("event_id".into(),                self.event_id as f64),
46                ("batch_id".into(),                self.batch_id as f64),
47            ],
48        )
49    }
Source

pub fn simple(value: T) -> Self

Create a task output with no metrics.

Source

pub fn with_metric(self, name: impl Into<String>, value: f64) -> Self

Add a named metric.

Trait Implementations§

Source§

impl<T: Clone> Clone for TaskOutput<T>

Source§

fn clone(&self) -> TaskOutput<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for TaskOutput<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for TaskOutput<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for TaskOutput<T>
where T: RefUnwindSafe,

§

impl<T> Send for TaskOutput<T>
where T: Send,

§

impl<T> Sync for TaskOutput<T>
where T: Sync,

§

impl<T> Unpin for TaskOutput<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for TaskOutput<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for TaskOutput<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.