class ConnectionPool(T)

Overview

Sharing connections across coroutines.

Connections will be checkout from the pool and tied to the current fiber, until they are checkin, and thus be usable by another coroutine. Connections may also be manually checkout and checkin.

Defined in:

connection.cr

Constructors

Instance Method Summary

Instance methods inherited from class Pool(T)

capacity capacity, checkin(connection : T) checkin, checkout : T checkout, pending pending, size size, start_all start_all, timeout timeout

Constructor methods inherited from class Pool(T)

new(capacity : Int32 = 5, timeout : Float64 = 5.0, &block : -> T) new

Constructor Detail

def self.new(capacity : Int32 = 5, timeout : Float64 = 5.0, &block : -> T) #

[View source]

Instance Method Detail

def active? #

Returns true if a connection was checkout for the current coroutine.


[View source]
def connection #

Returns the already checkout connection or checkout a connection then attaches it to the current coroutine.


[View source]
def connection(&) #

Yields a connection.

If a connection was already checkout for the curent coroutine, it will be yielded. Otherwise a connection will be checkout and tied to the current coroutine, passed to the block and eventually checkin.


[View source]
def release #

Releases the checkout connection for the current coroutine (if any).


[View source]