diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 568486f3..1b2b1bfe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -86,7 +86,7 @@ Click the 'Pull Request' button and fill out the form. These are mostly notes for myself. - * Be sure you are starting from a clean slate: `npm clean && npm install` + * Be sure you are starting from a clean slate: `npm run clean && npm install` * Run standard-version: `npm run release` - this will run the `ci` task * Push to GitHub: `git push --follow-tags origin master` * Publish to npmjs.com: `npm publish` diff --git a/config/webpack.browser.config.js b/config/webpack.browser.config.js deleted file mode 100644 index 3646eea2..00000000 --- a/config/webpack.browser.config.js +++ /dev/null @@ -1,66 +0,0 @@ -const path = require('path'); -const webpack = require('webpack'); -const configs = ['opossum', 'opossum.min', 'browser-test'] - .map(key => generateConfig(key)); - -// add a webpack for tests -configs.push({ - target: 'web', - mode: 'development', - entry: './test/browser/index.js', - node: { - fs: 'empty' - }, - output: { - path: path.resolve(__dirname, '..', 'test', 'browser'), - filename: 'webpack-test.js' - }, - resolve: { - modules: ['node_modules'], - extensions: ['*', '.js'] - }, - plugins: [ - new webpack.IgnorePlugin(/prom-client/), - new webpack.DefinePlugin({ - 'process.env': { - WEB: JSON.stringify('web') - } - }) - ] -}); - -function generateConfig (name) { - const mode = name.indexOf('min') > -1 ? 'production' : 'development'; - const config = { - mode, - entry: { - circuitBreaker: './index.js' - }, - output: { - path: path.resolve(__dirname, '..', 'dist'), - filename: `${name}.js`, - sourceMapFilename: `${name}.map`, - library: 'circuitBreaker', - libraryTarget: 'umd' - }, - node: { - process: true, - console: true - }, - plugins: [ - new webpack.IgnorePlugin(/prom-client/), - new webpack.ProvidePlugin({ - 'circuitBreaker': 'opossum' - }), - new webpack.DefinePlugin({ - 'process.env': { - WEB: JSON.stringify('web') - } - }) - ], - devtool: 'source-map' - }; - return config; -} - -module.exports = configs; diff --git a/config/webpack.config.js b/config/webpack.config.js index 30904aa4..91b5215c 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -3,10 +3,35 @@ const webpack = require('webpack'); const configs = ['opossum', 'opossum.min'] .map(key => generateConfig(key)); +// add a webpack for tests +configs.push({ + target: 'web', + mode: 'development', + entry: './test/browser/index.js', + node: { + fs: 'empty' + }, + output: { + path: path.resolve(__dirname, '..', 'test', 'browser'), + filename: 'webpack-test.js' + }, + resolve: { + modules: ['node_modules'], + extensions: ['*', '.js'] + }, + plugins: [ + new webpack.IgnorePlugin(/prom-client/), + new webpack.DefinePlugin({ + 'process.env': { + WEB: JSON.stringify('web') + } + }) + ] +}); + function generateConfig (name) { const mode = name.indexOf('min') > -1 ? 'production' : 'development'; const config = { - target: 'node', mode, entry: { circuitBreaker: './index.js' @@ -23,8 +48,14 @@ function generateConfig (name) { console: true }, plugins: [ + new webpack.IgnorePlugin(/prom-client/), new webpack.ProvidePlugin({ 'circuitBreaker': 'opossum' + }), + new webpack.DefinePlugin({ + 'process.env': { + WEB: JSON.stringify('web') + } }) ], devtool: 'source-map' diff --git a/docs/index.html b/docs/index.html index 472777a5..7b32d951 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,7 +2,7 @@ - opossum 2.0.0 | Documentation + opossum 2.1.0 | Documentation @@ -15,7 +15,7 @@

opossum

-
2.0.0
+
2.1.0
Prometheus res.type('text/plain'); res.send(opossum.metrics()); }); +

The prometheusRegistry option allows to provide a existing +prom-client registry. +The metrics about the circuit will be added to the provided registry instead +of the global registry. +The default metrics +will not be added to the provided registry.

+
const opossum = require('opossum');
+const { Registry } = require('prom-client');
+
+// Create a registry
+const prometheusRegistry = new Registry();
+
+// create a circuit
+const circuit = opossum(functionThatMightFail, {
+  usePrometheus: true,
+  prometheusRegistry
+});

Hystrix

NOTE: Hystrix metrics are deprecated

A Hystrix Stream is available for use with a Hystrix Dashboard using the circuitBreaker.hystrixStats.getHystrixStream method.

diff --git a/package.json b/package.json index 952f42c1..64d508b4 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,8 @@ }, "scripts": { "prebuild": "npm run lint", - "build": "npm run build:browser && npm run build:node && npm run build:docs", - "build:node": "webpack --config=config/webpack.config.js", - "build:browser": "webpack --config=config/webpack.browser.config.js", + "build": "./test/browser/generate-index.sh && npm run build:browser && npm run build:docs", + "build:browser": "webpack --config=config/webpack.config.js", "build:docs": "npm run build:docs:html && npm run build:docs:markdown", "build:docs:html": "documentation build index.js -f html -o docs --config documentation.yml", "build:docs:markdown": "documentation build index.js -f md -o docs/opossum.md", diff --git a/test/browser/generate-index.sh b/test/browser/generate-index.sh index 69a2e781..1493e6b0 100755 --- a/test/browser/generate-index.sh +++ b/test/browser/generate-index.sh @@ -2,7 +2,9 @@ echo $PWD -file_list=$(ls -1 test/*.js) +cd test +file_list=$(ls -1 --ignore="*prometheus*" | grep .js) +cd .. requires="" for f in $file_list ; do diff --git a/test/browser/index.js b/test/browser/index.js index 75281557..f87acbb8 100644 --- a/test/browser/index.js +++ b/test/browser/index.js @@ -6,6 +6,7 @@ require('../enable-disable-test.js'); require('../error-filter-test.js'); require('../half-open-test.js'); require('../health-check-test.js'); +require('../hystrix-order-test.js'); require('../hystrix-test.js'); require('../semaphore-test.js'); require('../test.js');