Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

callosum-client-tcp

tristanls7MIT0.1.5

TCP client for Callosum: a self-balancing distributed services protocol

self-balancing, distributed, services, client, tcp

readme

callosum-client-tcp

Stability: 1 - Experimental

NPM version

TCP Client for Callosum: a self-balancing distributed services protocol.

Usage

var CallosumClient = require('callosum-client-tcp');
var callosumClient = new CallosumClient({MAX_SLOTS: 100});

callosumClient.on('error', function (error) {
    console.log(error);
});

// add a connection to the connection pool
// client will either hang on to the connection or close it if it is not needed
callosumClient.newConnection(slot, socket);

var socket = callosumClient.getConnection();
// socket is either a connection that is available or undefined

callosumClient.returnConnection(socket);
// return a previously leased connection to the client pool

Tests

npm test

Overview

TCP Client for Callosum: a self-balancing distributed services protocol. It servers as a connection pool.

Open available connections are maintained internally via two heap data structures. The min heap data structure is maintained in order to provide a connection from the pool with the lowest slot value. The max heap data structure is maintained in order to enable rapid checking and replacing of a connection with a high slot value if a new connection with a lower slot value becomes available.

Documentation

CallosumClient

Public API

new CallosumClient([options])

callosumClient.getConnection()

callosumClient.newConnection(slot, socket)

callosumClient.returnConnection(socket)