shepherd-rs 0.1.0

Shepherd is a resilient, non-blocking orchestrator that persistently transforms and delivers data—built for remote, compute-heavy workloads.
Documentation
use async_trait::async_trait;

use crate::transform::TransformRequest;

#[async_trait]
pub trait Emitter: Eq + Send + Sync
where
    <Self as Emitter>::TransformRequest: TransformRequest, {
    /// The base `TransformRequest` type that this `InputCreator` creates.
    type TransformRequest;

    type EmitterError;

    /// The context used to reinitialize the emitter
    /// in case of process restart or similar events.
    type InitContext;

    fn new(init_context: Self::InitContext) -> Result<Self, Self::EmitterError>
    where
        Self: Sized;

    async fn update_init_context(
        &mut self,
        init_context: Self::InitContext,
    ) -> Result<(), Self::EmitterError>;

    /// The running loop of the emitter.
    /// This loop should run indefinitely, processing incoming requests
    /// Maybe needs a default implementation
    async fn emitter_loop(&mut self) -> Result<(), Self::EmitterError>;

    /// Creates a new transformation request.
    async fn emit_transform_request(
        &mut self,
        request: Self::TransformRequest,
    ) -> Result<(), Self::EmitterError>;
}

pub(crate) enum EmissionHint {
    Halt,
    Resume,
}