probe

package
v0.0.0-...-fe632b3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package probe provides liveness / readiness probe.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	GetStatus() error
}

Client is the interface to check the status of a probe controller.

func NewFileClient

func NewFileClient(opt *Options) Client

NewFileClient creates an instance of Client based on the file status specified in the path. The specified period is the interval of the probe, so if this

type Controller

type Controller interface {
	io.Closer
	Start()
	// contains filtered or unexported methods
}

Controller provides the internal interface to handle events coming from Emitters. Individual controller implementation will update its prober status.

func NewFileController

func NewFileController(opt *Options) Controller

NewFileController creates a new Controller implementation which creates a file at the specified path only when the registered emitters are all available.

type Options

type Options struct {
	// Path defines the path to the file used for the existence.
	Path string

	// UpdateInterval defines the interval for updating the file's last modified
	// time.
	UpdateInterval time.Duration
}

Options customizes the parameters of a probe.

func (*Options) IsValid

func (o *Options) IsValid() bool

IsValid returns true if some values are filled into the options.

type Probe

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

Probe manages the availability status used by Controller. Probe also implements SupportsProbe by itself, therefore a struct which embeds this can be registered.

func NewProbe

func NewProbe() *Probe

NewProbe creates a new Emitter instance.

func (*Probe) IsAvailable

func (p *Probe) IsAvailable() error

IsAvailable returns the current status.

func (*Probe) RegisterProbe

func (p *Probe) RegisterProbe(c Controller, name string)

RegisterProbe implements SupportsProbe interface.

func (*Probe) SetAvailable

func (p *Probe) SetAvailable(newStatus error)

SetAvailable sets the new status, and notifies the controller.

func (*Probe) String

func (p *Probe) String() string

String implements fmt.Stringer interface.

type SupportsProbe

type SupportsProbe interface {
	RegisterProbe(c Controller, name string)
}

SupportsProbe provides the interface to register itself to a controller.

Jump to

Keyboard shortcuts

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