Documentation
¶
Index ¶
- Variables
- func Every(ctx context.Context, d time.Duration, work func(t time.Time))
- func FirstNotEmpty(v ...string) string
- func FormatBytes(b int64) string
- func MustInt(v string) int
- func ScanReader(r io.Reader, callback func(line []byte)) error
- type AtomicBool
- type AtomicString
- type Information
- type Locker
- type Rate
Constants ¶
This section is empty.
Variables ¶
var ErrLockerLocked = errors.Sentinel("locker: cannot acquire lock, already locked")
var Version = "develop"
Functions ¶
func Every ¶ added in v1.2.0
Runs a given work function every "d" duration until the provided context is canceled.
func FirstNotEmpty ¶ added in v1.3.0
FirstNotEmpty returns the first string passed in that is not an empty value.
func FormatBytes ¶ added in v1.2.0
Types ¶
type AtomicBool ¶
type AtomicBool struct {
// contains filtered or unexported fields
}
func NewAtomicBool ¶ added in v1.2.0
func NewAtomicBool(v bool) *AtomicBool
func (*AtomicBool) Load ¶ added in v1.2.0
func (ab *AtomicBool) Load() bool
func (*AtomicBool) MarshalJSON ¶ added in v1.2.0
func (ab *AtomicBool) MarshalJSON() ([]byte, error)
func (*AtomicBool) Store ¶ added in v1.2.0
func (ab *AtomicBool) Store(v bool)
func (*AtomicBool) SwapIf ¶ added in v1.2.0
func (ab *AtomicBool) SwapIf(v bool) bool
SwapIf stores the value "v" if the current value stored in the AtomicBool is the opposite boolean value. If successfully swapped, the response is "true", otherwise "false" is returned.
func (*AtomicBool) UnmarshalJSON ¶ added in v1.2.0
func (ab *AtomicBool) UnmarshalJSON(b []byte) error
type AtomicString ¶ added in v1.1.0
type AtomicString struct {
// contains filtered or unexported fields
}
AtomicString allows for reading/writing to a given struct field without having to worry about a potential race condition scenario. Under the hood it uses a simple sync.RWMutex to control access to the value.
func NewAtomicString ¶ added in v1.1.0
func NewAtomicString(v string) *AtomicString
func (*AtomicString) Load ¶ added in v1.1.0
func (as *AtomicString) Load() string
Loads the string value and returns it.
func (*AtomicString) MarshalJSON ¶ added in v1.2.0
func (as *AtomicString) MarshalJSON() ([]byte, error)
func (*AtomicString) Store ¶ added in v1.1.0
func (as *AtomicString) Store(v string)
Stores the string value passed atomically.
func (*AtomicString) UnmarshalJSON ¶ added in v1.2.0
func (as *AtomicString) UnmarshalJSON(b []byte) error
type Information ¶
type Information struct {
Version string `json:"version"`
KernelVersion string `json:"kernel_version"`
Architecture string `json:"architecture"`
OS string `json:"os"`
CpuCount int `json:"cpu_count"`
}
func GetSystemInformation ¶
func GetSystemInformation() (*Information, error)
type Locker ¶ added in v1.6.0
type Locker struct {
// contains filtered or unexported fields
}
func (*Locker) Acquire ¶ added in v1.6.0
Acquire will acquire the power lock if it is not currently locked. If it is already locked, acquire will fail to acquire the lock, and will return false.
func (*Locker) Destroy ¶ added in v1.6.0
func (l *Locker) Destroy()
Destroy cleans up the power locker by closing the channel.
func (*Locker) IsLocked ¶ added in v1.6.0
IsLocked returns the current state of the locker channel. If there is currently a value in the channel, it is assumed to be locked.