probes

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PROBE_TIMEOUT = 3 * time.Second

	ProbeDelayVariance = 0.5
)

Variables

View Source
var (
	ExpectedResponses = []int{200, 201}

	ProbeDelay = float64(time.Second.Milliseconds())
)

Functions

func TransportWithDNSResponse

func TransportWithDNSResponse(overrides map[string]string, allowInsecureCertificates bool) http.RoundTripper

TransportWithDNSResponse creates a new transport which overrides hostnames.

Types

type Probe

type Probe struct {
	Transport RoundTripperFunc
	// contains filtered or unexported fields
}

func NewProbe

func NewProbe(headers v1alpha1.AdditionalHeaders) *Probe

func (*Probe) ExecuteProbe

func (w *Probe) ExecuteProbe(ctx context.Context, probe *v1alpha1.DNSHealthCheckProbe) <-chan ProbeResult

ExecuteProbe executes the health check request on a background routine at the correct interval. It returns a channel on which it will send each probe result

func (*Probe) Start

func (w *Probe) Start(clientctx context.Context, k8sClient client.Client, probe *v1alpha1.DNSHealthCheckProbe) context.CancelFunc

Start a worker in a separate gouroutine. Returns a cancel func to kill the worker. If a worker is nil, no routines will start and cancel could be ignored (still returning it to prevent panic)

type ProbeManager

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

func NewProbeManager

func NewProbeManager() *ProbeManager

func (*ProbeManager) EnsureProbeWorker

func (m *ProbeManager) EnsureProbeWorker(ctx context.Context, k8sClient client.Client, probeCR *v1alpha1.DNSHealthCheckProbe, headers v1alpha1.AdditionalHeaders)

EnsureProbeWorker ensures a new worker per generation of the probe. New generation of probe - new worker. If the generation has not changed, it will re-create a worker. If context is done (we are deleting) that worker will die immediately.

func (*ProbeManager) StopProbeWorker

func (m *ProbeManager) StopProbeWorker(ctx context.Context, probeCR *v1alpha1.DNSHealthCheckProbe)

StopProbeWorker stops the worker and removes it from the WorkerManager

type ProbeResult

type ProbeResult struct {
	// CheckedAt the current helath check time
	CheckedAt metav1.Time
	// PreviousCheck the time it was checked before the current check
	PreviousCheck metav1.Time
	Healthy       bool
	Reason        string
	Status        int
}

type RoundTripperFunc

type RoundTripperFunc func(*http.Request) (*http.Response, error)

func (RoundTripperFunc) RoundTrip

func (fn RoundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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