@cybridge/providers-pool

1.0.0 • Public • Published

Providers pool

Connections pool for providers from @npm/ethers.

Installing

npm i @cybridge/providers-pool

Testing

npm run test

Usage

'use strict'
const { createPool } = require('../')
const ethers = require("ethers")

/**
 * Init pool, with limit of 2 parallel connections
 */
const pool = createPool(ethers.providers.JsonRpcProvider, 2)

/**
 * Add URLs for round robing requests
 */
pool.addUrl('https://mainnet.infura.io/...')
pool.addUrl('https://rpc.ankr.com/eth_goerli')

/**
 * Get provider
 */
const provider = pool.nextProvider()

/**
 * Use provider
 */
provider.getBlockNumber().then(resp => {
  console.dir(resp)

  /**
   * Release provider
   */
  pool.releaseProvider(provider)
})

Readme

Keywords

none

Package Sidebar

Install

npm i @cybridge/providers-pool

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

6.72 kB

Total Files

8

Last publish

Collaborators

  • didkovsky
  • cybridge_technologies