Struct pravega_client::event::reader_group::ReaderGroup
source · pub struct ReaderGroup {
pub name: String,
pub config: ReaderGroupConfig,
/* private fields */
}
Expand description
A collection of readers that collectively read all the events in the stream.
The events are distributed among the readers in the group such that each event goes to only one reader.
The readers in the group may change over time. Readers are added to the group by invoking the
ReaderGroup::create_reader
API.
§Examples
use pravega_client_config::ClientConfigBuilder;
use pravega_client::client_factory::ClientFactory;
use pravega_client_shared::{ScopedStream, Scope, Stream};
#[tokio::main]
async fn main() {
let config = ClientConfigBuilder::default()
.controller_uri("localhost:8000")
.build()
.expect("creating config");
let client_factory = ClientFactory::new(config);
let stream = ScopedStream {
scope: Scope::from("scope".to_string()),
stream: Stream::from("stream".to_string()),
};
// Create a reader group to read data from the Pravega stream.
let rg = client_factory.create_reader_group("rg".to_string(), stream).await;
// Create a reader under the reader group.
let mut reader1 = rg.create_reader("r1".to_string()).await;
let mut reader2 = rg.create_reader("r2".to_string()).await;
// EventReader APIs can be used to read events.
}
Fields§
§name: String
§config: ReaderGroupConfig
Implementations§
source§impl ReaderGroup
impl ReaderGroup
sourcepub async fn create_reader(&self, reader_id: String) -> EventReader
pub async fn create_reader(&self, reader_id: String) -> EventReader
sourcepub async fn list_readers(&self) -> Vec<Reader>
pub async fn list_readers(&self) -> Vec<Reader>
Returns the readers which are currently online.
sourcepub async fn reader_offline(
&self,
reader_id: String,
last_position: Option<HashMap<String, i64>>
) -> Result<(), ReaderGroupStateError>
pub async fn reader_offline( &self, reader_id: String, last_position: Option<HashMap<String, i64>> ) -> Result<(), ReaderGroupStateError>
Removes a reader from the reader group. (Because it is offline)
Normally, readers shutdown gracefully by calling reader_offline
on the reader itself.
However, if the process dies, this provides an alternative way to shutdown the reader.
last_position
is a map containing the last offsets processed by the reader. There is no requirement for
the map to be complete, or even non-empty. If a segment is missing, the last known value will be
assumed.
The application can persist the full scoped segment and offset by using the SegmentSlice and the Event obtained while iterating over the SegmentSlice.
If the reader is already offline, this method will have no effect.
sourcepub fn get_managed_streams(&self) -> Vec<ScopedStream>
pub fn get_managed_streams(&self) -> Vec<ScopedStream>
Return the managed Streams by the ReaderGroup.
sourcepub async fn get_streamcut(&self) -> StreamCut
pub async fn get_streamcut(&self) -> StreamCut
Return the latest StreamCut in ReaderGroup.
Auto Trait Implementations§
impl Freeze for ReaderGroup
impl !RefUnwindSafe for ReaderGroup
impl Send for ReaderGroup
impl Sync for ReaderGroup
impl Unpin for ReaderGroup
impl !UnwindSafe for ReaderGroup
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<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> 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> 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