pkg: Index | Files

package probe

import ""

Package probe provides liveness / readiness probe.


Package Files

client.go cobra.go controller.go option.go probe.go

func CobraCommand Uses

func CobraCommand() *cobra.Command

CobraCommand returns a command used to probe liveness or readiness of a locally-running server by checking the last modified time of target file.

type Client Uses

type Client interface {
    GetStatus() error

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

func NewFileClient Uses

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 the last modified time is not within the interval, probe controller is not running fine.

type Controller Uses

type Controller interface {
    // 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 Uses

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 Uses

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 Uses

func (o *Options) IsValid() bool

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

func (*Options) Validate Uses

func (o *Options) Validate() error

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

type Probe Uses

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 Uses

func NewProbe() *Probe

NewProbe creates a new Emitter instance.

func (*Probe) IsAvailable Uses

func (p *Probe) IsAvailable() error

IsAvailable returns the current status.

func (*Probe) RegisterProbe Uses

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

RegisterProbe implements SupportsProbe interface.

func (*Probe) SetAvailable Uses

func (p *Probe) SetAvailable(newStatus error)

SetAvailable sets the new status, and notifies the controller.

func (*Probe) String Uses

func (p *Probe) String() string

String implements fmt.Stringer interface.

type SupportsProbe Uses

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

SupportsProbe provides the interface to register itself to a controller.

Package probe imports 10 packages (graph) and is imported by 17 packages. Updated 2020-02-22. Refresh now. Tools for package owners.