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
impl ClientFactory
pub fn new(config: ClientConfig) -> ClientFactory
pub fn new_with_runtime(config: ClientConfig, rt: Runtime) -> ClientFactory
pub fn runtime(&self) -> &Runtime
pub fn runtime_handle(&self) -> Handle
pub fn config(&self) -> &ClientConfig
pub fn controller_client(&self) -> &dyn ControllerClient
pub fn create_event_writer(&self, stream: ScopedStream) -> EventWriter
pub async fn create_reader_group( &self, reader_group_name: String, stream: ScopedStream ) -> ReaderGroup
sourcepub async fn create_reader_group_with_config(
&self,
reader_group_name: String,
reader_group_config: ReaderGroupConfig,
scope: Scope
) -> ReaderGroup
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.
sourcepub async fn delete_reader_group(
&self,
scope: Scope,
reader_group_name: String
) -> Result<(), TableError>
pub async fn delete_reader_group( &self, scope: Scope, reader_group_name: String ) -> Result<(), TableError>
Delete a ReaderGroup.
pub async fn create_transactional_event_writer( &self, stream: ScopedStream, writer_id: WriterId ) -> TransactionalEventWriter
pub async fn create_byte_writer(&self, stream: ScopedStream) -> ByteWriter
pub async fn create_byte_reader(&self, stream: ScopedStream) -> ByteReader
pub async fn create_index_writer<T: Fields + PartialOrd + PartialEq + Debug>( &self, stream: ScopedStream ) -> IndexWriter<T>
pub async fn create_index_reader(&self, stream: ScopedStream) -> IndexReader
pub async fn create_table(&self, scope: Scope, name: String) -> Table
pub async fn create_synchronizer( &self, scope: Scope, name: String ) -> Synchronizer
pub fn to_async(&self) -> ClientFactoryAsync
Auto Trait Implementations§
impl !Freeze for ClientFactory
impl !RefUnwindSafe for ClientFactory
impl Send for ClientFactory
impl Sync for ClientFactory
impl Unpin for ClientFactory
impl !UnwindSafe for ClientFactory
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
§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>
Wrap the input message
T
in a tonic::Request