Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MinTotalBackoffDuration ¶
MinTotalBackoffDuration returns the minimum duration that backoff would wait, including all steps, not including any jitter
func NewNetDialer ¶
NewNetDialer creates a new (net).Dialer with the given connection timeout and keep alive duration.
func StartTestServer ¶
StartTestServer creates and starts an *httptest.Server in the background, then parses its URL and returns both values.
If this function returns a nil error, the caller is responsible for closing the returned server. If it returns a non-nil error, the server and URL will be nil.
Types ¶
type DialContextFunc ¶
DialContextFunc is a function that matches the (net).Dialer.DialContext functions's signature
func DialContextWithRetry ¶
func DialContextWithRetry(coreDialer *net.Dialer, backoff wait.Backoff) DialContextFunc
DialContextWithRetry creates a new DialContextFunc -- which has the same signature as the net.Conn.DialContext function -- that calls coreDialer.DialContext multiple times with an exponential backoff. The timeout of the first dial will be coreDialer.Timeout, and it will multiply by a factor of two from there.
This function is mainly used in the interceptor so that, once it sees that the target deployment has 1 or more replicas, it can forward the request. If the deployment's state changed in the time slice between detecting >=1 replicas and the network send, the connection will be retried a few times.
Thanks to Knative for inspiring this code. See GitHub link below https://github.com/knative/serving/blob/20815258c92d0f26100031c71a91d0bef930a475/vendor/knative.dev/pkg/network/transports.go#L70
type TestHTTPHandlerWrapper ¶
type TestHTTPHandlerWrapper struct {
// contains filtered or unexported fields
}
func NewTestHTTPHandlerWrapper ¶
func NewTestHTTPHandlerWrapper(hdl http.Handler) *TestHTTPHandlerWrapper
func (*TestHTTPHandlerWrapper) IncomingRequests ¶
func (t *TestHTTPHandlerWrapper) IncomingRequests() []http.Request
IncomingRequests returns a copy slice of all the requests that have been received before this function was called.
func (*TestHTTPHandlerWrapper) ServeHTTP ¶
func (t *TestHTTPHandlerWrapper) ServeHTTP(w http.ResponseWriter, r *http.Request)