Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #55 from bbc/promises
Browse files Browse the repository at this point in the history
Feature: Expose Client for simpler promisification
  • Loading branch information
robinjmurphy authored Jan 3, 2017
2 parents fa97175 + 7766e59 commit 5d54d86
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ npm install --save flashheart
* [StatsD integration](#stats)
* [Retries](#retries)
* [Circuit breaker](#circuit-breaker)
* [Promises](#promises)

## Usage

Expand Down Expand Up @@ -217,6 +218,21 @@ const client = require('flashheart').createClient({
});
```

### Promises

Flashheart uses callbacks, but we expose the `Client` constructor to make it easy to [promisify](http://bluebirdjs.com/docs/api/promisification.html) the entire library:

```js
const Promise = require('bluebird');
const Client = require('flashheart').Client;
const client = require('flashheart').createClient();

Promise.promisifyAll(Client.prototype);

client.getAsync('http://httpstat.us/200')
.then((body) => console.log(body));
```

## API

#### Callback return values
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ module.exports.createClient = function (opts) {

return client;
};

module.exports.Client = Client;

0 comments on commit 5d54d86

Please sign in to comment.