pub struct PromptRequest {
pub session: SessionId,
pub request_id: String,
pub input: String,
pub meta: HashMap<String, String>,
pub deadline: Option<Instant>,
}Expand description
Initial prompt request from client
Fields§
§session: SessionIdSession this request belongs to. Used for affinity sharding and deduplication key generation.
request_id: StringUnique ID for distributed trace correlation across all pipeline stages.
input: StringThe raw prompt text to send to the inference backend.
meta: HashMap<String, String>Arbitrary key-value metadata forwarded unchanged through the pipeline.
deadline: Option<Instant>Optional absolute deadline for this request. When Some, the inference
stage drops the request and increments requests_expired_total if the
deadline has already passed at dequeue time.
Implementations§
Source§impl PromptRequest
impl PromptRequest
Sourcepub fn with_deadline(self, duration: Duration) -> Self
pub fn with_deadline(self, duration: Duration) -> Self
Builder-style helper that sets an absolute deadline duration from now.
This is an infallible convenience wrapper around try_with_deadline.
It accepts any positive Duration; for validated input (e.g. user-supplied
values) prefer try_with_deadline which rejects zero or excessively large
timeouts at the call site.
§Example
use std::collections::HashMap;
use std::time::Duration;
use tokio_prompt_orchestrator::{PromptRequest, SessionId};
let req = PromptRequest {
session: SessionId::new("s1"),
request_id: "r1".to_string(),
input: "hello".to_string(),
meta: HashMap::new(),
deadline: None,
}
.with_deadline(Duration::from_secs(5));
assert!(req.deadline.is_some());§Panics
This function does not panic.
Sourcepub fn try_with_deadline(
self,
timeout_seconds: u64,
) -> Result<Self, OrchestratorError>
pub fn try_with_deadline( self, timeout_seconds: u64, ) -> Result<Self, OrchestratorError>
Validated builder that sets an absolute deadline timeout_seconds from now.
Accepts a timeout expressed as a whole number of seconds and validates it before storing the deadline.
§Errors
Returns Err(OrchestratorError::ConfigError(_)) when:
timeout_secondsis0— a zero-second deadline expires immediately.timeout_secondsexceeds3600— unreasonably large timeouts are rejected to prevent accidental resource leaks.
§Example
use std::collections::HashMap;
use tokio_prompt_orchestrator::{PromptRequest, SessionId};
let req = PromptRequest {
session: SessionId::new("s1"),
request_id: "r1".to_string(),
input: "hello".to_string(),
meta: HashMap::new(),
deadline: None,
}
.try_with_deadline(30)
.expect("30s is a valid timeout");
assert!(req.deadline.is_some());§Panics
This function does not panic.
Trait Implementations§
Source§impl Clone for PromptRequest
impl Clone for PromptRequest
Source§fn clone(&self) -> PromptRequest
fn clone(&self) -> PromptRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PromptRequest
impl RefUnwindSafe for PromptRequest
impl Send for PromptRequest
impl Sync for PromptRequest
impl Unpin for PromptRequest
impl UnsafeUnpin for PromptRequest
impl UnwindSafe for PromptRequest
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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>
T in a tonic::Request