pub struct JobStreamer { /* private fields */ }Expand description
Job streamer that polls endpoints and dispatches to handlers.
Implementations§
Source§impl JobStreamer
impl JobStreamer
Sourcepub fn new(
base_url: impl Into<String>,
api_key: impl Into<String>,
job_id: impl Into<String>,
) -> JobStreamer
pub fn new( base_url: impl Into<String>, api_key: impl Into<String>, job_id: impl Into<String>, ) -> JobStreamer
Create a new job streamer.
Sourcepub fn with_endpoints(self, endpoints: StreamEndpoints) -> JobStreamer
pub fn with_endpoints(self, endpoints: StreamEndpoints) -> JobStreamer
Set the stream endpoints.
Sourcepub fn with_config(self, config: StreamConfig) -> JobStreamer
pub fn with_config(self, config: StreamConfig) -> JobStreamer
Set the stream config.
Sourcepub fn with_handler(self, handler: Arc<dyn StreamHandler>) -> JobStreamer
pub fn with_handler(self, handler: Arc<dyn StreamHandler>) -> JobStreamer
Add a handler.
Sourcepub fn add_handler<H>(&mut self, handler: H)where
H: StreamHandler + 'static,
pub fn add_handler<H>(&mut self, handler: H)where
H: StreamHandler + 'static,
Add a handler (convenience method).
Sourcepub async fn poll_events(&mut self) -> Result<Vec<StreamMessage>, CoreError>
pub async fn poll_events(&mut self) -> Result<Vec<StreamMessage>, CoreError>
Poll events once.
Sourcepub async fn poll_metrics(&mut self) -> Result<Vec<StreamMessage>, CoreError>
pub async fn poll_metrics(&mut self) -> Result<Vec<StreamMessage>, CoreError>
Poll metrics once.
Sourcepub async fn poll_timeline(&mut self) -> Result<Vec<StreamMessage>, CoreError>
pub async fn poll_timeline(&mut self) -> Result<Vec<StreamMessage>, CoreError>
Poll timeline once.
Sourcepub async fn stream_until_terminal(&mut self) -> Result<Value, CoreError>
pub async fn stream_until_terminal(&mut self) -> Result<Value, CoreError>
Stream until the job reaches a terminal state.
Sourcepub async fn stream_for_duration(
&mut self,
max_seconds: f64,
) -> Result<Option<Value>, CoreError>
pub async fn stream_for_duration( &mut self, max_seconds: f64, ) -> Result<Option<Value>, CoreError>
Stream for a maximum duration, returning early if terminal.
Sourcepub fn last_event_seq(&self) -> Option<i64>
pub fn last_event_seq(&self) -> Option<i64>
Get the last event sequence number.
Sourcepub fn clear_seen(&mut self)
pub fn clear_seen(&mut self)
Clear seen messages (for re-streaming).
Auto Trait Implementations§
impl Freeze for JobStreamer
impl !RefUnwindSafe for JobStreamer
impl Send for JobStreamer
impl Sync for JobStreamer
impl Unpin for JobStreamer
impl !UnwindSafe for JobStreamer
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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