lhttpc_manager (lhttpc v4.3.2)

Connection manager for the HTTP client. This gen_server is responsible for keeping track of persistent connections to HTTP servers. The only interesting API is connection_count/0 and connection_count/1. The gen_server is supposed to be started by a supervisor, which is normally lhttpc_sup.

Summary

Functions

Returns the total number of active clients maintained by the specified lhttpc pool (manager).
A client has finished one request and returns the socket to the pool, which can be new or not.
Returns the total number of active connections maintained by the specified lhttpc pool (manager).
Returns the number of active connections to the specific Destination maintained by the httpc manager.
Returns the current settings in state for the specified lhttpc pool (manager).
If call contains pool_ensure option, dynamically create the pool with configured parameters. Checks the pool for a socket connected to the destination and returns it if it exists, 'undefined' otherwise.
Lists all the pools already started.
Sets the maximum pool size for the specified pool.
Starts and link to the gen server. This is normally called by a supervisor.
Starts and link to the gen server (with options). This is normally called by a supervisor.
Updates the timeout for persistent connections. This will only affect future sockets handed to the manager. The sockets already managed will keep their timers.

Types

-type state() ::
    #state{destinations :: term(),
           sockets :: term(),
           clients :: term(),
           queues :: term(),
           max_pool_size :: non_neg_integer(),
           timeout :: non_neg_integer()}.

Functions

Link to this function

client_count(PidOrName)

-spec client_count(lhttpc:pool_id()) -> non_neg_integer().
Returns the total number of active clients maintained by the specified lhttpc pool (manager).
Link to this function

client_done(Pool, Host, Port, Ssl, Socket)

-spec client_done(pid(), lhttpc:host(), lhttpc:port_num(), boolean(), lhttpc:socket()) -> ok.
A client has finished one request and returns the socket to the pool, which can be new or not.
Link to this function

code_change(_, State, _)

-spec code_change(any(), state(), any()) -> {ok, state()}.
Link to this function

connection_count(PidOrName)

-spec connection_count(lhttpc:pool_id()) -> non_neg_integer().
Returns the total number of active connections maintained by the specified lhttpc pool (manager).
Link to this function

connection_count(PidOrName, _)

-spec connection_count(lhttpc:pool_id(), lhttpc:destination()) -> non_neg_integer().
Returns the number of active connections to the specific Destination maintained by the httpc manager.
Link to this function

dump_settings(PidOrName)

-spec dump_settings(lhttpc:pool_id()) -> list().
Returns the current settings in state for the specified lhttpc pool (manager).
Link to this function

ensure_call(Pool, Pid, Host, Port, Ssl, Options)

-spec ensure_call(lhttpc:pool_id(),
            pid(),
            lhttpc:host(),
            lhttpc:port_num(),
            boolean(),
            lhttpc:options()) ->
               lhttpc:socket() | no_socket.
If call contains pool_ensure option, dynamically create the pool with configured parameters. Checks the pool for a socket connected to the destination and returns it if it exists, 'undefined' otherwise.
Link to this function

handle_call(_, From, State)

-spec handle_call(any(), any(), state()) -> {reply, any(), state()}.
Link to this function

handle_cast(_, State)

-spec handle_cast(any(), state()) -> {noreply, state()}.
Link to this function

handle_info(_, State)

-spec handle_info(any(), state()) -> {noreply, state()}.
-spec init([any()]) -> {ok, state()}.
-spec list_pools() -> term().
Lists all the pools already started.
Link to this function

set_max_pool_size(PidOrName, Size)

-spec set_max_pool_size(lhttpc:pool_id(), non_neg_integer()) -> ok.
Sets the maximum pool size for the specified pool.
-spec start_link() -> {ok, pid()} | {error, already_started}.
Starts and link to the gen server. This is normally called by a supervisor.
Link to this function

start_link(Options0)

-spec start_link([{atom(), non_neg_integer()}]) -> {ok, pid()} | {error, already_started}.
Starts and link to the gen server (with options). This is normally called by a supervisor.
Link to this function

terminate(_, State)

-spec terminate(any(), state()) -> ok.
Link to this function

update_connection_timeout(PidOrName, Milliseconds)

-spec update_connection_timeout(lhttpc:pool_id(), non_neg_integer()) -> ok.
Updates the timeout for persistent connections. This will only affect future sockets handed to the manager. The sockets already managed will keep their timers.