pub struct IngestStream<D> where
for<'a> D: Data + Deserialize<'a>, { /* private fields */ }
Expand description
An IngestStream
enables drivers to inject data into a running ERDOS application.
Similar to a WriteStream
, an IngestStream
exposes a send
function to allow drivers to send data to the operators of the constructed graph.
Example
The below example shows how to use an IngestStream
to send data to a
FlatMapOperator
,
and retrieve the processed values through an
ExtractStream
.
let args = erdos::new_app("ERDOS").get_matches();
let mut node = Node::new(Configuration::from_args(&args));
// Create an IngestStream.
let mut ingest_stream = IngestStream::new();
// Create an ExtractStream from the ReadStream of the FlatMapOperator.
let output_stream = erdos::connect_one_in_one_out(
|| FlatMapOperator::new(|x: &usize| { std::iter::once(2 * x) }),
|| {},
OperatorConfig::new().name("MapOperator"),
&ingest_stream,
);
let mut extract_stream = ExtractStream::new(&output_stream);
node.run_async();
// Send data on the IngestStream.
for i in 1..10 {
ingest_stream.send(Message::new_message(Timestamp::Time(vec![i as u64]), i)).unwrap();
}
// Retrieve mapped values using an ExtractStream.
for i in 1..10 {
let message = extract_stream.read().unwrap();
assert_eq!(*message.data().unwrap(), 2 * i);
}
Implementations
sourceimpl<D> IngestStream<D> where
for<'a> D: Data + Deserialize<'a>,
impl<D> IngestStream<D> where
for<'a> D: Data + Deserialize<'a>,
sourcepub fn new() -> Self
pub fn new() -> Self
Returns a new instance of the IngestStream
.
sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Returns true
if a top watermark message was received or the IngestStream
failed to
set up.
Trait Implementations
sourceimpl<D> Default for IngestStream<D> where
for<'a> D: Data + Deserialize<'a>,
impl<D> Default for IngestStream<D> where
for<'a> D: Data + Deserialize<'a>,
sourceimpl<D> Stream<D> for IngestStream<D> where
for<'a> D: Data + Deserialize<'a>,
impl<D> Stream<D> for IngestStream<D> where
for<'a> D: Data + Deserialize<'a>,
sourceimpl<D> WriteStreamT<D> for IngestStream<D> where
for<'a> D: Data + Deserialize<'a>,
impl<D> WriteStreamT<D> for IngestStream<D> where
for<'a> D: Data + Deserialize<'a>,
Auto Trait Implementations
impl<D> RefUnwindSafe for IngestStream<D>
impl<D> Send for IngestStream<D>
impl<D> Sync for IngestStream<D>
impl<D> Unpin for IngestStream<D>
impl<D> UnwindSafe for IngestStream<D>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more