check / check (push) Failing after 3m53s
Five asks that get no answer in time within five seconds open the breaker. While open, a request takes SWW_RPROXY_WAF_BACKEND_NO_ANSWER_DISPOSITION without asking waf, except one ask a second; the first answer closes it. Slow answers count as failures. SPEC.md describes it. The sww test that stops and restarts waf now waits for the breaker to close before it expects the ban again. Model: opus-5-5
24 lines
519 B
Go
24 lines
519 B
Go
package rproxy
|
|
|
|
import "time"
|
|
|
|
// Breaker is the circuit breaker, for tests that give it the time.
|
|
type Breaker struct {
|
|
b breaker
|
|
}
|
|
|
|
// MayAsk reports whether a request may ask waf at now.
|
|
func (b *Breaker) MayAsk(now time.Time) bool {
|
|
return b.b.mayAsk(now)
|
|
}
|
|
|
|
// NoteAnswer notes that an ask got an answer in time.
|
|
func (b *Breaker) NoteAnswer() {
|
|
b.b.noteAnswer()
|
|
}
|
|
|
|
// NoteFailure notes that an ask that ended at now got no answer in time.
|
|
func (b *Breaker) NoteFailure(now time.Time) {
|
|
b.b.noteFailure(now)
|
|
}
|