checks

package
v0.0.0-...-e099475 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout      = Timeout(20 * time.Second)
	DefaultRetries      = 3
	DefaultWait         = Timeout(1 * time.Second)
	DefaultConcurrency  = 10
	DefaultPingTimeout  = Timeout(1 * time.Second)
	DefaultPingCount    = 10
	DefaultPingInterval = Timeout(100 * time.Millisecond)
	DefaultPingSize     = 64
)

Variables

View Source
var MockBundles = []TrackedBundle{
	{
		// contains filtered or unexported fields
	},
	{
		// contains filtered or unexported fields
	},
}

Functions

This section is empty.

Types

type Bundle

type Bundle struct {
	ID          string  `json:"id,omitempty" yaml:"id,omitempty"`
	Description string  `json:"description,omitempty" yaml:"description,omitempty"`
	Timeout     Timeout `json:"timeout,omitempty" yaml:"timeout,omitempty"`
	Retries     int     `json:"retries,omitempty" yaml:"retries,omitempty"`
	Wait        Timeout `json:"wait,omitempty" yaml:"wait,omitempty"`
	Concurrency int     `json:"concurrency,omitempty" yaml:"concurrency,omitempty"`
	Checks      []Check `json:"checks,omitempty" yaml:"checks,omitempty"`
}

Bundle represents a consistent set of checks, with some package-level defaults.

func New

func New(path string) (*Bundle, error)

New fetches the bundle data from the given path, parses it and returns a Bundle object with all checks ready to be run.

func (*Bundle) Check

func (b *Bundle) Check()

Check creates a goroutine pool, enqueues all the Checks to the workers in the pool and then waits for the Checks to come back with the actual result.

func (*Bundle) ToJSON

func (b *Bundle) ToJSON() string

ToJSON returns a JSON representation of the Bundle.

func (*Bundle) ToYAML

func (b *Bundle) ToYAML() string

ToYAML returns a YAML representation of the Bundle.

type Check

type Check struct {
	Name     string   `json:"name,omitempty" yaml:"name,omitempty"`
	Timeout  Timeout  `json:"timeout,omitempty" yaml:"timeout,omitempty"`
	Retries  int      `json:"retries,omitempty" yaml:"retries,omitempty"`
	Wait     Timeout  `json:"wait,omitempty" yaml:"wait,omitempty"`
	Address  string   `json:"address,omitempty" yaml:"address,omitempty"`
	Protocol Protocol `json:"protocol" yaml:"protocol"`
	Result   Result   `json:"result" yaml:"result"`
	// contains filtered or unexported fields
}

Check represents a single check to perform.

func (*Check) Do

func (c *Check) Do() error

Do performs the actual check.

func (*Check) ToJSON

func (c *Check) ToJSON() string

ToJSON converts the Check to its JSON pretty representation.

func (*Check) ToYAML

func (c *Check) ToYAML() string

ToYAML converts the Check to its YAML representation.

type Defaults

type Defaults struct {
	Timeout     *Timeout `yaml:"timeout"`
	Retries     *int     `yaml:"retries"`
	Wait        *Timeout `yaml:"wait"`
	Concurrency *int     `yaml:"concurrency"`
	Ping        *struct {
		Count    *int     `yaml:"count"`
		Interval *Timeout `yaml:"interval"`
		Size     *int     `yaml:"size"`
	} `yaml:"ping"`
}
var Default *Defaults

type Protocol

type Protocol uint8

Protocol represents the supported protocols.

const (
	TCP Protocol = iota
	UDP
	ICMP
	TLS
	DTLS // TLS over UDP
	SSH
)

func (*Protocol) FromString

func (p *Protocol) FromString(value string) error

FromString returns the Protocol value corresponding to the given string representation.

func (Protocol) MarshalJSON

func (p Protocol) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Protocol struct to JSON.

func (Protocol) MarshalText

func (p Protocol) MarshalText() (text []byte, err error)

MarshalText marshals the Timeout struct to text.

func (Protocol) MarshalYAML

func (p Protocol) MarshalYAML() (any, error)

MarshalYAML marshals the Timeout struct to YAML.

func (Protocol) String

func (p Protocol) String() string

String returns a string representation of the Protocol.

func (*Protocol) UnmarshalJSON

func (p *Protocol) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON marshals the Timeout struct from JSON.

func (*Protocol) UnmarshalText

func (p *Protocol) UnmarshalText(text []byte) error

UnmarshalText marshals the Timeout struct from text.

func (*Protocol) UnmarshalYAML

func (p *Protocol) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML marshals the Timeout struct from YAML.

type Result

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

Result represents the result of a check.

func (Result) IsError

func (r Result) IsError() bool

IsError returns whether the Result represents an error.

func (Result) MarshalJSON

func (r Result) MarshalJSON() ([]byte, error)

MarshalJSON produces the JSON value for the Result.

func (Result) MarshalYAML

func (r Result) MarshalYAML() (any, error)

MarshalYAML returns the YAML value for the Result.

func (Result) String

func (r Result) String() string

String returns a string representation of the Result.

type Timeout

type Timeout time.Duration

Timeout wraps the native time.Duration time, adding JSON, YAML and TOML marshalling/unmarshalling capabilities.

func (Timeout) MarshalJSON

func (t Timeout) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Timeout struct to JSON.

func (Timeout) MarshalText

func (t Timeout) MarshalText() (text []byte, err error)

MarshalText marshals the Timeout struct to text.

func (Timeout) MarshalYAML

func (t Timeout) MarshalYAML() (any, error)

MarshalYAML marshals the Timeout struct to YAML.

func (Timeout) String

func (t Timeout) String() string

String returns a string representation of the Timeout.

func (*Timeout) UnmarshalJSON

func (t *Timeout) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON unmarshals the Timeout struct from JSON.

func (*Timeout) UnmarshalText

func (t *Timeout) UnmarshalText(text []byte) error

UnmarshalText unmarshals the Timeout struct from text.

func (*Timeout) UnmarshalYAML

func (t *Timeout) UnmarshalYAML(node *yaml.Node) (err error)

UnmarshalYAML unmarshals the Timeout struct from YAML.

type TrackedBundle

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

func (*TrackedBundle) Checks

func (g *TrackedBundle) Checks() []TrackedCheck

func (*TrackedBundle) ChecksAccessed

func (g *TrackedBundle) ChecksAccessed() bool

func (*TrackedBundle) Concurrency

func (g *TrackedBundle) Concurrency() int

func (*TrackedBundle) ConcurrencyAccessed

func (g *TrackedBundle) ConcurrencyAccessed() bool

func (*TrackedBundle) Description

func (g *TrackedBundle) Description() string

func (*TrackedBundle) DescriptionAccessed

func (g *TrackedBundle) DescriptionAccessed() bool

func (*TrackedBundle) ID

func (g *TrackedBundle) ID() string

func (*TrackedBundle) IDAccessed

func (g *TrackedBundle) IDAccessed() bool

func (*TrackedBundle) Retries

func (g *TrackedBundle) Retries() int

func (*TrackedBundle) RetriesAccessed

func (g *TrackedBundle) RetriesAccessed() bool

func (*TrackedBundle) Timeout

func (g *TrackedBundle) Timeout() Timeout

func (*TrackedBundle) TimeoutAccessed

func (g *TrackedBundle) TimeoutAccessed() bool

func (*TrackedBundle) Wait

func (g *TrackedBundle) Wait() Timeout

func (*TrackedBundle) WaitAccessed

func (g *TrackedBundle) WaitAccessed() bool

type TrackedCheck

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

func (*TrackedCheck) Address

func (g *TrackedCheck) Address() string

func (*TrackedCheck) AddressAccessed

func (g *TrackedCheck) AddressAccessed() bool

func (*TrackedCheck) Description

func (g *TrackedCheck) Description() string

func (*TrackedCheck) DescriptionAccessed

func (g *TrackedCheck) DescriptionAccessed() bool

func (*TrackedCheck) Protocol

func (g *TrackedCheck) Protocol() Protocol

func (*TrackedCheck) ProtocolAccessed

func (g *TrackedCheck) ProtocolAccessed() bool

func (*TrackedCheck) Result

func (g *TrackedCheck) Result() Result

func (*TrackedCheck) ResultAccessed

func (g *TrackedCheck) ResultAccessed() bool

func (*TrackedCheck) Retries

func (g *TrackedCheck) Retries() int

func (*TrackedCheck) RetriesAccessed

func (g *TrackedCheck) RetriesAccessed() bool

func (*TrackedCheck) Timeout

func (g *TrackedCheck) Timeout() Timeout

func (*TrackedCheck) TimeoutAccessed

func (g *TrackedCheck) TimeoutAccessed() bool

func (*TrackedCheck) Wait

func (g *TrackedCheck) Wait() Timeout

func (*TrackedCheck) WaitAccessed

func (g *TrackedCheck) WaitAccessed() bool

Jump to

Keyboard shortcuts

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