Documentation ¶
Index ¶
- Variables
- func CaptureHost(hostport string) string
- func CheckHostnameIPMismatch(local string, hostsMap map[string][]string) ([]string, error)
- func CheckLocalMissing(local string, hostports []string) error
- func HostPortsByHost(hostports []string) (hostMap map[string][]string)
- func MS(d time.Duration) int64
- func Min(first int, rest ...int) int
- func SelectBool(opt, def bool) bool
- func SelectDuration(opt, def time.Duration) time.Duration
- func SelectFloat(opt, def float64) float64
- func SelectInt(opt, def int) int
- func ShuffleStrings(strings []string) []string
- func ShuffleStringsInPlace(strings []string)
- func SingleNodeCluster(hostport string, hostMap map[string][]string) bool
- func StringInSlice(slice []string, str string) bool
- func TakeNode(nodes *[]string, index int) string
- func TimeNowMS() int64
- func TimeZero() time.Time
- func UnixMS(t time.Time) int64
- type Timestamp
Constants ¶
This section is empty.
Variables ¶
var HostportPattern = regexp.MustCompile(`^(\d+.\d+.\d+.\d+):\d+$`)
HostportPattern is regex to match a host:port
Functions ¶
func CaptureHost ¶
CaptureHost takes a host:port and returns the host.
func CheckHostnameIPMismatch ¶
CheckHostnameIPMismatch checks for a hostname/IP mismatch in a map of hosts to host:ports. If there is a mismatch, returns the mismatched hosts and an error, otherwise nil and nil.
func CheckLocalMissing ¶
CheckLocalMissing checks a slice of host:ports for the given local host:port, return an error if not found, otherwise nil.
func HostPortsByHost ¶
HostPortsByHost parses a list of host/port conbinations and creates a map of unique hosts each containing a slice of the hostsport instances for each host.
func Min ¶
Min returns the lowest integer and is defined because golang only has a min function for floats and not for ints.
func SelectBool ¶ added in v0.8.0
SelectBool takes an option and a default value and returns the default value if the option is equal to the zero value, and the option otherwise.
func SelectDuration ¶
SelectDuration takes an option and a default value and returns the default value if the option is equal to zero, and the option otherwise.
func SelectFloat ¶ added in v0.5.0
SelectFloat takes an option and a default value and returns the default value if the option is equal to zero, and the option otherwise.
func SelectInt ¶
SelectInt takes an option and a default value and returns the default value if the option is equal to zero, and the option otherwise.
func ShuffleStrings ¶
ShuffleStrings takes a slice of strings and returns a new slice containing the same strings in a random order.
func ShuffleStringsInPlace ¶ added in v0.5.0
func ShuffleStringsInPlace(strings []string)
ShuffleStringsInPlace uses the Fisher–Yates shuffle to randomize the strings in place.
func SingleNodeCluster ¶
SingleNodeCluster determines if hostport is the only host:port contained within the hostMap.
func StringInSlice ¶
StringInSlice returns whether the string is contained within the slice.
Types ¶
type Timestamp ¶
Timestamp is a bi-directional binding of Time to interger Unix timestamp in JSON.
func (*Timestamp) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the timestamp.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON sets the timestamp to the value in the specified JSON.