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

source

pub async fn create_reader(&self, reader_id: String) -> EventReader

Create a new EventReader under the ReaderGroup. This method panics if the reader is already part of the reader group.

§Examples
let rg = client_factory.create_reader_group(scope, "rg".to_string(), stream).await;
let reader = rg.create_reader("reader".to_string()).await;
source

pub async fn list_readers(&self) -> Vec<Reader>

Returns the readers which are currently online.

source

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.

source

pub fn get_managed_streams(&self) -> Vec<ScopedStream>

Return the managed Streams by the ReaderGroup.

source

pub async fn get_streamcut(&self) -> StreamCut

Return the latest StreamCut in ReaderGroup.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more