check / check (push) Failing after 1m42s
Neither Server embeds *http.Server any more. Each holds it as a private field, is its handler, and has Serve, Shutdown, Close and ServeHTTP. sww's serve hook takes the new daemonServer interface of those first three, and fx provides each Server as it. Model: opus-5-5
38 lines
943 B
Go
38 lines
943 B
Go
package rproxy
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
// HTTPServer is Go's server s holds, for tests that read its settings.
|
|
func (s *Server) HTTPServer() *http.Server {
|
|
return s.httpServer
|
|
}
|
|
|
|
// StopBreakerClock has the circuit breaker of s read at as the time, so that how
|
|
// long requests take cannot matter to it. It is called before s serves.
|
|
func (s *Server) StopBreakerClock(at time.Time) {
|
|
s.h.breakerClock = func() time.Time { return at }
|
|
}
|
|
|
|
// 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 rproxy can use.
|
|
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)
|
|
}
|