Documentation
¶
Index ¶
- Variables
- func FirstNotEmpty(v ...string) string
- func FormatBytes[T int | int16 | int32 | int64 | uint | uint16 | uint32 | uint64](b T) string
- func GetDockerInfo(ctx context.Context) (types.Version, system.Info, error)
- func MustInt(v string) int
- func PruneDockerImages(ctx context.Context) (types.ImagesPruneReport, error)
- func ScanReader(r io.Reader, callback func(line []byte)) error
- type Atomic
- type AtomicBool
- type AtomicString
- type DockerCgroups
- type DockerContainers
- type DockerDiskUsage
- type DockerInformation
- type DockerRunc
- type DockerStorage
- type Information
- type IpAddresses
- type Locker
- type Rate
- type SinkName
- type SinkPool
- type System
- type Utilization
Constants ¶
This section is empty.
Variables ¶
var ErrLockerLocked = errors.Sentinel("locker: cannot acquire lock, already locked")
var Version = "develop"
Functions ¶
func FirstNotEmpty ¶
FirstNotEmpty returns the first string passed in that is not an empty value.
func FormatBytes ¶
func PruneDockerImages ¶
func PruneDockerImages(ctx context.Context) (types.ImagesPruneReport, error)
Types ¶
type Atomic ¶
type Atomic[T any] struct { // contains filtered or unexported fields }
func (*Atomic[T]) MarshalJSON ¶
MarshalJSON marshals the Atomic[T] value into JSON.
func (*Atomic[T]) Store ¶
func (a *Atomic[T]) Store(v T)
Store stores the string value passed atomically.
func (*Atomic[T]) UnmarshalJSON ¶
UnmarshalJSON unmarshals the JSON value into the Atomic[T] value.
type AtomicBool ¶
type AtomicBool struct {
// contains filtered or unexported fields
}
func NewAtomicBool ¶
func NewAtomicBool(v bool) *AtomicBool
func (*AtomicBool) Load ¶
func (ab *AtomicBool) Load() bool
func (*AtomicBool) MarshalJSON ¶
func (ab *AtomicBool) MarshalJSON() ([]byte, error)
func (*AtomicBool) Store ¶
func (ab *AtomicBool) Store(v bool)
func (*AtomicBool) SwapIf ¶
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 ¶
func (ab *AtomicBool) UnmarshalJSON(b []byte) error
type AtomicString ¶
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 ¶
func NewAtomicString(v string) *AtomicString
func (*AtomicString) Load ¶
func (as *AtomicString) Load() string
Load loads the string value and returns it.
func (*AtomicString) MarshalJSON ¶
func (as *AtomicString) MarshalJSON() ([]byte, error)
func (*AtomicString) Store ¶
func (as *AtomicString) Store(v string)
Store stores the string value passed atomically.
func (*AtomicString) UnmarshalJSON ¶
func (as *AtomicString) UnmarshalJSON(b []byte) error
type DockerCgroups ¶
type DockerContainers ¶
type DockerDiskUsage ¶
type DockerDiskUsage struct { ContainersSize int64 `json:"containers_size"` ImagesTotal int `json:"images_total"` ImagesActive int64 `json:"images_active"` ImagesSize int64 `json:"images_size"` BuildCacheSize int64 `json:"build_cache_size"` }
func GetDockerDiskUsage ¶
func GetDockerDiskUsage(ctx context.Context) (*DockerDiskUsage, error)
type DockerInformation ¶
type DockerInformation struct { Version string `json:"version"` Cgroups DockerCgroups `json:"cgroups"` Containers DockerContainers `json:"containers"` Storage DockerStorage `json:"storage"` Runc DockerRunc `json:"runc"` }
type DockerRunc ¶
type DockerRunc struct {
Version string `json:"version"`
}
type DockerStorage ¶
type Information ¶
type Information struct { Version string `json:"version"` Docker DockerInformation `json:"docker"` System System `json:"system"` }
func GetSystemInformation ¶
func GetSystemInformation() (*Information, error)
type IpAddresses ¶
type IpAddresses struct {
IpAddresses []string `json:"ip_addresses"`
}
func GetSystemIps ¶
func GetSystemIps() (*IpAddresses, error)
type Locker ¶
type Locker struct {
// contains filtered or unexported fields
}
func (*Locker) Acquire ¶
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 ¶
func (l *Locker) Destroy()
Destroy cleans up the power locker by closing the channel.
func (*Locker) IsLocked ¶
IsLocked returns the current state of the locker channel. If there is currently a value in the channel, it is assumed to be locked.
type Rate ¶
type Rate struct {
// contains filtered or unexported fields
}
Rate defines a rate limiter of n items (limit) per duration of time.
type SinkPool ¶
type SinkPool struct {
// contains filtered or unexported fields
}
SinkPool represents a pool with sinks.
func NewSinkPool ¶
func NewSinkPool() *SinkPool
NewSinkPool returns a new empty SinkPool. A sink pool generally lives with a server instance for its full lifetime.
func (*SinkPool) Destroy ¶
func (p *SinkPool) Destroy()
Destroy destroys the pool by removing and closing all sinks and destroying all of the channels that are present.
func (*SinkPool) Off ¶
Off removes a given channel from the sink pool. If no matching sink is found this function is a no-op. If a matching channel is found, it will be removed.
func (*SinkPool) Push ¶
Push sends a given message to each of the channels registered in the pool. This will use a Ring Buffer channel in order to avoid blocking the channel sends, and attempt to push though the most recent messages in the queue in favor of the oldest messages.
If the channel becomes full and isn't being drained fast enough, this function will remove the oldest message in the channel, and then push the message that it got onto the end, effectively making the channel a rolling buffer.
There is a potential for data to be lost when passing it through this function, but only in instances where the channel buffer is full and the channel is not drained fast enough, in which case dropping messages is most likely the best option anyways. This uses waitgroups to allow every channel to attempt its send concurrently thus making the total blocking time of this function "O(1)" instead of "O(n)".
type Utilization ¶
type Utilization struct { MemoryTotal uint64 `json:"memory_total"` MemoryUsed uint64 `json:"memory_used"` SwapTotal uint64 `json:"swap_total"` SwapUsed uint64 `json:"swap_used"` LoadAvg1 float64 `json:"load_average1"` LoadAvg5 float64 `json:"load_average5"` LoadAvg15 float64 `json:"load_average15"` CpuPercent float64 `json:"cpu_percent"` DiskTotal uint64 `json:"disk_total"` DiskUsed uint64 `json:"disk_used"` }
func GetSystemUtilization ¶
func GetSystemUtilization() (*Utilization, error)