pub struct EchoWorker {
pub delay_ms: u64,
}Expand description
Dummy echo worker for testing
Simply splits the prompt into words and returns them as tokens. Useful for pipeline smoke tests without real model dependencies.
Fields§
§delay_ms: u64Simulated inference delay
Implementations§
Source§impl EchoWorker
impl EchoWorker
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new EchoWorker with a default 10 ms simulated delay.
The echo worker requires no API keys or external services. It splits the prompt on whitespace and returns each word as a token, making it ideal for pipeline smoke tests and local development.
§Errors
This constructor never returns an error.
§Examples
use tokio_prompt_orchestrator::worker::EchoWorker;
use std::sync::Arc;
let worker = Arc::new(EchoWorker::new());
// Use worker with spawn_pipeline or directlySourcepub fn with_delay(delay_ms: u64) -> Self
pub fn with_delay(delay_ms: u64) -> Self
Create a new EchoWorker with a custom simulated inference delay in milliseconds.
Trait Implementations§
Source§impl Default for EchoWorker
impl Default for EchoWorker
Source§impl ModelWorker for EchoWorker
impl ModelWorker for EchoWorker
Source§fn infer<'life0, 'life1, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, OrchestratorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn infer<'life0, 'life1, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, OrchestratorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Perform inference on the given prompt. Read more
Source§fn infer_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<TokenStream, OrchestratorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn infer_stream<'life0, 'life1, 'async_trait>(
&'life0 self,
prompt: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<TokenStream, OrchestratorError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Stream inference tokens as they arrive from the provider. Read more
Auto Trait Implementations§
impl Freeze for EchoWorker
impl RefUnwindSafe for EchoWorker
impl Send for EchoWorker
impl Sync for EchoWorker
impl Unpin for EchoWorker
impl UnsafeUnpin for EchoWorker
impl UnwindSafe for EchoWorker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request