ctl

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

ctl package contains the core business logic of the `heartbeatctl` application. It exposes a Port (interface) that provides methods for controlling Heartbeats, listing them, enabling, disabling, etc.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSelector = errors.New(
	"No selector options given, to target all heartbeats pass '.*' name expression explicitly.",
)

ErrNoSelector is an error returned when a particular method requires a non-empty selector but none was given.

Functions

This section is empty.

Types

type Port

type Port interface {
	// Get returns a list of Heartbeats. If SelectorConfig is given, the list
	// is filtered down to only include Heartbeats matching both the label and
	// field selectors or name expressions (all of which are optional),
	// otherwise all Heartbeats are returned.
	Get(*SelectorConfig) ([]heartbeat.Heartbeat, error)

	// Enable enables all heartbeats selected by given SelectorConfig, which
	// in this case must specify at least one selector or name (to target all
	// heartbeats specify a `nameExpressions=['.*']` rule explicitly).
	Enable(*SelectorConfig) ([]heartbeat.HeartbeatInfo, error)

	// Disable disables all heartbeats selected by given SelectorConfig, which
	// in this case must specify at least one selector or name (to target all
	// heartbeats specify a `nameExpressions=['.*']` rule explicitly).
	Disable(*SelectorConfig) ([]heartbeat.HeartbeatInfo, error)

	// Ping pings all heartbeats selected by given SelectorConfig, which
	// in this case must specify at least one selector or name (to target all
	// heartbeats specify a `nameExpressions=['.*']` rule explicitly).
	Ping(*SelectorConfig) (map[string]heartbeat.PingResult, error)
}

Port of the heartbeatctl application

func NewCtl

func NewCtl(r client.Port) Port

type SelectorConfig

type SelectorConfig struct {
	// NameExpressions specifies a list of regular expressions to match against
	// names of heartbeats. Note that unlike label and field selectors
	// heartbeats matching any of the names are returned, but if both name
	// expressions and any selectors are specified at the same time, the
	// heartbeat must match all to be returned.
	NameExpressions []string

	// LabelSelector specifies a selector to filter the list of returned
	// objects using a K8s-compatible label selector syntax.
	// Defaults to accepting everything.
	LabelSelector string

	// FieldSelector specifies a selector to filter the list of returned
	// objects using a K8s-compatible field selector syntax.
	// Defaults to accepting everything.
	FieldSelector string
}

SelectorConfig allow configuring selectors that specify field or label query expressions to filter a list of objects to operate on.

Jump to

Keyboard shortcuts

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