prober

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package prober contains functionality for implementing probing in knative serving.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(ctx context.Context, transport http.RoundTripper, target string, ops ...interface{}) (bool, error)

Do sends a single probe to given target, e.g. `http://revision.default.svc.cluster.local:81`. Do returns whether the probe was successful or not, or there was an error probing.

Types

type Done

type Done func(arg interface{}, success bool, err error)

Done is a callback that is executed when the async probe has finished. `arg` is given by the caller at the offering time, while `success` and `err` are the return values of the `Do` call. It is assumed that the opaque arg is consistent for a given target and we will coalesce concurrent Offer invocations on target.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages async probes and makes sure we run concurrently only a single probe for the same key.

func New

func New(cb Done, transport http.RoundTripper) *Manager

New creates a new Manager, that will invoke the given callback when async probing is finished.

func (*Manager) Offer

func (m *Manager) Offer(ctx context.Context, target string, arg interface{}, period, timeout time.Duration, ops ...interface{}) bool

Offer executes asynchronous probe using `target` as the key. If a probe with the same key already exists, Offer will return false and the call is discarded. If the request is accepted, Offer returns true. Otherwise Offer starts a goroutine that periodically executes `Do`, until timeout is reached, the probe succeeds, or fails with an error. In the end the callback is invoked with the provided `arg` and probing results.

type Preparer added in v0.8.0

type Preparer func(r *http.Request) *http.Request

Preparer is a way for the caller to modify the HTTP request before it goes out.

func WithHeader added in v0.8.0

func WithHeader(name, value string) Preparer

WithHeader sets a header in the probe request.

func WithHost added in v0.8.0

func WithHost(host string) Preparer

WithHost sets the host in the probe request.

type Verifier added in v0.8.0

type Verifier func(r *http.Response, b []byte) (bool, error)

Verifier is a way for the caller to validate the HTTP response after it comes back.

func ExpectsBody added in v0.8.0

func ExpectsBody(body string) Verifier

ExpectsBody validates that the body of the probe response matches the provided string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL