Documentation
¶
Overview ¶
Package utils are utilities for system-probe
Index ¶
- Constants
- func GetClientID(req *http.Request) string
- func WithConcurrencyLimit(limit int, original func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)
- func WriteAsJSON(w http.ResponseWriter, data interface{}, outputOptions FormatOptions)
- type FormatOptions
- type MemoryMonitor
Constants ¶
const ( // CompactOutput indicates that the output should be compact (no indentation). CompactOutput = false // PrettyPrint indicates that the output should be pretty-printed (with indentation). PrettyPrint = true )
const DefaultMaxConcurrentRequests = 2
DefaultMaxConcurrentRequests determines the maximum number of requests in-flight for a given handler We choose 2 because one is for regular agent checks and another one is for manual troubleshooting
const (
// PrettyPrintQueryParam is the query parameter used to request pretty-printed JSON output
PrettyPrintQueryParam = "pretty_print"
)
Variables ¶
This section is empty.
Functions ¶
func GetClientID ¶
GetClientID gets client provided in the http request, defaulting to -1
func WithConcurrencyLimit ¶
func WithConcurrencyLimit(limit int, original func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)
WithConcurrencyLimit enforces a maximum number of concurrent requests over a certain HTTP handler function
func WriteAsJSON ¶
func WriteAsJSON(w http.ResponseWriter, data interface{}, outputOptions FormatOptions)
WriteAsJSON marshals the give data argument into JSON and writes it to the `http.ResponseWriter`
Types ¶
type FormatOptions ¶
type FormatOptions bool
FormatOptions represents formatting options for WriteAsJson.
func GetPrettyPrintFromQueryParams ¶
func GetPrettyPrintFromQueryParams(req *http.Request) FormatOptions
GetPrettyPrintFromQueryParams returns true if the pretty_print query parameter is set to "true" in the request URL
type MemoryMonitor ¶
type MemoryMonitor = memorymonitor.MemoryController
MemoryMonitor monitors cgroups' memory usage
func NewMemoryMonitor ¶
func NewMemoryMonitor(kind string, containerized bool, pressureLevels map[string]string, thresholds map[string]string) (*MemoryMonitor, error)
NewMemoryMonitor instantiates a new memory monitor