client

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package client provides HTTP clients for communicating with Kedastral services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStale

func IsStale(snapshot storage.Snapshot, staleAfter time.Duration) bool

IsStale checks if a snapshot is older than the specified duration. This is a helper function for the scaler to determine staleness based on the snapshot's GeneratedAt timestamp.

Types

type ForecasterClient

type ForecasterClient struct {
	// contains filtered or unexported fields
}

ForecasterClient is an HTTP client for fetching forecast snapshots from the forecaster service. It is safe for concurrent use by multiple goroutines.

func NewForecasterClient

func NewForecasterClient(baseURL string) *ForecasterClient

NewForecasterClient creates a new client for the forecaster service. The baseURL should include the scheme and host (e.g., "http://localhost:8081"). A default timeout of 5 seconds is used for HTTP requests.

func NewForecasterClientWithTimeout

func NewForecasterClientWithTimeout(baseURL string, timeout time.Duration) *ForecasterClient

NewForecasterClientWithTimeout creates a new client with a custom timeout.

func (*ForecasterClient) GetSnapshot

func (c *ForecasterClient) GetSnapshot(ctx context.Context, workload string) (*SnapshotResult, error)

GetSnapshot fetches the latest forecast snapshot for a workload. Returns the snapshot and whether it's marked as stale by the forecaster.

The context can be used to cancel the request or set deadlines. If the workload is not found, returns an error.

type SnapshotResponse

type SnapshotResponse struct {
	Workload        string    `json:"workload"`
	Metric          string    `json:"metric"`
	GeneratedAt     time.Time `json:"generatedAt"`
	StepSeconds     int       `json:"stepSeconds"`
	HorizonSeconds  int       `json:"horizonSeconds"`
	Values          []float64 `json:"values"`
	DesiredReplicas []int     `json:"desiredReplicas"`
}

SnapshotResponse represents the JSON response from GET /forecast/current. This matches the structure defined in SPEC.md §3.1.

type SnapshotResult

type SnapshotResult struct {
	Snapshot storage.Snapshot
	Stale    bool // true if X-Kedastral-Stale header was present
}

SnapshotResult contains the snapshot and metadata about staleness.

Jump to

Keyboard shortcuts

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