freshness v0.2.1 Freshness.Pool View Source

A simple pool backed by a :queue to store connections

Usage

To create a pool call the new/4 function

pool = Freshness.Pool.new(:http, "google.com", 80)

To checkout a connection from the pool use the checkout/1 function. Note: if there are no connections in the pool a new one will be created and returned

{:ok, pool, connection} = Freshness.Pool.checkout(pool)

You may also get an error if there are no connections in the pool and a new connection cannot be opened

{:error, error} = Freshness.Pool.checkout(pool)

To return a connection back to the pool use the checkin/2 function

pool = Freshness.Pool.checkin(pool, connection)

Link to this section Summary

Link to this section Types

Link to this type

t()

View Source
t() :: %Freshness.Pool{
  connections: term(),
  host: term(),
  opts: term(),
  port: term(),
  scheme: term()
}

Link to this section Functions

Link to this function

checkin(pool, connection)

View Source
checkin(t(), Mint.HTTP.t()) :: t()
Link to this function

checkout(pool)

View Source
checkout(t()) :: {:ok, t(), Mint.HTTP.t()} | {:error, Mint.Types.error()}
Link to this function

new(scheme, host, port, opts \\ [])

View Source