client

package
v0.0.0-...-bfe00b6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package client contains the client for the API exposed by system-probe

Index

Constants

This section is empty.

Variables

View Source
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")
)

Get returns a http client configured to talk to the system-probe

Functions

func DebugURL

func DebugURL(endpoint string) string

DebugURL constructs a system-probe URL for the debug module and endpoint.

func DialContextFunc

func DialContextFunc(socketPath string) func(context.Context, string, string) (net.Conn, error)

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

func IgnoreStartupError(err error) error

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

func ReadAllResponseBody(resp *http.Response) ([]byte, error)

ReadAllResponseBody reads the entire HTTP response body as a byte slice

func URL

func URL(endpoint string) string

URL constructs a system-probe URL for a module-less endpoint.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL