9#include <condition_variable>
68 std::string host,
unsigned short port,
size_t pool_size = 10,
69 std::chrono::seconds acquire_timeout = std::chrono::seconds(30));
93 auto
acquire() -> std::unique_ptr<messaging_client>;
102 auto
release(std::unique_ptr<messaging_client> client) ->
void;
134 std::condition_variable
cv_;
std::atomic< bool > is_shutdown_
~connection_pool() noexcept
Destructor. Stops all connections and cleans up resources.
connection_pool(std::string host, unsigned short port, size_t pool_size=10, std::chrono::seconds acquire_timeout=std::chrono::seconds(30))
Constructs a connection pool.
auto acquire() -> std::unique_ptr< messaging_client >
Acquires a connection from the pool.
std::condition_variable cv_
auto pool_size() const noexcept -> size_t
Gets the total pool size.
std::queue< std::unique_ptr< messaging_client > > available_
auto initialize() -> VoidResult
Initializes the pool by creating and connecting all clients.
std::chrono::seconds acquire_timeout_
std::atomic< size_t > active_count_
auto release(std::unique_ptr< messaging_client > client) -> void
Releases a connection back to the pool.
auto active_count() const noexcept -> size_t
Gets the number of active (borrowed) connections.
TCP client implementation.
Result< std::monostate > VoidResult
Network-specific error and result type definitions.