src/middlewares/circuit-breaker.js
function trip(item, ctx) {
		item.state = C.CIRCUIT_OPEN;
		item.ep.state = false;

		if (item.cbTimer) {
			clearTimeout(item.cbTimer);
			item.cbTimer = null;
		}

		item.cbTimer = setTimeout(() => halfOpen(item, ctx), item.opts.halfOpenTime);
		item.cbTimer.unref();

		const rate = item.count > 0 ? item.failures / item.count : 0;
		logger.debug(`Circuit breaker has been opened on '${item.ep.name}' endpoint.`, { nodeID: item.ep.id, action: item.ep.action.name, failures: item.failures, count: item.count, rate });
		broker.broadcast("$circuit-breaker.opened", { nodeID: item.ep.id, action: item.ep.action.name, failures: item.failures, count: item.count, rate });
	}
function trip(item, ctx) {
		item.state = C.CIRCUIT_OPEN;
		item.ep.state = false;

		if (item.cbTimer) {
			clearTimeout(item.cbTimer);
			item.cbTimer = null;
		}

		item.cbTimer = setTimeout(() => halfOpen(item, ctx), item.opts.halfOpenTime);
		item.cbTimer.unref();

		const rate = item.count > 0 ? item.failures / item.count : 0;
		logger.debug(`Circuit breaker has been opened on '${item.ep.name}' endpoint.`, { nodeID: item.ep.id, action: item.ep.action.name, failures: item.failures, count: item.count, rate });
		broker.broadcast("$circuit-breaker.opened", { nodeID: item.ep.id, action: item.ep.action.name, failures: item.failures, count: item.count, rate });
	}
function trip ( item , ctx ) { item . state = C . CIRCUIT_OPEN ; item . ep . state = false ; if ( item . cbTimer ) { clearTimeout ( item . cbTimer ) ; item . cbTimer = null ; } item . cbTimer = setTimeout ( ( ) => halfOpen ( item , ctx ) , item . opts . halfOpenTime ) ; item . cbTimer . unref ( ) ; const rate = item . count > 0 ? item . failures / item . count : 0 ; logger . debug ( ` ${ item . ep . name } ` , { nodeID : item . ep . id , action : item . ep . action . name , failures : item . failures , count : item . count , rate } ) ; broker . broadcast ( "$circuit-breaker.opened" , { nodeID : item . ep . id , action : item . ep . action . name , failures : item . failures , count : item . count , rate } ) ; }
Trip the circuit-breaker, change the status to open

@param {Object} item
@param {Context} ctx
Trip the circuit - breaker change the status to open