Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including pooler with all npm packages installed. Try it out:

var pooler = require("pooler")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

pooler v2.0.0

A generic pooling interface and TypeScript/JavaScript implementation.


npm npm downloads GitHub issues Travis Coverage Status GitHub license

A generic pooling interface and TypeScript/JavaScript implementation.

The interface

The heart of pooler is the interface. The interface is largely taken from the Go standard library where the two key methods are get and put.

Unique to this library is the method use. The use method is a convenience feature that abstracts the logic of both get and put by passing in a callback to be executed with a value from the pool. This is especially nice for making single queries to a database. It removes the need for a lot of boilerplate code, and also removes the possibility you forget to put the value back in the pool.

Note that the factory function implements an equal jitter exponential backoff for retrying resource creation.

pooler interface

Basic Usage

To get started, created a pooler from the implementation's option object.

basic usage with database

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free