types

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPSingleExecutionMode   = "httpSingle"
	HTTPMultipleExecutionMode = "httpMultiple"
)
View Source
const (
	HTTPSingleLoadZone   = "httpSingle"
	HTTPMultipleLoadZone = "httpMultiple"
)
View Source
const (
	AreaGraphSeriesType   = "area"
	LineGraphSeriesType   = "line"
	ColumnGraphSeriesType = "column"
)

Variables

This section is empty.

Functions

func GetDurationValue

func GetDurationValue(v interface{}) (time.Duration, error)

GetDurationValue is a helper function that can convert a lot of different types to time.Duration.

TODO: move to a separate package and check for integer overflows?

func IsBuiltinMetric

func IsBuiltinMetric(metricName string) bool

func IsValidSeriesKind

func IsValidSeriesKind(kind string) bool

func ParseExtendedDuration

func ParseExtendedDuration(data string) (result time.Duration, err error)

ParseExtendedDuration is a helper function that allows for string duration values containing days.

func ValidSeriesColor

func ValidSeriesColor(color string) bool

Ensures color is a valid hex color

Types

type DNSConfig

type DNSConfig struct {
	// If positive, defines how long DNS lookups should be returned from the cache.
	TTL null.String `json:"ttl"`
	// Select specifies the strategy to use when picking a single IP if more than one is returned for a host name.
	Select NullDNSSelect `json:"select"`
	// Policy specifies how to handle returning of IPv4 or IPv6 addresses.
	Policy NullDNSPolicy `json:"policy"`
	// FIXME: Valid is unused and is only added to satisfy some logic in
	// libWorker.Options.ForEachSpecified(), otherwise it would panic with
	// `reflect: call of reflect.Value.Bool on zero Value`.
	Valid bool `json:"-"`
}

DNSConfig is the DNS resolver configuration.

func DefaultDNSConfig

func DefaultDNSConfig() DNSConfig

DefaultDNSConfig returns the default DNS configuration.

func (DNSConfig) String

func (c DNSConfig) String() string

String implements fmt.Stringer.

func (*DNSConfig) UnmarshalJSON

func (c *DNSConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*DNSConfig) UnmarshalText

func (c *DNSConfig) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type DNSPolicy

type DNSPolicy uint8

DNSPolicy specifies the preference for handling IP versions in DNS resolutions.

const (
	// DNSpreferIPv4 returns an IPv4 address if available, falling back to IPv6 otherwise.
	DNSpreferIPv4 DNSPolicy = iota + 1
	// DNSpreferIPv6 returns an IPv6 address if available, falling back to IPv4 otherwise.
	DNSpreferIPv6
	// DNSonlyIPv4 only returns an IPv4 address and the resolution will fail if no IPv4 address is found.
	DNSonlyIPv4
	// DNSonlyIPv6 only returns an IPv6 address and the resolution will fail if no IPv6 address is found.
	DNSonlyIPv6
	// DNSany returns any resolved address regardless of version.
	DNSany
)

These are lower camel cased since enumer doesn't support it as a transform option. See https://github.com/alvaroloes/enumer/pull/60 .

func DNSPolicyString

func DNSPolicyString(s string) (DNSPolicy, error)

DNSPolicyString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func DNSPolicyValues

func DNSPolicyValues() []DNSPolicy

DNSPolicyValues returns all values of the enum

func (DNSPolicy) IsADNSPolicy

func (i DNSPolicy) IsADNSPolicy() bool

IsADNSPolicy returns "true" if the value is listed in the enum definition. "false" otherwise

func (DNSPolicy) MarshalJSON

func (d DNSPolicy) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of d.

func (DNSPolicy) String

func (i DNSPolicy) String() string

func (*DNSPolicy) UnmarshalJSON

func (d *DNSPolicy) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON data to a valid DNSPolicy

type DNSSelect

type DNSSelect uint8

DNSSelect is the strategy to use when picking a single IP if more than one is returned for a host name.

const (
	// DNSfirst returns the first IP from the response.
	DNSfirst DNSSelect = iota + 1
	// DNSroundRobin rotates the IP returned on each lookup.
	DNSroundRobin
	// DNSrandom returns a random IP from the response.
	DNSrandom
)

These are lower camel cased since enumer doesn't support it as a transform option. See https://github.com/alvaroloes/enumer/pull/60 .

func DNSSelectString

func DNSSelectString(s string) (DNSSelect, error)

DNSSelectString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func DNSSelectValues

func DNSSelectValues() []DNSSelect

DNSSelectValues returns all values of the enum

func (DNSSelect) IsADNSSelect

func (i DNSSelect) IsADNSSelect() bool

IsADNSSelect returns "true" if the value is listed in the enum definition. "false" otherwise

func (DNSSelect) MarshalJSON

func (d DNSSelect) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of d.

func (DNSSelect) String

func (i DNSSelect) String() string

func (*DNSSelect) UnmarshalJSON

func (d *DNSSelect) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON data to a valid DNSSelect

type Duration

type Duration time.Duration

Duration is an alias for time.Duration that de/serialises to JSON as human-readable strings.

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of d

func (Duration) String

func (d Duration) String() string

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON data to Duration

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(data []byte) error

UnmarshalText converts text data to Duration

type HostnameTrie

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

HostnameTrie is a tree-structured list of hostname matches with support for wildcards exclusively at the start of the pattern. Items may only be inserted and searched. Internationalized hostnames are valid.

func NewHostnameTrie

func NewHostnameTrie(source []string) (*HostnameTrie, error)

NewHostnameTrie returns a pointer to a new HostnameTrie or an error if the input is incorrect

func (*HostnameTrie) Contains

func (t *HostnameTrie) Contains(s string) (matchedPattern string, matchFound bool)

Contains returns whether s matches a pattern in the HostnameTrie along with the matching pattern, if one was found.

type IPPool

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

IPPool represent a slice of IPBlocks

func NewIPPool

func NewIPPool(ranges string) (*IPPool, error)

NewIPPool returns an IPPool slice from the provided string representation that should be comma separated list of IPs, IP ranges(ip1-ip2) and CIDRs

func (*IPPool) GetIP

func (pool *IPPool) GetIP(index uint64) net.IP

GetIP return an IP from a pool of IPBlock slice

func (*IPPool) GetIPBig

func (pool *IPPool) GetIPBig(index *big.Int) net.IP

GetIPBig returns an IP from the pool with the provided index that is big.Int

type LoadZone

type LoadZone struct {
	Location string  `json:"location"`
	Fraction float64 `json:"fraction"`
}

type MetricGraph

type MetricGraph struct {
	Name         string              `json:"name"`
	Description  string              `json:"description"`
	Series       []MetricGraphSeries `json:"series"`
	DesiredWidth int                 `json:"desiredWidth"`
}

type MetricGraphSeries

type MetricGraphSeries struct {
	LoadZone string `json:"loadZone"`
	Metric   string `json:"metric"`
	Kind     string `json:"kind"`
	Color    string `json:"color"`
}

type NullDNSPolicy

type NullDNSPolicy struct {
	DNSPolicy
	Valid bool
}

NullDNSPolicy is a nullable wrapper around DNSPolicy, required for the current configuration system.

func (NullDNSPolicy) MarshalJSON

func (d NullDNSPolicy) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of d.

func (*NullDNSPolicy) UnmarshalJSON

func (d *NullDNSPolicy) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON data to a valid NullDNSPolicy.

type NullDNSSelect

type NullDNSSelect struct {
	DNSSelect
	Valid bool
}

NullDNSSelect is a nullable wrapper around DNSSelect, required for the current configuration system.

func (NullDNSSelect) MarshalJSON

func (d NullDNSSelect) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of d.

func (*NullDNSSelect) UnmarshalJSON

func (d *NullDNSSelect) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON data to a valid NullDNSSelect.

type NullDuration

type NullDuration struct {
	Duration
	Valid bool
}

NullDuration is a nullable Duration, in the same vein as the nullable types provided by package gopkg.in/guregu/null.v3.

func NewNullDuration

func NewNullDuration(d time.Duration, valid bool) NullDuration

NewNullDuration is a simple helper constructor function

func NullDurationFrom

func NullDurationFrom(d time.Duration) NullDuration

NullDurationFrom returns a new valid NullDuration from a time.Duration.

func (NullDuration) MarshalJSON

func (d NullDuration) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON representation of d

func (NullDuration) TimeDuration

func (d NullDuration) TimeDuration() time.Duration

TimeDuration returns a NullDuration's value as a stdlib Duration.

func (*NullDuration) UnmarshalJSON

func (d *NullDuration) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON data to a valid NullDuration

func (*NullDuration) UnmarshalText

func (d *NullDuration) UnmarshalText(data []byte) error

UnmarshalText converts text data to a valid NullDuration

func (NullDuration) ValueOrZero

func (d NullDuration) ValueOrZero() Duration

ValueOrZero returns the underlying Duration value of d if valid or its zero equivalent otherwise. It matches the existing guregu/null API.

type NullExecutionMode

type NullExecutionMode struct {
	Value string
	Valid bool
}

func NewNullExecutionMode

func NewNullExecutionMode(s string, valid bool) NullExecutionMode

func NullExecutionModeFrom

func NullExecutionModeFrom(s string) NullExecutionMode

func (NullExecutionMode) MarshalJSON

func (em NullExecutionMode) MarshalJSON() ([]byte, error)

func (*NullExecutionMode) UnmarshalJSON

func (em *NullExecutionMode) UnmarshalJSON(data []byte) error

func (NullExecutionMode) ValueOrZero

func (em NullExecutionMode) ValueOrZero() string

type NullHostnameTrie

type NullHostnameTrie struct {
	Trie  *HostnameTrie
	Valid bool
}

NullHostnameTrie is a nullable HostnameTrie, in the same vein as the nullable types provided by package gopkg.in/guregu/null.v3

func NewNullHostnameTrie

func NewNullHostnameTrie(source []string) (NullHostnameTrie, error)

NewNullHostnameTrie returns a NullHostnameTrie encapsulating HostnameTrie or an error if the input is incorrect

func (NullHostnameTrie) MarshalJSON

func (d NullHostnameTrie) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (*NullHostnameTrie) Source

func (d *NullHostnameTrie) Source() []string

Source return source hostnames that were used diring the construction

func (*NullHostnameTrie) UnmarshalJSON

func (d *NullHostnameTrie) UnmarshalJSON(data []byte) error

UnmarshalJSON converts JSON data to a valid NullHostnameTrie

func (*NullHostnameTrie) UnmarshalText

func (d *NullHostnameTrie) UnmarshalText(data []byte) error

UnmarshalText converts text data to a valid NullHostnameTrie

type NullIPPool

type NullIPPool struct {
	Pool  *IPPool
	Valid bool
	// contains filtered or unexported fields
}

NullIPPool is a nullable IPPool

func (*NullIPPool) MarshalText

func (n *NullIPPool) MarshalText() ([]byte, error)

MarshalText returns the IPs pool in text form

func (*NullIPPool) UnmarshalText

func (n *NullIPPool) UnmarshalText(data []byte) error

UnmarshalText converts text data to a valid NullIPPool

type NullLoadDistribution

type NullLoadDistribution struct {
	Value []LoadZone
	Valid bool
}

func NewNullLoadDistribution

func NewNullLoadDistribution(loadZone []LoadZone, valid bool) NullLoadDistribution

func NullLoadDistributionFrom

func NullLoadDistributionFrom(loadZone []LoadZone) NullLoadDistribution

func (NullLoadDistribution) MarshalJSON

func (em NullLoadDistribution) MarshalJSON() ([]byte, error)

func (*NullLoadDistribution) UnmarshalJSON

func (em *NullLoadDistribution) UnmarshalJSON(data []byte) error

type NullOutputConfig

type NullOutputConfig struct {
	Value OutputConfig
	Valid bool
}

func DefaultOutputConfig

func DefaultOutputConfig(localhost bool) NullOutputConfig

func NewNullOutputConfig

func NewNullOutputConfig(outputConfig OutputConfig, valid bool) NullOutputConfig

func NullOutputConfigFrom

func NullOutputConfigFrom(outputConfig OutputConfig) NullOutputConfig

func (NullOutputConfig) MarshalJSON

func (oc NullOutputConfig) MarshalJSON() ([]byte, error)

func (*NullOutputConfig) UnmarshalJSON

func (oc *NullOutputConfig) UnmarshalJSON(data []byte) error

type OutputConfig

type OutputConfig struct {
	Graphs []MetricGraph `json:"graphs"`
}

Jump to

Keyboard shortcuts

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