Skip to content

Client Socket Pool

Sudheer edited this page Mar 11, 2023 · 7 revisions

A set of functions to manage connections in a socket connection pool { ({type, host, name}, [ss_ptr]) } This module provides a single pool per instance of evlua/evluaserver The module Socket connection pool repository(evpoolrepos) provides an interface to manage multiple repositories per instance of evlua/evluaserver {(pool_name, pool)} and is a better implementation of socket connection pool. It is recommended to use that interface rather than this.

Constructor

local client_socket_pool = require('libevclient');

client_socket_pool.add_to_pool(type, host, name, ss_ptr);

Adds connection to the pool

Parameters:
    type: string (e.g. SMTP, HTTP etc.)
    host: string
    name: string (e.g. 'AAA', 'ROC', ...)
    ss_ptr: handle to client socket
Return:
    none

ERROR:
    Exceptions are thrown upon error, which can be caught via mechanism of pcall/xpcall

client_socket_pool.get_from_pool(type, host, name);

Gets a connection from the pool given the key inputs

Parameters:
    type: string (e.g. SMTP, HTTP etc.)
    host: string
    name: string (e.g. 'AAA', 'ROC', ...)
Return:
    ss_ptr: handle to client socket, nil if there is no entry

ERROR:
    Exceptions are thrown upon error, which can be caught via mechanism of pcall/xpcall

Clone this wiki locally