Documentation
¶
Index ¶
- Variables
- func CopyFile(src, dst string) (int64, error)
- func CopyFolder(source, dest string) error
- func CopyFolderWithFilter(source, dest string, includeFilter IncludeFilter) (err error)
- func ExeDir() (string, error)
- func ExecAndCaptureOutput(command string, args ...string) (string, string, error)
- func FileExists(filePath string) bool
- func FindProcess(pid int) (*os.Process, error)
- func GetCurrentProcessTimes() (utime int64, stime int64, err error)
- func GetFdLimits() (soft uint64, hard uint64, err error)
- func GetFirstLineFromFile(netFile string) (string, error)
- func Getrusage(who int, rusage *syscall.Rusage) (err error)
- func IsDir(path string) bool
- func IsEmpty(path string) bool
- func KillProcess(pid int, sig syscall.Signal) error
- func MoveFile(src, dst string) error
- func NanoAfter(d time.Duration) <-chan time.Time
- func NanoSleep(d time.Duration)
- func NewREDCongestionManager(d time.Duration, bsize int) *redCongestionManager
- func RunFuncWithSpinningCursor(asyncFunc func())
- func SetFdSoftLimit(newLimit uint64) error
- func SetGoroutineLabels(args ...string)
- type CongestionManager
- type ElasticRateLimiter
- type ErlCapacityGuard
- type ErlClient
- type IncludeFilter
- type List
- type ListNode
- type Set
- type TCPInfo
- type WatchdogStreamReader
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotSyscallConn is reported when GetConnTCPInfo is passed a connection that doesn't satisfy the syscall.Conn interface. ErrNotSyscallConn = errors.New("conn doesn't satisfy syscall.Conn") // ErrTCPInfoUnsupported is reported if TCP information is not available for this platform. ErrTCPInfoUnsupported = errors.New("GetConnRTT not supported on this platform") // ErrNoTCPInfo is reported if getsockopt returned no TCP info for some reason. ErrNoTCPInfo = errors.New("getsockopt returned no TCP info") )
var ErrWatchdogStreamReaderReaderReachedDataLimit = fmt.Errorf("watchdog stream reader reached data limit")
ErrWatchdogStreamReaderReaderReachedDataLimit is returned when watchdogStreamReader was asked to read beyond the designated data limits
var ErrWatchdogStreamReaderTimerElapsed = fmt.Errorf("watchdog stream reader timer elapsed")
ErrWatchdogStreamReaderTimerElapsed is returned when the watchdogStreamReader was not reset in the past readaheadDuration and read was attempted
Functions ¶
func CopyFile ¶
CopyFile uses io.Copy() to copy a file to another location This was copied from https://opensource.com/article/18/6/copying-files-go
func CopyFolder ¶
CopyFolder recursively copies an entire directory to another location (ignoring symlinks)
func CopyFolderWithFilter ¶
func CopyFolderWithFilter(source, dest string, includeFilter IncludeFilter) (err error)
CopyFolderWithFilter recursively copies an entire directory to another location (ignoring symlinks) with an optional filter function to include/exclude folders or files
func ExeDir ¶
ExeDir returns the absolute path to the current executing binary (not including the filename)
func ExecAndCaptureOutput ¶
ExecAndCaptureOutput runs the specified command and args and captures stdout into a string, returning the string or an error upon completion.
func FileExists ¶
FileExists checks to see if the specified file (or directory) exists
func FindProcess ¶
FindProcess looks for a running process by its pid
func GetCurrentProcessTimes ¶
GetCurrentProcessTimes gets current process kernel and usermode times
func GetFdLimits ¶
GetFdLimits returns a current values for file descriptors limits.
func GetFirstLineFromFile ¶
GetFirstLineFromFile retrieves the first line of the specified file.
func KillProcess ¶
KillProcess kills a running OS process
func MoveFile ¶
MoveFile moves a file from src to dst. The advantages of using this over os.Rename() is that it can move files across different filesystems.
func NanoAfter ¶
NanoAfter waits for the duration to elapse and then sends the current time on the returned channel.
func NewREDCongestionManager ¶
NewREDCongestionManager creates a Congestion Manager which will watches capacityGuard activity, and regularly calculates a Target Service Rate, and can give "Should Drop" suggestions
func RunFuncWithSpinningCursor ¶
func RunFuncWithSpinningCursor(asyncFunc func())
RunFuncWithSpinningCursor runs a given function in a go-routine, while displaying a spinning cursor to the CLI
func SetFdSoftLimit ¶
SetFdSoftLimit sets a new file descriptors soft limit.
func SetGoroutineLabels ¶
func SetGoroutineLabels(args ...string)
SetGoroutineLabels sets profiler labels for identifying goroutines using the pprof package.
Types ¶
type CongestionManager ¶
type CongestionManager interface { Start() Stop() Consumed(c ErlClient, t time.Time) Served(t time.Time) ShouldDrop(c ErlClient) bool }
CongestionManager is an interface for tracking events which happen to capacityQueues
type ElasticRateLimiter ¶
type ElasticRateLimiter struct { MaxCapacity int CapacityPerReservation int // contains filtered or unexported fields }
ElasticRateLimiter holds and distributes capacity through capacityQueues Capacity consumers are given an error if there is no capacity available for them, and a "capacityGuard" structure they can use to return the capacity when finished
func NewElasticRateLimiter ¶
func NewElasticRateLimiter( maxCapacity int, reservedCapacity int, cmWindow time.Duration, conmanCount *metrics.Counter) *ElasticRateLimiter
NewElasticRateLimiter creates an ElasticRateLimiter and initializes maps maxCapacity: the total (absolute maximum) number of capacity units vended by this ERL at a given time reservedCapacity: the number of capacity units to be reserved per client cmWindow: the window duration of data collection for congestion management, passed to the congestion manager conmanCount: the metric to increment when the congestion manager proposes dropping a request
func (*ElasticRateLimiter) ConsumeCapacity ¶
func (erl *ElasticRateLimiter) ConsumeCapacity(c ErlClient) (*ErlCapacityGuard, bool, error)
ConsumeCapacity will dispense one capacity from either the resource's reservedCapacity, and will return a guard who can return capacity when the client is ready Returns an error if the capacity could not be vended, which could be: - there is not sufficient free capacity to assign a reserved capacity block - there is no reserved or shared capacity available for the client
func (*ElasticRateLimiter) DisableCongestionControl ¶
func (erl *ElasticRateLimiter) DisableCongestionControl()
DisableCongestionControl turns off the flag that the ERL uses to check with its CongestionManager
func (*ElasticRateLimiter) EnableCongestionControl ¶
func (erl *ElasticRateLimiter) EnableCongestionControl()
EnableCongestionControl turns on the flag that the ERL uses to check with its CongestionManager
func (*ElasticRateLimiter) Start ¶
func (erl *ElasticRateLimiter) Start()
Start will start any underlying component of the ElasticRateLimiter
func (*ElasticRateLimiter) Stop ¶
func (erl *ElasticRateLimiter) Stop()
Stop will stop any underlying component of the ElasticRateLimiter
type ErlCapacityGuard ¶
type ErlCapacityGuard struct {
// contains filtered or unexported fields
}
ErlCapacityGuard is the structure returned to clients so they can release the capacity when needed they also inform the congestion manager of events
func (*ErlCapacityGuard) Release ¶
func (cg *ErlCapacityGuard) Release() error
Release will put capacity back into the queue attached to this capacity guard
func (*ErlCapacityGuard) Served ¶
func (cg *ErlCapacityGuard) Served()
Served will notify the CongestionManager that this resource has been served, informing the Service Rate
type ErlClient ¶
type ErlClient interface {
OnClose(func())
}
ErlClient clients must support OnClose for reservation closing
type IncludeFilter ¶
IncludeFilter is a callback for filtering files and folders encountered while copying with CopyFileWithFilter()
type List ¶
type List[T any] struct { // contains filtered or unexported fields }
List represents a doubly linked list. must initiate with NewList.
func (*List[T]) AllocateFreeNodes ¶
AllocateFreeNodes adds N nodes to the free list
func (*List[T]) MoveToFront ¶
MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified. The element must not be nil.
type ListNode ¶
type ListNode[T any] struct { Value T // contains filtered or unexported fields }
ListNode represent a list node holding next/prev pointers and a value of type T.
type Set ¶
type Set[T comparable] map[T]struct{}
Set is a type alias for map with empty struct{}, where keys are comparable We don't attempt to move even forward for the generics, for keys being comparable should be sufficient for most cases. (Though we actually want compare byte slices, but seems not achievable at this moment)
func Intersection ¶
func Intersection[T comparable](sets ...Set[T]) Set[T]
Intersection constructs a new set, containing all elements that appear in all given sets. nil is never returned. Intersection of no sets is an empty set because that seems more useful, regardless of your very reasonable arguments otherwise.
func MakeSet ¶
func MakeSet[T comparable](elems ...T) Set[T]
MakeSet constructs a set instance directly from elements.
func Union ¶
func Union[T comparable](sets ...Set[T]) Set[T]
Union constructs a new set, containing all elements from the given sets. nil is never returned
type TCPInfo ¶
type TCPInfo struct { RTT uint32 `json:",omitempty"` // smoothed RTT RTTVar uint32 `json:",omitempty"` // RTT variance RTTMin uint32 `json:",omitempty"` // smallest observed RTT on the connection SndMSS, RcvMSS uint32 `json:",omitempty"` // send and receive maximum segment size SndCwnd uint32 `json:",omitempty"` // sender congestion window SndWnd uint32 `json:",omitempty"` // send window advertised to receiver RcvWnd uint32 `json:",omitempty"` // receive window advertised to sender // tcpi_delivery_rate: The most recent goodput, as measured by // tcp_rate_gen(). If the socket is limited by the sending // application (e.g., no data to send), it reports the highest // measurement instead of the most recent. The unit is bytes per // second (like other rate fields in tcp_info). Rate uint64 `json:",omitempty"` // tcpi_delivery_rate_app_limited: A boolean indicating if the goodput // was measured when the socket's throughput was limited by the // sending application. AppLimited bool `json:",omitempty"` }
TCPInfo provides socket-level TCP information.
type WatchdogStreamReader ¶
WatchdogStreamReader is the public interface for the watchdogStreamReader implementation.
func MakeWatchdogStreamReader ¶
func MakeWatchdogStreamReader(underlayingReader io.Reader, readSize uint64, readaheadSize uint64, readaheadDuration time.Duration) WatchdogStreamReader
MakeWatchdogStreamReader creates a watchdogStreamReader and initializes it.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package bloom implements Bloom filters.
|
Package bloom implements Bloom filters. |
Package db defines database utility functions.
|
Package db defines database utility functions. |
Package metrics provides a metric logging wrappers for Prometheus server.
|
Package metrics provides a metric logging wrappers for Prometheus server. |
Package timers provides a Clock abstraction useful for simulating timeouts.
|
Package timers provides a Clock abstraction useful for simulating timeouts. |