Documentation
¶
Overview ¶
Package v1 provides the gpud v1 client for the server.
Index ¶
- Variables
- func BlockUntilServerReady(ctx context.Context, addr string, opts ...OpOption) error
- func CheckHealthz(ctx context.Context, addr string, opts ...OpOption) error
- func DeregisterComponent(ctx context.Context, addr string, componentName string, opts ...OpOption) error
- func GetComponents(ctx context.Context, addr string, opts ...OpOption) ([]string, error)
- func GetEvents(ctx context.Context, addr string, opts ...OpOption) (v1.GPUdComponentEvents, error)
- func GetHealthStates(ctx context.Context, addr string, opts ...OpOption) (v1.GPUdComponentHealthStates, error)
- func GetInfo(ctx context.Context, addr string, opts ...OpOption) (v1.GPUdComponentInfos, error)
- func GetMachineInfo(ctx context.Context, addr string, opts ...OpOption) (*apiv1.MachineInfo, error)
- func GetMetrics(ctx context.Context, addr string, opts ...OpOption) (v1.GPUdComponentMetrics, error)
- func GetPackageStatus(ctx context.Context, url string, opts ...OpOption) ([]packages.PackageStatus, error)
- func GetPluginSpecs(ctx context.Context, addr string, opts ...OpOption) (pkgcustomplugins.Specs, error)
- func ReadComponents(rd io.Reader, opts ...OpOption) ([]string, error)
- func ReadEvents(rd io.Reader, opts ...OpOption) (v1.GPUdComponentEvents, error)
- func ReadHealthStates(rd io.Reader, opts ...OpOption) (v1.GPUdComponentHealthStates, error)
- func ReadInfo(rd io.Reader, opts ...OpOption) (v1.GPUdComponentInfos, error)
- func ReadMetrics(rd io.Reader, opts ...OpOption) (v1.GPUdComponentMetrics, error)
- func ReadPluginSpecs(rd io.Reader, opts ...OpOption) (pkgcustomplugins.Specs, error)
- func SetHealthyComponents(ctx context.Context, addr string, components []string, opts ...OpOption) ([]string, error)
- func TriggerComponent(ctx context.Context, addr string, componentName string, opts ...OpOption) (v1.GPUdComponentHealthStates, error)
- func TriggerComponentCheckByTag(ctx context.Context, addr string, tagName string, opts ...OpOption) error
- type Op
- type OpOption
Constants ¶
This section is empty.
Variables ¶
var ErrServerNotReady = errors.New("server not ready, timeout waiting")
Functions ¶
func BlockUntilServerReady ¶
func DeregisterComponent ¶ added in v0.5.0
func DeregisterComponent(ctx context.Context, addr string, componentName string, opts ...OpOption) error
DeregisterComponent deregisters the component from the server, by using the component name. It fails if the component has not been registered yet or is not deregisterable.
func GetComponents ¶
func GetHealthStates ¶ added in v0.5.0
func GetHealthStates(ctx context.Context, addr string, opts ...OpOption) (v1.GPUdComponentHealthStates, error)
GetHealthStates returns health states from the server for the given components.
Example:
baseURL := "https://localhost:15132"
for _, componentName := range []string{"disk", "accelerator-nvidia-info"} {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
states, err := GetHealthStates(ctx, baseURL, WithComponent(componentName))
if err != nil {
if errdefs.IsNotFound(err) {
log.Logger.Warnw("component not found", "component", componentName)
return
}
log.Logger.Error("error fetching component info", "error", err)
return
}
for _, ss := range states {
for _, s := range ss.States {
log.Logger.Infof("state: %q, health: %s\n", s.Name, s.Health)
}
}
}
func GetInfo ¶
GetInfo returns component information from the server.
Example:
baseURL := "https://localhost:15132"
componentName := "" // Leave empty to query all components
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
info, err := GetInfo(ctx, baseURL, WithComponent(componentName))
if err != nil {
fmt.Println("Error fetching component info:", err)
return
}
fmt.Println("Component Information:")
for _, i := range info {
fmt.Printf("Component: %s\n", i.Component)
for _, event := range i.Info.Events {
fmt.Printf(" Event: %s - %s\n", event.Name, event.Message)
}
for _, metric := range i.Info.Metrics {
fmt.Printf(" Metric: %s (labels: %q) - Value: %f\n", metric.Name, metric.Labels, metric.Value)
}
for _, state := range i.Info.States {
fmt.Printf(" State: %s - Health: %s\n", state.Name, state.Health)
}
}
func GetMachineInfo ¶ added in v0.5.0
func GetMetrics ¶
func GetPackageStatus ¶ added in v0.4.3
func GetPackageStatus(ctx context.Context, url string, opts ...OpOption) ([]packages.PackageStatus, error)
GetPackageStatus fetches the GPUd package status from the GPUd admin API.
func GetPluginSpecs ¶ added in v0.5.0
func GetPluginSpecs(ctx context.Context, addr string, opts ...OpOption) (pkgcustomplugins.Specs, error)
GetPluginSpecs returns the custom plugins registered in the server.
func ReadEvents ¶
func ReadHealthStates ¶ added in v0.5.0
func ReadMetrics ¶
func ReadPluginSpecs ¶ added in v0.5.0
ReadPluginSpecs reads the custom plugin specs from the server.
func SetHealthyComponents ¶ added in v0.8.0
func SetHealthyComponents(ctx context.Context, addr string, components []string, opts ...OpOption) ([]string, error)
SetHealthyComponents sets specified components to healthy state
func TriggerComponent ¶ added in v0.5.0
func TriggerComponent(ctx context.Context, addr string, componentName string, opts ...OpOption) (v1.GPUdComponentHealthStates, error)
TriggerComponent manually triggers a component check.
Types ¶
type OpOption ¶
type OpOption func(*Op)
func WithAcceptEncodingGzip ¶
func WithAcceptEncodingGzip() OpOption
WithAcceptEncodingGzip requests gzip encoding for the response.
func WithComponent ¶ added in v0.0.2
func WithRequestContentTypeJSON ¶
func WithRequestContentTypeJSON() OpOption
WithRequestContentTypeJSON sets the request content type to JSON.
func WithRequestContentTypeYAML ¶
func WithRequestContentTypeYAML() OpOption
WithRequestContentTypeYAML sets the request content type to YAML.