Documentation ¶
Index ¶
- func GetDurationValue(v interface{}) (time.Duration, error)
- func NullDecoder(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error)
- func ParseExtendedDuration(data string) (result time.Duration, err error)
- type DNSConfig
- type DNSPolicy
- type DNSSelect
- type Duration
- type HostnameTrie
- type IPPool
- type NullDNSPolicy
- type NullDNSSelect
- type NullDuration
- type NullHostnameTrie
- type NullIPPool
- type ScriptException
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDurationValue ¶ added in v0.32.0
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 NullDecoder ¶ added in v0.22.0
NullDecoder converts data with expected type f to a guregu/null value of equivalent type t. It returns an error if a type mismatch occurs.
Types ¶
type DNSConfig ¶ added in v0.32.0
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 // lib.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 ¶ added in v0.32.0
func DefaultDNSConfig() DNSConfig
DefaultDNSConfig returns the default DNS configuration.
func (*DNSConfig) UnmarshalJSON ¶ added in v0.32.0
UnmarshalJSON implements json.Unmarshaler.
func (*DNSConfig) UnmarshalText ¶ added in v0.32.0
UnmarshalText implements encoding.TextUnmarshaler.
type DNSPolicy ¶ added in v0.32.0
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 ¶ added in v0.32.0
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 ¶ added in v0.32.0
func DNSPolicyValues() []DNSPolicy
DNSPolicyValues returns all values of the enum
func (DNSPolicy) IsADNSPolicy ¶ added in v0.32.0
IsADNSPolicy returns "true" if the value is listed in the enum definition. "false" otherwise
func (DNSPolicy) MarshalJSON ¶ added in v0.32.0
MarshalJSON returns the JSON representation of d.
func (*DNSPolicy) UnmarshalJSON ¶ added in v0.32.0
UnmarshalJSON converts JSON data to a valid DNSPolicy
type DNSSelect ¶ added in v0.32.0
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 ¶ added in v0.32.0
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 ¶ added in v0.32.0
func DNSSelectValues() []DNSSelect
DNSSelectValues returns all values of the enum
func (DNSSelect) IsADNSSelect ¶ added in v0.32.0
IsADNSSelect returns "true" if the value is listed in the enum definition. "false" otherwise
func (DNSSelect) MarshalJSON ¶ added in v0.32.0
MarshalJSON returns the JSON representation of d.
func (*DNSSelect) UnmarshalJSON ¶ added in v0.32.0
UnmarshalJSON converts JSON data to a valid DNSSelect
type Duration ¶
Duration is an alias for time.Duration that de/serialises to JSON as human-readable strings.
func (Duration) MarshalJSON ¶
MarshalJSON returns the JSON representation of d
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON converts JSON data to Duration
func (*Duration) UnmarshalText ¶
UnmarshalText converts text data to Duration
type HostnameTrie ¶ added in v0.32.0
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 ¶ added in v0.32.0
func NewHostnameTrie(source []string) (*HostnameTrie, error)
NewHostnameTrie returns a pointer to a new HostnameTrie or an error if the input is incorrect
type IPPool ¶ added in v0.32.0
type IPPool struct {
// contains filtered or unexported fields
}
IPPool represent a slice of IPBlocks
func NewIPPool ¶ added in v0.32.0
NewIPPool returns an IPPool slice from the provided string representation that should be comma separated list of IPs, IP ranges(ip1-ip2) and CIDRs
type NullDNSPolicy ¶ added in v0.32.0
NullDNSPolicy is a nullable wrapper around DNSPolicy, required for the current configuration system.
func (NullDNSPolicy) MarshalJSON ¶ added in v0.32.0
func (d NullDNSPolicy) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of d.
func (*NullDNSPolicy) UnmarshalJSON ¶ added in v0.32.0
func (d *NullDNSPolicy) UnmarshalJSON(data []byte) error
UnmarshalJSON converts JSON data to a valid NullDNSPolicy.
type NullDNSSelect ¶ added in v0.32.0
NullDNSSelect is a nullable wrapper around DNSSelect, required for the current configuration system.
func (NullDNSSelect) MarshalJSON ¶ added in v0.32.0
func (d NullDNSSelect) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of d.
func (*NullDNSSelect) UnmarshalJSON ¶ added in v0.32.0
func (d *NullDNSSelect) UnmarshalJSON(data []byte) error
UnmarshalJSON converts JSON data to a valid NullDNSSelect.
type NullDuration ¶
NullDuration is a nullable Duration, in the same vein as the nullable types provided by package gopkg.in/guregu/null.v3.
func NewNullDuration ¶ added in v0.21.0
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) 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 ¶ added in v0.26.0
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 NullHostnameTrie ¶ added in v0.32.0
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 ¶ added in v0.32.0
func NewNullHostnameTrie(source []string) (NullHostnameTrie, error)
NewNullHostnameTrie returns a NullHostnameTrie encapsulating HostnameTrie or an error if the input is incorrect
func (NullHostnameTrie) MarshalJSON ¶ added in v0.32.0
func (d NullHostnameTrie) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface
func (*NullHostnameTrie) UnmarshalJSON ¶ added in v0.32.0
func (d *NullHostnameTrie) UnmarshalJSON(data []byte) error
UnmarshalJSON converts JSON data to a valid NullHostnameTrie
func (*NullHostnameTrie) UnmarshalText ¶ added in v0.32.0
func (d *NullHostnameTrie) UnmarshalText(data []byte) error
UnmarshalText converts text data to a valid NullHostnameTrie
type NullIPPool ¶ added in v0.32.0
NullIPPool is a nullable IPPool
func (*NullIPPool) UnmarshalText ¶ added in v0.32.0
func (n *NullIPPool) UnmarshalText(data []byte) error
UnmarshalText converts text data to a valid NullIPPool
type ScriptException ¶ added in v0.32.0
type ScriptException interface { error // StackTrace is the string representation of the stacktrace of where the script exception happened StackTrace() string }
ScriptException is an interface used to represent an error as a result of a script exception.