我是Node.js的新手,遇到了用作断路器的堤坝,当我执行以下代码时,会发生异常
'use strict';
var Levee = require('levee');
var Wreck = require('wreck');
var options, circuit;
options = {
maxFailures: 5,
timeout: 60000,
resetTimeout: 30000
};
circuit = Levee.createBreaker(Wreck.get, options);
circuit.run('https://www.google.com', function (err, req, payload)
{
// If the service fails or timeouts occur 5 consecutive times,
// the breaker opens, fast failing subsequent requests.
console.log(err || payload);
});
例外情况如下
TypeError: this._shortcut is not a function
at Object.internals.Client.get [as execute] (/Users/amolmohandeshpande/Documents/node/node_modules/wreck/lib/index.js:580:17)
at zalgo (/Users/amolmohandeshpande/Documents/node/node_modules/levee/lib/zalgo.js:28:12)
at Breaker._run (/Users/amolmohandeshpande/Documents/node/node_modules/levee/lib/breaker.js:126:13)
at Breaker.run (/Users/amolmohandeshpande/Documents/node/node_modules/levee/lib/breaker.js:60:15)
at Object. (/Users/amolmohandeshpande/Documents/node/server.js:15:9)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)