(opts, returnValue, error, callback)
| 9681 | var STARTING_BACK_OFF = 0; |
| 9682 | |
| 9683 | function backOff(opts, returnValue, error, callback) { |
| 9684 | if (opts.retry === false) { |
| 9685 | returnValue.emit('error', error); |
| 9686 | returnValue.removeAllListeners(); |
| 9687 | return; |
| 9688 | } |
| 9689 | /* istanbul ignore if */ |
| 9690 | if (typeof opts.back_off_function !== 'function') { |
| 9691 | opts.back_off_function = defaultBackOff; |
| 9692 | } |
| 9693 | returnValue.emit('requestError', error); |
| 9694 | if (returnValue.state === 'active' || returnValue.state === 'pending') { |
| 9695 | returnValue.emit('paused', error); |
| 9696 | returnValue.state = 'stopped'; |
| 9697 | var backOffSet = function backoffTimeSet() { |
| 9698 | opts.current_back_off = STARTING_BACK_OFF; |
| 9699 | }; |
| 9700 | var removeBackOffSetter = function removeBackOffTimeSet() { |
| 9701 | returnValue.removeListener('active', backOffSet); |
| 9702 | }; |
| 9703 | returnValue.once('paused', removeBackOffSetter); |
| 9704 | returnValue.once('active', backOffSet); |
| 9705 | } |
| 9706 | |
| 9707 | opts.current_back_off = opts.current_back_off || STARTING_BACK_OFF; |
| 9708 | opts.current_back_off = opts.back_off_function(opts.current_back_off); |
| 9709 | setTimeout(callback, opts.current_back_off); |
| 9710 | } |
| 9711 | |
| 9712 | function sortObjectPropertiesByKey(queryParams) { |
| 9713 | return Object.keys(queryParams).sort(collate).reduce(function (result, key) { |
no outgoing calls
no test coverage detected
searching dependent graphs…