Trait pravega_wire_protocol::connection_factory::ConnectionFactory[][src]

pub trait ConnectionFactory: Send + Sync {
#[must_use]    fn establish_connection<'life0, 'async_trait>(
        &'life0 self,
        endpoint: PravegaNodeUri
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Connection>, ConnectionFactoryError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; }

ConnectionFactory trait is the factory used to establish the TCP connection with remote servers.

Required methods

#[must_use]fn establish_connection<'life0, 'async_trait>(
    &'life0 self,
    endpoint: PravegaNodeUri
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Connection>, ConnectionFactoryError>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

establish_connection will return a Connection future that used to send and read data.

Example

use pravega_wire_protocol::connection_factory::{ConnectionFactory, ConnectionFactoryConfig};
use pravega_client_shared::PravegaNodeUri;
use pravega_client_config::connection_type::ConnectionType;
use tokio::runtime::Runtime;

fn main() {
  let mut rt = Runtime::new().unwrap();
  let endpoint = PravegaNodeUri::from("localhost:9090".to_string());
  let config = ConnectionFactoryConfig::new(ConnectionType::Tokio);
  let cf = ConnectionFactory::create(config);
  let connection_future = cf.establish_connection(endpoint);
  let mut connection = rt.block_on(connection_future).unwrap();
}
Loading content...

Implementations

impl dyn ConnectionFactory[src]

Implementors

Loading content...