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
//! # Dummy Instrumentation
//!
//! This module provides a dummy implementation of the `Instrumentation` trait.
//!
//! ## Overview
//! - **DummyInstrumentation**: A placeholder implementation for testing and
//!   debugging.
//! - **Event Handling**: Tracks transformation and consumption events.
//!
//! ## Example
//! ```rust
//! let instrumentation = DummyInstrumentation::new();
//! instrumentation.request_added(...);
//! ```

use std::sync::Arc;

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

use crate::config::Config;
use crate::instrumentation::instrumentation::Instrumentation;

pub struct DummyInstrumentation<TRI, TAI, CAI, C>
where
    TRI: Send + Sync,
    TAI: Send + Sync,
    CAI: Send + Sync,
    C: Config,
{
    _marker: std::marker::PhantomData<(TRI, TAI, CAI, C)>,
}

#[async_trait]
impl<TRI, TAI, CAI, C> Instrumentation for DummyInstrumentation<TRI, TAI, CAI, C>
where
    TRI: Send + Sync,
    TAI: Send + Sync,
    CAI: Send + Sync,
    C: Config,
{
    type Config = C;
    type ConsumeAttemptIdentifier = CAI;
    type TransformAttemptIdentifier = TAI;
    type TransformRequestIdentifier = TRI;

    /// Creates a new instance of `DummyInstrumentation`.
    ///
    /// # Arguments
    /// * `config` - A shared, mutable reference to the configuration.
    ///
    /// # Returns
    /// * `Ok(Self)` - A new instance of `DummyInstrumentation`.
    /// * `Err(String)` - An error message if the creation fails.
    async fn new(_config: Arc<Mutex<Self::Config>>) -> Result<Self, String>
    where
        Self: Sized,
    {
        Ok(DummyInstrumentation {
            _marker: std::marker::PhantomData,
        })
    }

    /// A dummy implementation of the instrumentation loop.
    ///
    /// # Returns
    /// * `Ok(())` - Indicates the loop has completed successfully.
    /// * `Err(String)` - An error message if the loop encounters an issue.
    async fn instrumentation_loop(&mut self) -> Result<(), String> { Ok(()) }

    /// Records the addition of a request.
    ///
    /// # Arguments
    /// * `request_id` - The identifier of the request that was added.
    fn request_added(&mut self, _request_id: Self::TransformRequestIdentifier) {}

    /// Records the completion of a request.
    ///
    /// # Arguments
    /// * `request_id` - The identifier of the request that was completed.
    fn request_completed(&mut self, _request_id: Self::TransformRequestIdentifier) {}

    /// Records the start of a transform attempt.
    ///
    /// # Arguments
    /// * `request_id` - The identifier of the request for which the transform
    ///   attempt started.
    fn transform_attempt_started(&mut self, _request_id: Self::TransformAttemptIdentifier) {}

    /// Records the completion of a transform attempt.
    ///
    /// # Arguments
    /// * `request_id` - The identifier of the request for which the transform
    ///   attempt completed.
    fn transform_attempt_completed(&mut self, _request_id: Self::TransformAttemptIdentifier) {}

    /// Records a failed transform attempt.
    ///
    /// # Arguments
    /// * `request_id` - The identifier of the request for which the transform
    ///   attempt failed.
    fn transform_attempt_failed(&mut self, _request_id: Self::TransformAttemptIdentifier) {}

    /// Records the start of a consume attempt.
    ///
    /// # Arguments
    /// * `request_id` - The identifier of the request for which the consume
    ///   attempt started.
    fn consume_attempt_started(&mut self, _request_id: Self::ConsumeAttemptIdentifier) {}

    /// Records the completion of a consume attempt.
    ///
    /// # Arguments
    /// * `request_id` - The identifier of the request for which the consume
    ///   attempt completed.
    fn consume_attempt_completed(&mut self, _request_id: Self::ConsumeAttemptIdentifier) {}

    /// Records a failed consume attempt.
    ///
    /// # Arguments
    /// * `request_id` - The identifier of the request for which the consume
    ///   attempt failed.
    fn consume_attempt_failed(&mut self, _request_id: Self::ConsumeAttemptIdentifier) {}
}