pub struct EventEmitter<S: State> {
pub tx: Sender<StreamEvent<S>>,
pub mode: StreamMode,
/* private fields */
}Expand description
Event emitter for streaming
Fields§
§tx: Sender<StreamEvent<S>>§mode: StreamModeImplementations§
Source§impl<S: State> EventEmitter<S>
impl<S: State> EventEmitter<S>
pub const fn new(tx: Sender<StreamEvent<S>>, mode: StreamMode) -> Self
Sourcepub fn with_subgraph_ns(&self, ns_segment: String) -> Self
pub fn with_subgraph_ns(&self, ns_segment: String) -> Self
Create a child emitter with an additional subgraph namespace segment.
Used by subgraph execution to namespace streaming events, allowing consumers to distinguish events from nested subgraphs.
Sourcepub const fn mode(&self) -> &StreamMode
pub const fn mode(&self) -> &StreamMode
Return the stream mode for this emitter.
Sourcepub async fn emit(&self, event: StreamEvent<S>)
pub async fn emit(&self, event: StreamEvent<S>)
Emit an event to the stream.
Silently drops the event if the receiver has been closed, matching the design intent that stream consumers may disconnect at any time without disrupting execution.
pub fn stream_writer(&self, node: String) -> StreamWriter<S>
pub fn should_emit(&self, event: &StreamEvent<S>) -> bool
Sourcepub fn has_nostream_tag(&self, options: Option<&CallOptions>) -> bool
pub fn has_nostream_tag(&self, options: Option<&CallOptions>) -> bool
Check if CallOptions contains “nostream” tag.
This method provides the public API for checking whether LLM call options include the “nostream” tag, which suppresses streaming for that specific call.
§Examples
ⓘ
use juncture_core::stream::EventEmitter;
use juncture_core::llm::CallOptions;
let emitter = EventEmitter::new(tx, StreamMode::Messages);
// No options - no nostream tag
assert!(!emitter.has_nostream_tag(None));
// Options with nostream tag
let options = CallOptions {
tags: vec!["nostream".to_string()],
..Default::default()
};
assert!(emitter.has_nostream_tag(Some(&options)));
// Options without nostream tag
let options = CallOptions {
tags: vec!["fast".to_string()],
..Default::default()
};
assert!(!emitter.has_nostream_tag(Some(&options)));Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for EventEmitter<S>
impl<S> RefUnwindSafe for EventEmitter<S>where
S: RefUnwindSafe,
impl<S> Send for EventEmitter<S>
impl<S> Sync for EventEmitter<S>
impl<S> Unpin for EventEmitter<S>where
S: Unpin,
impl<S> UnsafeUnpin for EventEmitter<S>
impl<S> UnwindSafe for EventEmitter<S>where
S: UnwindSafe,
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