# cueball-resolver

> Cueball resolver for Euroeka service discovery

Latest version **1.0.2** (published 2017-10-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install cueball-resolver
pnpm add cueball-resolver
yarn add cueball-resolver
bun add cueball-resolver
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2017-10-13 |
| First published | 2017-10-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Peter Marton |
| Maintainers | hekike |

## Links

- npm: https://www.npmjs.com/package/cueball-resolver
- Repository: https://github.com/hekike/cueball-resolver
- Homepage: https://github.com/hekike/cueball-resolver#readme
- Issues: https://github.com/hekike/cueball-resolver/issues
- npm.io page: https://npm.io/package/cueball-resolver

## Dependencies (3)

- [chai](https://npm.io/package/chai.md) 4.1.2
- [ipaddr.js](https://npm.io/package/ipaddr.js.md) 1.5.3
- [mooremachine](https://npm.io/package/mooremachine.md) 2.2.0

## Recent versions

- 1.0.2 (latest) — 2017-10-13
- 1.0.1 — 2017-10-05
- 1.0.0 — 2017-10-05

## README

# cueball-resolver

[![Build Status](https://travis-ci.org/hekike/cueball-resolver.svg?branch=master)](https://travis-ci.org/hekike/cueball-resolver)  

Custom Resolver for https://joyent.github.io/node-cueball  
Static IP resolver with add and remove interface.  

## Install

```js
npm install cueball-resolver
```

## API

See for the complete API: https://joyent.github.io/node-cueball/#resolver

### new Resolver(options)

- `options` -- Object, with keys:
  - `defaultPort` -- optional Number (defaults to 80), fallback port to use for backends
    that only have an `address` property
  - `backends` -- Array of objects, each having properties (optional, defaults to []):
    - `address` -- String, an IP address to emit as a backend
    - `port` -- Number (optional, defaults to 80), a port number
        for this backend

### addBackend(backend)

Adds a new backend.

- `backend` -- object:
  - `address` -- String, an IP address to emit as a backend
  - `port` -- Number (optional, defaults to 80), a port number
      for this backend

Returns with the backend.

### removeBackend(backend)

Removes a backend.

- `backend` -- object:
  - `address` -- String, an IP address to emit as a backend
  - `port` -- Number (optional, defaults to 80), a port number
      for this backend

Returns with the backend.

### resetBackends([backends])

Clears all backends and add news if provided.

- `backends` -- Array of objects, each having properties (optional, defaults to []):
  - `address` -- String, an IP address to emit as a backend
  - `port` -- Number (optional, defaults to 80), a port number
      for this backend

## How to use

```js
const bunyan = require('bunyan')
const cueball = require('cueball')
const restifyClients = require('restify-clients')
const Resolver = require('cueball-resolver')

const agent = new cueball.HttpAgent({
  log: bunyan.createLogger({
    name: 'agent-test',
    level: process.env.LOG_LEVEL || 'error'
  }),
  spares: 2,
  maximum: 4,
  recovery: {
    default: {
      timeout: 50,
      retries: 2,
      delay: 5,
      maxDelay: 50
    }
  }
})

const client = restifyClients.createStringClient({
  url: 'http://test.host.com',
  agent
})

const resolver = new Resolver({
  backends: [
    {
      address: '127.0.0.1',
      port: 1234
    }
  ]
})

resolver.start()

agent.createPool('test.host.com', {
  resolver
})

client.get('/test', (err, req, res, data) => {}
```

## How it works

See: https://joyent.github.io/node-cueball/#resolver

---
_Source: https://npm.io/package/cueball-resolver · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
