Skip to content

Commit

Permalink
build: switch to standardx for linting
Browse files Browse the repository at this point in the history
  • Loading branch information
lance committed Apr 29, 2019
1 parent 6f0b66d commit 4967736
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 140 deletions.
12 changes: 11 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
{
"extends": "semistandard",
"extends": "eslint:recommended",
"env": {
"es6": true,
"node": true
},
"rules": {
"standard/no-callback-literal": "off",
"arrow-spacing": "error",
"arrow-parens": ["error", "as-needed"],
"arrow-body-style": ["error", "as-needed"],
"prefer-template": "error",
"max-len": ["warn", { "code": 80 }],
"no-unused-vars": ["warn", {
"argsIgnorePattern": "^_$|^e$|^reject$|^resolve$"
}],
"no-console": ["error", {
"allow": ["warn", "error"]
}],
"valid-jsdoc": "error"
}

Expand Down
52 changes: 27 additions & 25 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,37 @@ const defaults = {
* @param {Object} options Options for the {@link CircuitBreaker}
* @param {Number} options.timeout The time in milliseconds that action should
* be allowed to execute before timing out. Default 10000 (10 seconds)
* @param {Number} options.maxFailures The number of times the circuit can fail before
* opening. Default 10.
* @param {Number} options.resetTimeout The time in milliseconds to wait before setting
* the breaker to `halfOpen` state, and trying the action again.
* @param {Number} options.rollingCountTimeout Sets the duration of the statistical rolling
* window, in milliseconds. This is how long Opossum keeps metrics for the circuit
* breaker to use and for publishing. Default: 10000
* @param {Number} options.rollingCountBuckets Sets the number of buckets the rolling
* statistical window is divided into. So, if options.rollingCountTimeout is
* 10000, and options.rollingCountBuckets is 10, then the statistical window will
* be 1000 1 second snapshots in the statistical window. Default: 10
* @param {Number} options.maxFailures The number of times the circuit can fail
* before opening. Default 10.
* @param {Number} options.resetTimeout The time in milliseconds to wait before
* setting the breaker to `halfOpen` state, and trying the action again.
* @param {Number} options.rollingCountTimeout Sets the duration of the
* statistical rolling window, in milliseconds. This is how long Opossum keeps
* metrics for the circuit breaker to use and for publishing. Default: 10000
* @param {Number} options.rollingCountBuckets Sets the number of buckets the
* rolling statistical window is divided into. So, if
* options.rollingCountTimeout is 10000, and options.rollingCountBuckets is 10,
* then the statistical window will be 1000 1 second snapshots in the
* statistical window. Default: 10
* @param {String} options.name the circuit name to use when reporting stats
* @param {boolean} options.rollingPercentilesEnabled This property indicates whether
* execution latencies should be tracked and calculated as percentiles. If they
* are disabled, all summary statistics (mean, percentiles) are returned as -1.
* Default: false
* @param {Number} options.capacity the number of concurrent requests allowed. If the number
* currently executing function calls is equal to options.capacity, further calls
* to `fire()` are rejected until at least one of the current requests completes.
* @param {Number} options.errorThresholdPercentage the error percentage at which to open the
* circuit and start short-circuiting requests to fallback.
* @param {boolean} options.enabled whether this circuit is enabled upon construction. Default: true
* @param {boolean} options.rollingPercentilesEnabled This property indicates
* whether execution latencies should be tracked and calculated as percentiles.
* If they are disabled, all summary statistics (mean, percentiles) are
* returned as -1. Default: false
* @param {Number} options.capacity the number of concurrent requests allowed.
* If the number currently executing function calls is equal to
* options.capacity, further calls to `fire()` are rejected until at least one
* of the current requests completes.
* @param {Number} options.errorThresholdPercentage the error percentage at
* which to open the circuit and start short-circuiting requests to fallback.
* @param {boolean} options.enabled whether this circuit is enabled upon
* construction. Default: true
* @param {boolean} options.allowWarmUp determines whether to allow failures
* without opening the circuit during a brief warmup period (this is the
* `rollingCountDuration` property). Default: false
* allow before enabling the circuit. This can help in situations where no matter
* what your `errorThresholdPercentage` is, if the first execution times out or
* fails, the circuit immediately opens. Default: 0
* allow before enabling the circuit. This can help in situations where no
* matter what your `errorThresholdPercentage` is, if the first execution
* times out or fails, the circuit immediately opens. Default: 0
* @param {Number} options.volumeThreshold the minimum number of requests within
* the rolling statistical window that must exist before the circuit breaker
* can open. This is similar to `options.allowWarmUp` in that no matter how many
Expand All @@ -68,7 +71,6 @@ function factory (action, options) {
* @function factory.promisify
*
* @param {Function} action A Node.js-like asynchronous function
* @return {Function} The `action` wrapped in a promise API.
* @example
* const fs = require('fs');
* const readFilePromised = circuitBreaker.promisify(fs.readFile);
Expand Down
3 changes: 2 additions & 1 deletion lib/circuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,8 @@ function handleError (error, circuit, timeout, args, latency, resolve, reject) {
function fallback (circuit, err, args) {
if (circuit[FALLBACK_FUNCTION]) {
const result =
circuit[FALLBACK_FUNCTION].apply(circuit[FALLBACK_FUNCTION], [...args, err]);
circuit[FALLBACK_FUNCTION]
.apply(circuit[FALLBACK_FUNCTION], [...args, err]);
/**
* Emitted when the circuit breaker executes a fallback function
* @event CircuitBreaker#fallback
Expand Down
5 changes: 3 additions & 2 deletions lib/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ const EventEmitter = require('events').EventEmitter;
* @class Status
* @extends EventEmitter
* @param {Object} options for the status window
* @param {Number} options.rollingCountBuckets the number of buckets in the window
* @param {Number} options.rollingCountBuckets number of buckets in the window
* @param {Number} options.rollingCountTimeout the duration of the window
* @param {Boolean} options.rollingPercentilesEnabled whether to calculate percentiles
* @param {Boolean} options.rollingPercentilesEnabled whether to calculate
* percentiles
* @example
* // Creates a 1 second window consisting of ten time slices,
* // each 100ms long.
Expand Down
Loading

0 comments on commit 4967736

Please sign in to comment.