pub struct PromptManager { /* private fields */ }Expand description
Prompt manager
Tracks active prompts per session and ensures serialization:
- Only one prompt can run at a time per session
- New prompts automatically cancel old prompts
- Provides timeout protection for cancellation
Implementations§
Source§impl PromptManager
impl PromptManager
Sourcepub async fn cancel_session_prompt(&self, session_id: &str) -> bool
pub async fn cancel_session_prompt(&self, session_id: &str) -> bool
Cancel any active prompt for the given session
This will:
- Send a cancellation signal via the token
- Wait for the task to complete (with 5 second timeout)
- Remove the task from tracking
Returns true if an old prompt was cancelled, false if there was
no active prompt for this session.
Sourcepub fn register_prompt(
&self,
session_id: String,
handle: JoinHandle<()>,
cancel_token: CancellationToken,
) -> PromptId
pub fn register_prompt( &self, session_id: String, handle: JoinHandle<()>, cancel_token: CancellationToken, ) -> PromptId
Register a new prompt task
This should be called after spawning a prompt task. The prompt will be tracked and can be cancelled later.
Sourcepub fn complete_prompt(&self, session_id: &str, prompt_id: &str)
pub fn complete_prompt(&self, session_id: &str, prompt_id: &str)
Mark a prompt as completed
This should be called when a prompt finishes normally (not cancelled). It removes the prompt from tracking if the prompt_id matches.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Get the number of active prompts
Sourcepub fn has_active_prompt(&self, session_id: &str) -> bool
pub fn has_active_prompt(&self, session_id: &str) -> bool
Check if a session has an active prompt
Trait Implementations§
Source§impl Debug for PromptManager
impl Debug for PromptManager
Auto Trait Implementations§
impl Freeze for PromptManager
impl !RefUnwindSafe for PromptManager
impl Send for PromptManager
impl Sync for PromptManager
impl Unpin for PromptManager
impl UnwindSafe for PromptManager
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
fn into_option(self) -> Option<T>
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