コード例 #1
0
ファイル: failrate.go プロジェクト: GitHub9527/vulcan
func (r *RollingMeter) ObserveResponse(req request.Request, lastAttempt request.Attempt) {
	if lastAttempt == nil || lastAttempt.GetEndpoint() != r.endpoint {
		return
	}

	if r.isError(lastAttempt) {
		r.errors.Inc()
	} else {
		r.successes.Inc()
	}
}
コード例 #2
0
ファイル: cbreaker.go プロジェクト: GitHub9527/vulcan
func (c *CircuitBreaker) ProcessResponse(r request.Request, a request.Attempt) {
	// We should not record metrics for the requests intercepted by circuit breaker
	// otherwise our metrics would be incorrect
	if c.shouldRecordMetrics(r) {
		c.metrics.RecordMetrics(a)
	}

	// Note that this call is less expensive than it looks -- checkCondition only performs the real check
	// periodically. Because of that we can afford to call it here on every single response.
	if c.checkCondition(r) {
		c.setTripped(a.GetEndpoint())
	}
}
コード例 #3
0
ファイル: roundrobin.go プロジェクト: GitHub9527/vulcan
func (rr *RoundRobin) ObserveResponse(req request.Request, a request.Attempt) {
	rr.mutex.Lock()
	defer rr.mutex.Unlock()

	if a == nil || a.GetEndpoint() == nil {
		return
	}
	we, _ := rr.findEndpointByUrl(a.GetEndpoint().GetUrl())
	if we == nil {
		return
	}

	// Update endpoint stats: failure count and request roundtrip
	we.meter.ObserveResponse(req, a)
}