ConnectionPool.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/network/ConnectionPool.hpp"

ConnectionPool

Connection Pool.

namespace oatpp { namespace network { 
  class ConnectionPool {}
}}

Methods

Return Type Name Summary
[none] ConnectionPool Constructor.
[none] ~ConnectionPool Destructor.
std::shared_ptr<ConnectionProvider> getConnectionProvider Get underlying connection provider.
std::shared_ptr<Pool> getPoolInstance Get pool instance.
std::shared_ptr<ConnectionWrapper> getConnection Get connection.
oatpp::async::CoroutineStarterForResult<const std::shared_ptr<ConnectionWrapper>&> getConnectionAsync Multiple implementations:
  1. Get connection in Async manner.
  2. Get connection in Async manner.
void close Close all connections.

ConnectionPool::ConnectionPool

Constructor.

  • @param connectionProvider - underlying connection provider.
  • @param maxConnections - maximum number of allowed connections in the pool.
  • @param maxConnectionTTL - maximum time that unused connection is allowed to live in the pool.

ConnectionPool(const std::shared_ptr<ConnectionProvider>& connectionProvider,
               v_int64 maxConnections,
               const std::chrono::duration<v_int64, std::micro>& maxConnectionTTL)

ConnectionPool::~ConnectionPool

Destructor. Calls ConnectionPool::close().

~ConnectionPool()

ConnectionPool::getConnectionProvider

Get underlying connection provider.

std::shared_ptr<ConnectionProvider> getConnectionProvider()

ConnectionPool::getPoolInstance

Get pool instance.

  • @return

std::shared_ptr<Pool> getPoolInstance()

ConnectionPool::getConnection

Get connection. This call will wait until connection is available.

  • @return

std::shared_ptr<ConnectionWrapper> getConnection()

ConnectionPool::getConnectionAsync

  1. Get connection in Async manner.
    • @param connectionProvider
    • @param poolInstance
    • @return
    static oatpp::async::CoroutineStarterForResult<const std::shared_ptr<ConnectionWrapper>&>
    getConnectionAsync(const std::shared_ptr<ConnectionProvider>& connectionProvider, const std::shared_ptr<Pool>& poolInstance)
    
  2. Get connection in Async manner. This call will wait until connection is available.
    • @return
    oatpp::async::CoroutineStarterForResult<const std::shared_ptr<ConnectionWrapper>&> getConnectionAsync()
    

ConnectionPool::close

Close all connections. All free connections that are currently in the pool are closed immediately. Other connections are closed once returned to the pool.

void close()

ConnectionPool::ConnectionWrapper

Wrapper over oatpp::data::stream::IOStream. Will acquire connection from the pool on initialization and will return connection to the pool on destruction.

namespace oatpp { namespace network { 
  class ConnectionPool {
    class ConnectionWrapper : public oatpp::data::stream::IOStream {}
  };
}}

Methods

Return Type Name Summary
void invalidate Mark that this connection cannot be reused in the pool any more.
bool isValid Check if connection is still valid.

ConnectionPool::ConnectionWrapper::invalidate

Mark that this connection cannot be reused in the pool any more.

void invalidate()

ConnectionPool::ConnectionWrapper::isValid

Check if connection is still valid.

  • @return

bool isValid()

ServerConnectionPool

oatpp::network::ServerConnectionProvider based on ConnectionPool.

namespace oatpp { namespace network { 
  class ServerConnectionPool : public ServerConnectionProvider {}
}}

Methods

Return Type Name Summary
[none] ServerConnectionPool Constructor.
std::shared_ptr<IOStream> getConnection Get connection.
oatpp::async::CoroutineStarterForResult<const std::shared_ptr<IOStream>&> getConnectionAsync Get connection in Async manner.
void invalidateConnection Invalidate connection that was previously created by this provider.
void close Close pool.

ServerConnectionPool::ServerConnectionPool

Constructor.

  • @param connectionProvider - underlying connection provider.
  • @param maxConnections - maximum number of allowed connections in the pool.
  • @param maxConnectionTTL - maximum time that unused connection is allowed to live in the pool.

ServerConnectionPool(const std::shared_ptr<ServerConnectionProvider>& connectionProvider,
                     v_int64 maxConnections,
                     const std::chrono::duration<v_int64, std::micro>& maxConnectionTTL)

ServerConnectionPool::getConnection

Get connection. This call will wait until connection is available.

  • @return

std::shared_ptr<IOStream> getConnection() override

ServerConnectionPool::getConnectionAsync

Get connection in Async manner. This call will wait until connection is available.

  • @return

oatpp::async::CoroutineStarterForResult<const std::shared_ptr<IOStream>&> getConnectionAsync() override

ServerConnectionPool::invalidateConnection

Invalidate connection that was previously created by this provider. Ex.: if provider is pool based - you can signal that this connection should not be reused anymore.

  • @param connection

void invalidateConnection(const std::shared_ptr<IOStream>& connection) override

ServerConnectionPool::close

Close pool.

void close() override

ClientConnectionPool

oatpp::network::ClientConnectionProvider based on ConnectionPool.

namespace oatpp { namespace network { 
  class ClientConnectionPool : public ClientConnectionProvider {}
}}

Methods

Return Type Name Summary
[none] ClientConnectionPool Constructor.
std::shared_ptr<IOStream> getConnection Get connection.
oatpp::async::CoroutineStarterForResult<const std::shared_ptr<IOStream>&> getConnectionAsync Get connection in Async manner.
void invalidateConnection Invalidate connection that was previously created by this provider.
void close Close pool.

ClientConnectionPool::ClientConnectionPool

Constructor.

  • @param connectionProvider - underlying connection provider.
  • @param maxConnections - maximum number of allowed connections in the pool.
  • @param maxConnectionTTL - maximum time that unused connection is allowed to live in the pool.

ClientConnectionPool(const std::shared_ptr<ClientConnectionProvider>& connectionProvider,
                     v_int64 maxConnections,
                     const std::chrono::duration<v_int64, std::micro>& maxConnectionTTL)

ClientConnectionPool::getConnection

Get connection. This call will wait until connection is available.

  • @return

std::shared_ptr<IOStream> getConnection() override

ClientConnectionPool::getConnectionAsync

Get connection in Async manner. This call will wait until connection is available.

  • @return

oatpp::async::CoroutineStarterForResult<const std::shared_ptr<IOStream>&> getConnectionAsync() override

ClientConnectionPool::invalidateConnection

Invalidate connection that was previously created by this provider. Ex.: if provider is pool based - you can signal that this connection should not be reused anymore.

  • @param connection

void invalidateConnection(const std::shared_ptr<IOStream>& connection) override

ClientConnectionPool::close

Close pool.

void close() override