Struct pravega_client::client_factory::ClientFactory

source ·
pub struct ClientFactory { /* private fields */ }
Expand description

Applications should use ClientFactory to create resources they need.

ClientFactory contains a connection pool that is shared by all the readers and writers it creates. It also contains a tokio runtime that is used to drive async tasks. Spawned tasks in readers and writers are tied to this runtime.

Note that dropping Runtime in async context is not a good practice and it will have warning messages. ClientFactory is the only place that’s holding the Runtime, so it should not be used in any async contexts. You can use [‘ClientFactoryAsync’] in async contexts instead.

§Examples

use pravega_client_config::ClientConfigBuilder;
use pravega_client::client_factory::ClientFactory;

fn main() {
   let config = ClientConfigBuilder::default()
        .controller_uri("localhost:8000")
        .build()
        .expect("create config");
    let client_factory = ClientFactory::new(config);
}
use pravega_client_config::ClientConfigBuilder;
use pravega_client::client_factory::ClientFactoryAsync;
use tokio::runtime::Handle;

#[tokio::main]
async fn main() {
   let config = ClientConfigBuilder::default()
        .controller_uri("localhost:8000")
        .build()
        .expect("create config");
    let handle = Handle::try_current().expect("get current runtime handle");
    let client_factory = ClientFactoryAsync::new(config, handle);
}

Implementations§

source§

impl ClientFactory

source

pub fn new(config: ClientConfig) -> ClientFactory

source

pub fn new_with_runtime(config: ClientConfig, rt: Runtime) -> ClientFactory

source

pub fn runtime(&self) -> &Runtime

source

pub fn runtime_handle(&self) -> Handle

source

pub fn config(&self) -> &ClientConfig

source

pub fn controller_client(&self) -> &dyn ControllerClient

source

pub fn create_event_writer(&self, stream: ScopedStream) -> EventWriter

source

pub async fn create_reader_group( &self, reader_group_name: String, stream: ScopedStream ) -> ReaderGroup

source

pub async fn create_reader_group_with_config( &self, reader_group_name: String, reader_group_config: ReaderGroupConfig, scope: Scope ) -> ReaderGroup

Create a Reader Group based on the ReaderGroupConfig.

source

pub async fn delete_reader_group( &self, scope: Scope, reader_group_name: String ) -> Result<(), TableError>

Delete a ReaderGroup.

source

pub async fn create_transactional_event_writer( &self, stream: ScopedStream, writer_id: WriterId ) -> TransactionalEventWriter

source

pub async fn create_byte_writer(&self, stream: ScopedStream) -> ByteWriter

source

pub async fn create_byte_reader(&self, stream: ScopedStream) -> ByteReader

source

pub async fn create_index_writer<T: Fields + PartialOrd + PartialEq + Debug>( &self, stream: ScopedStream ) -> IndexWriter<T>

source

pub async fn create_index_reader(&self, stream: ScopedStream) -> IndexReader

source

pub async fn create_table(&self, scope: Scope, name: String) -> Table

source

pub async fn create_synchronizer( &self, scope: Scope, name: String ) -> Synchronizer

source

pub fn to_async(&self) -> ClientFactoryAsync

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