probe

package
v7.5.3 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

* Copyright 2020-2024 Open Networking Foundation (ONF) and the ONF Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright 2019-2024 Open Networking Foundation (ONF) and the ONF Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

View Source
const (
	// ProbeContextKey value of context key to fetch probe
	ProbeContextKey = ProbeContextKeyType("status-update-probe")
)

Variables

This section is empty.

Functions

func UpdateStatusFromContext

func UpdateStatusFromContext(ctx context.Context, name string, status ServiceStatus)

UpdateStatusFromContext a convenience function to pull the Probe reference from the Context, if it exists, and then calling UpdateStatus on that Probe reference. If Context is nil or if a Probe reference is not associated with the ProbeContextKey then nothing happens

Types

type Probe

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

Probe reciever on which to implement probe capabilities

func GetProbeFromContext

func GetProbeFromContext(ctx context.Context) *Probe

func (*Probe) GetStatus

func (p *Probe) GetStatus(name string) ServiceStatus

func (*Probe) IsReady

func (p *Probe) IsReady() bool

func (*Probe) ListenAndServe

func (p *Probe) ListenAndServe(ctx context.Context, address string)

ListenAndServe implements 3 HTTP endpoints on the given port for healthz, readz, and detailz. Returns only on error

func (*Probe) RegisterService

func (p *Probe) RegisterService(ctx context.Context, names ...string)

RegisterService register one or more service names with the probe, status will be track against service name

func (*Probe) UpdateStatus

func (p *Probe) UpdateStatus(ctx context.Context, name string, status ServiceStatus)

UpdateStatus utility function to send a service update to the probe

func (*Probe) WithHealthFunc

func (p *Probe) WithHealthFunc(healthFunc func(map[string]ServiceStatus) bool) *Probe

WithHealthFunc override the default health calculation function

func (*Probe) WithReadyFunc

func (p *Probe) WithReadyFunc(readyFunc func(map[string]ServiceStatus) bool) *Probe

WithReadyFunc override the default ready calculation function

type ProbeContextKeyType

type ProbeContextKeyType string

ProbeContextKey used to fetch the Probe instance from a context

type ServiceStatus

type ServiceStatus int

ServiceStatus typed values for service status

const (
	// ServiceStatusUnknown initial state of services
	ServiceStatusUnknown ServiceStatus = iota

	// ServiceStatusPreparing to optionally be used for prep, such as connecting
	ServiceStatusPreparing

	// ServiceStatusPrepared to optionally be used when prep is complete, but before run
	ServiceStatusPrepared

	// ServiceStatusRunning service is functional
	ServiceStatusRunning

	// ServiceStatusStopped service has stopped, but not because of error
	ServiceStatusStopped

	// ServiceStatusFailed service has stopped because of an error
	ServiceStatusFailed

	// ServiceStatusNotReady service has started but is unable to accept requests
	ServiceStatusNotReady
)

func (ServiceStatus) String

func (s ServiceStatus) String() string

String convert ServiceStatus values to strings

type ServiceStatusUpdate

type ServiceStatusUpdate struct {
	Name   string
	Status ServiceStatus
}

ServiceStatusUpdate status update event

Jump to

Keyboard shortcuts

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