Documentation ¶
Index ¶
Constants ¶
const ( // RequestTimeout is the default timeout for the polling requests. RequestTimeout = 5 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func DefaultErrorRetryChecker ¶
DefaultErrorRetryChecker implements the defaults for retrying on error.
func ResolveEndpoint ¶
func ResolveEndpoint(kubeClientset *kubernetes.Clientset, domain string, resolvable bool, endpointOverride string) (string, error)
ResolveEndpoint resolves the endpoint address considering whether the domain is resolvable and taking into account whether the user overrode the endpoint address externally
Types ¶
type ErrorRetryChecker ¶
ErrorRetryChecker is used to determine if an error should be retried or not. If an error should be retried, it should return true and the wrapped error to explain why to retry.
type Interface ¶
type Interface interface { Do(*http.Request) (*Response, error) Poll(*http.Request, ResponseChecker, ...ErrorRetryChecker) (*Response, error) }
Interface defines the actions that can be performed by the spoofing client.
type Response ¶
Response is a stripped down subset of http.Response. The is primarily useful for ResponseCheckers to inspect the response body without consuming it. Notably, Body is a byte slice instead of an io.ReadCloser.
type ResponseChecker ¶
ResponseChecker is used to determine when SpoofinClient.Poll is done polling. This allows you to predicate wait.PollImmediate on the request's http.Response.
See the apimachinery wait package: https://github.com/kubernetes/apimachinery/blob/cf7ae2f57dabc02a3d215f15ca61ae1446f3be8f/pkg/util/wait/wait.go#L172
type SpoofingClient ¶
type SpoofingClient struct { Client *http.Client RequestInterval time.Duration RequestTimeout time.Duration Logf logging.FormatLogger }
SpoofingClient is a minimal HTTP client wrapper that spoofs the domain of requests for non-resolvable domains.
func New ¶
func New( kubeClientset *kubernetes.Clientset, logf logging.FormatLogger, domain string, resolvable bool, endpointOverride string, opts ...TransportOption) (*SpoofingClient, error)
New returns a SpoofingClient that rewrites requests if the target domain is not `resolvable`. It does this by looking up the ingress at construction time, so reusing a client will not follow the ingress if it moves (or if there are multiple ingresses).
If that's a problem, see test/request.go#WaitForEndpointState for oneshot spoofing.
func (*SpoofingClient) Do ¶
func (sc *SpoofingClient) Do(req *http.Request) (*Response, error)
Do dispatches to the underlying http.Client.Do, spoofing domains as needed and transforming the http.Response into a spoof.Response. Each response is augmented with "ZipkinTraceID" header that identifies the zipkin trace corresponding to the request.
func (*SpoofingClient) Poll ¶
func (sc *SpoofingClient) Poll(req *http.Request, inState ResponseChecker, errorRetryCheckers ...ErrorRetryChecker) (*Response, error)
Poll executes an http request until it satisfies the inState condition or encounters an error.