Documentation
¶
Overview ¶
Package client contains the client for the API exposed by system-probe
Index ¶
- Variables
- func DebugURL(endpoint string) string
- func DialContextFunc(socketPath string) func(context.Context, string, string) (net.Conn, error)
- func GetCheck[T any](client *CheckClient, module types.ModuleName) (T, error)
- func IgnoreStartupError(err error) error
- func ModuleURL(module types.ModuleName, endpoint string) string
- func Post[T any](client *CheckClient, endpoint string, requestBody any, module types.ModuleName) (T, error)
- func ReadAllResponseBody(resp *http.Response) ([]byte, error)
- func URL(endpoint string) string
- type CheckClient
- type CheckClientOption
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotImplemented is an error used when system-probe is attempted to be accessed on an unsupported OS ErrNotImplemented = errors.New("system-probe unsupported") // ErrNotStartedYet is an error used when system-probe is attempted to be // accessed while it hasn't started yet (and could still be reasonably // expected to) ErrNotStartedYet = errors.New("system-probe not started yet") )
var Get = funcs.MemoizeArgNoError[string, *http.Client](get)
Get returns a http client configured to talk to the system-probe
Functions ¶
func DialContextFunc ¶
DialContextFunc returns a function to be used in http.Transport.DialContext for connecting to system-probe. The result will be OS-specific.
func GetCheck ¶
func GetCheck[T any](client *CheckClient, module types.ModuleName) (T, error)
GetCheck returns data unmarshalled from JSON to T, from the specified module at the /<module>/check endpoint.
func IgnoreStartupError ¶
IgnoreStartupError is used to avoid reporting errors from checks if system-probe has not started yet and can reasonably be expected to.
func ModuleURL ¶
func ModuleURL(module types.ModuleName, endpoint string) string
ModuleURL constructs a system-probe ModuleURL given the specified module and endpoint.
func Post ¶
func Post[T any](client *CheckClient, endpoint string, requestBody any, module types.ModuleName) (T, error)
Post makes a POST request to a module endpoint with an optional JSON request body and returns data unmarshalled from JSON to T. The endpoint parameter should be the path relative to the module (e.g., "/check", "/services").
func ReadAllResponseBody ¶
ReadAllResponseBody reads the entire HTTP response body as a byte slice
Types ¶
type CheckClient ¶
type CheckClient struct {
// contains filtered or unexported fields
}
CheckClient is a client for communicating with the system-probe check API
func GetCheckClient ¶
func GetCheckClient(options ...CheckClientOption) *CheckClient
GetCheckClient returns a new check client with the given options.
type CheckClientOption ¶
type CheckClientOption func(c *checkClientConfig)
CheckClientOption is a function that can be used to configure the check client.
func WithCheckTimeout ¶
func WithCheckTimeout(timeout time.Duration) CheckClientOption
WithCheckTimeout configures the check request timeout. This is HTTP timeout when making a request to the check endpoint once system-probe is started.
func WithSocketPath ¶
func WithSocketPath(socketPath string) CheckClientOption
WithSocketPath configures the socket path to use for the check client.
func WithStartupCheckTimeout ¶
func WithStartupCheckTimeout(timeout time.Duration) CheckClientOption
WithStartupCheckTimeout configures the startup check request timeout. This is the HTTP timeout when making a request to the debug/stats endpoint to check if system-probe is started.