shepherd-rs 0.2.0

Shepherd is a resilient, non-blocking orchestrator that persistently transforms and delivers data—built for remote, compute-heavy workloads.
Documentation
//! # Instrumentation Trait
//!
//! This trait defines the behavior of instrumentation in the shepherd
//! framework.
//!
//! ## Overview
//! - **Instrumentation**: Tracks events and provides monitoring capabilities.
//! - **Event Handling**: Handles transformation and consumption events.
//!
//! ## Example
//! ```rust
//! struct MyInstrumentation;
//!
//! impl Instrumentation for MyInstrumentation {
//!     // Implementation details...
//! }
//! ```

use std::sync::Arc;

use async_trait::async_trait;
use tokio::sync::Mutex;

use crate::config::Config;

#[async_trait]
pub trait Instrumentation: Send + Sync {
    type TransformRequestIdentifier;
    type TransformAttemptIdentifier;
    type ConsumeAttemptIdentifier;
    type Config: Config;

    async fn new(config: Arc<Mutex<Self::Config>>) -> Result<Self, String>
    where
        Self: Sized;

    async fn instrumentation_loop(&mut self) -> Result<(), String>;

    fn request_added(&mut self, request_id: Self::TransformRequestIdentifier);
    fn request_completed(&mut self, request_id: Self::TransformRequestIdentifier);
    fn transform_attempt_started(&mut self, request_id: Self::TransformAttemptIdentifier);
    fn transform_attempt_completed(&mut self, request_id: Self::TransformAttemptIdentifier);
    fn transform_attempt_failed(&mut self, request_id: Self::TransformAttemptIdentifier);
    fn consume_attempt_started(&mut self, request_id: Self::ConsumeAttemptIdentifier);
    fn consume_attempt_completed(&mut self, request_id: Self::ConsumeAttemptIdentifier);
    fn consume_attempt_failed(&mut self, request_id: Self::ConsumeAttemptIdentifier);
}