rustvello 0.8.0

Distributed task queue and workflow runtime for Rust and Python: typed tasks, retries, priorities, triggers and pluggable backends
mod native_async;
mod subprocess;
mod tokio;

#[cfg(feature = "rayon")]
mod rayon;

use std::sync::Arc;

use async_trait::async_trait;
use rustvello_core::context::{InvocationContext, RunnerContext};
use rustvello_core::error::RustvelloResult;
use rustvello_core::task::DynTask;
use rustvello_proto::call::SerializedArguments;
use rustvello_proto::identifiers::ExecutorKind;

pub(crate) use native_async::execute_native_async;
#[cfg(feature = "rayon")]
pub(crate) use rayon::RayonExecutor;
pub(crate) use subprocess::SubprocessExecutor;
pub use subprocess::SubprocessSpec;
pub(crate) use tokio::TokioExecutor;

/// Local mechanism used to invoke task code after distributed work is claimed.
#[async_trait]
pub(crate) trait TaskExecutor: Send + Sync {
    fn kind(&self) -> ExecutorKind;

    async fn execute(
        &self,
        task: Arc<dyn DynTask>,
        args: SerializedArguments,
        invocation_context: InvocationContext,
        runner_context: RunnerContext,
    ) -> RustvelloResult<String>;
}