Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultControlSocket() string
- func DefaultHome() string
- func DefaultStatsDir() string
- func FilterModels(models []*pb.NodeModelSpec, allow []string) []*pb.NodeModelSpec
- func FormatSchedule(week []int8) (string, error)
- func ParseRetention(s string) (time.Duration, error)
- func ParseWhen(s string, now time.Time) (time.Time, error)
- func Render(w io.Writer, findings []Finding) (problems int)
- func ResolveURLs(engineURL, endpoint string) (poll, report string)
- func TagJudgeModels(models []*pb.NodeModelSpec, judgeModels []string) []*pb.NodeModelSpec
- func TailRequests(ctx context.Context, st *StatsStore, since time.Time, w io.Writer, ...) error
- func WriteReport(w io.Writer, rep *Report, format string) error
- type Agent
- type AgentConfig
- type ControlCallError
- type ControlClient
- func (c *ControlClient) ClearOverride(ctx context.Context) (*Status, error)
- func (c *ControlClient) Events(ctx context.Context, fn func(*Status)) error
- func (c *ControlClient) PauseEngine(ctx context.Context, name string, paused bool) (*Status, error)
- func (c *ControlClient) PreviewSchedule(ctx context.Context, text string) (*ScheduleInfo, error)
- func (c *ControlClient) PutSchedule(ctx context.Context, text string) (*ScheduleInfo, error)
- func (c *ControlClient) Schedule(ctx context.Context) (*ScheduleInfo, error)
- func (c *ControlClient) SetOverride(ctx context.Context, req OverrideRequest) (*OverrideResult, error)
- func (c *ControlClient) SetScheduleSource(ctx context.Context, src string) (*Status, error)
- func (c *ControlClient) Settings(ctx context.Context) (*Settings, error)
- func (c *ControlClient) Stats(ctx context.Context, from, to, by string) (*Report, error)
- func (c *ControlClient) Status(ctx context.Context) (*Status, error)
- type ControlError
- type DayWindows
- type DecisionsInspector
- type Doctor
- type EngineController
- type EngineInspector
- type EngineLoad
- type EngineSpec
- type Finding
- type FreeTokenInspector
- type GPUStats
- type Gap
- type Gateway
- type GenericOpenAIInspector
- type Level
- type LlamaCppInspector
- type LoadProber
- type MTInspector
- type OllamaInspector
- func (oi *OllamaInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)
- func (oi *OllamaInspector) Unload(ctx context.Context, endpoint, authToken, model string) error
- func (oi *OllamaInspector) Warm(ctx context.Context, endpoint, authToken, model string) error
- type Override
- type OverrideRequest
- type OverrideResult
- type Report
- type ReportRow
- type RequestRecord
- type Sample
- type Schedule
- type ScheduleInfo
- type Settings
- type StatsStore
- func (s *StatsStore) AppendGap(g Gap) error
- func (s *StatsStore) AppendRequests(recs []RequestRecord) error
- func (s *StatsStore) AppendSample(sm Sample) error
- func (s *StatsStore) Cursor() (string, error)
- func (s *StatsStore) CursorAge(now time.Time) (age time.Duration, ok bool)
- func (s *StatsStore) Days(kind, from, to string) ([]string, error)
- func (s *StatsStore) Dir() string
- func (s *StatsStore) Gaps(from, to time.Time) ([]Gap, error)
- func (s *StatsStore) Maintain(now time.Time, retention time.Duration) error
- func (s *StatsStore) Requests(from, to time.Time) ([]RequestRecord, error)
- func (s *StatsStore) Samples(from, to time.Time) ([]Sample, error)
- func (s *StatsStore) SetCursor(id string) error
- func (s *StatsStore) Touch(now time.Time) error
- type Status
- type StatusConn
- type StatusEngine
- type StatusGPU
- type StatusKTMS
- type StatusLevel
- type StatusModel
- type StatusNext
- type StatusRequests
- type Switch
- type TGIInspector
- type VLLMInspector
- type Window
Constants ¶
const ( ExposeNone = "none" // the operator supplies --endpoint ExposeCloudflared = "cloudflared" // gateway on localhost behind a quick tunnel )
How the node becomes reachable by the proxy.
const ( FreeTokenEngineURL = "http://127.0.0.1:1919" FreeTokenMaxRunning = 4 )
FreeToken defaults: `ft serve` listens on 1919 and runs 4 requests at once (--max-running-requests); the rest wait inside the engine.
const ( ScheduleSourceLocal = "local" // --schedule-file ScheduleSourceKTMS = "ktms" // what KTMS sends with each heartbeat; the file is ignored )
Where the daemon takes its schedule from.
const ( MinOverride = time.Minute MaxOverride = 24 * time.Hour )
Bounds of an override, by the owner or from KTMS: a node cannot be forgotten on a pause for good.
const ( SourceSchedule = "schedule" SourceOverride = "override" SourceDefault = "default" // no schedule: 100% SourceKTMSSchedule = "ktms_schedule" SourceKTMSOverride = "ktms_override" )
Where the level in force comes from.
const ( SampleStateServing = "serving" SampleStatePaused = "paused" SampleStateDraining = "draining" SampleStateOffline = "offline" )
const ( StateActive = "active" StateThrottled = "throttled" // between 1% and 99% StatePausing = "pausing" // at 0%, proxy requests still running StatePaused = "paused" StateDraining = "draining" StateOffline = "offline" // not registered, or the last heartbeat failed )
Node states the control API reports.
const DefaultEngineURL = "http://127.0.0.1:11434"
DefaultEngineURL is Ollama's default listen address.
const MinCloudflared = "2026.10.3"
MinCloudflared is the oldest cloudflared that no longer trusts the eMudhra intermediates whose keys leaked in October 2026.
const StatusRunning = 8
StatusRunning caps the request ids a status lists: the tray draws fewer.
Variables ¶
var ErrAgentDown = errors.New("the node daemon is not running (or predates the control API)")
ErrAgentDown means nothing answers on the control socket.
var ErrFreeTokenFailed = errors.New("freetoken server failed")
ErrFreeTokenFailed is a server whose /health reports a dead backend.
Functions ¶
func DefaultControlSocket ¶ added in v1.5.0
func DefaultControlSocket() string
DefaultControlSocket is where the daemon listens for its owner by default.
func DefaultHome ¶ added in v1.5.0
func DefaultHome() string
DefaultHome is the node's directory: the installer's, else ~/.ktms-node.
func DefaultStatsDir ¶ added in v1.3.0
func DefaultStatsDir() string
DefaultStatsDir is where the installer's node keeps its log.
func FilterModels ¶
func FilterModels(models []*pb.NodeModelSpec, allow []string) []*pb.NodeModelSpec
FilterModels keeps only the allowed models; an empty allow list keeps all. An engine shared with other tools would otherwise advertise models this node must not serve.
func FormatSchedule ¶ added in v1.5.0
FormatSchedule writes the rules for a week of levels (-1 = no rule), one line per window; days with the same windows share a line. Parsing the result gives the same week back.
func ParseRetention ¶ added in v1.3.0
ParseRetention reads "90d", "12h" or "0" (keep everything).
func ParseWhen ¶ added in v1.3.0
ParseWhen reads "24h", "7d", "2026-10-01" or "2026-10-01T15:04" (local time) as a moment before now.
func ResolveURLs ¶
ResolveURLs returns the engine URL to poll and the endpoint to report. With only endpoint set, polling uses it too, as before --engine-url existed.
func TagJudgeModels ¶
func TagJudgeModels(models []*pb.NodeModelSpec, judgeModels []string) []*pb.NodeModelSpec
TagJudgeModels ensures models in judge list declare the "judge" capability.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func NewAgent ¶
func NewAgent(cfg AgentConfig) *Agent
type AgentConfig ¶
type AgentConfig struct {
ProxyAddr string
TLS bool // dial ProxyAddr over TLS with system roots, e.g. a load balancer on :443
NodeKey string
NodeID string
NodeName string
EngineURL string // where the daemon itself polls the engine; local, never reported
Endpoint string // address the proxy dials, as reported at registration
Engine string
ExtraEngines []EngineSpec // engines served beside Engine, behind the built-in gateway
NodeAuthToken string // bearer the proxy presents to Endpoint; replaced by a generated key when exposing
EngineToken string // bearer the engine itself requires, if any
OnlyModels []string // when set, report only these engine models
JudgeModels []string // models to tag with capability "judge"
Expose string // ExposeNone or ExposeCloudflared
CloudflaredBin string
BaseWeight float64
MaxConcurrent uint32
// EngineMaxRunning is how many requests the engine runs at once, for
// engines that report only a total (FreeToken); 0 is the engine default.
EngineMaxRunning uint32
ScheduleFile string // capacity levels by local time; missing = 100%
ScheduleSource string // local (ScheduleFile) or ktms (sent by KTMS); the tray's saved choice wins
Warmup time.Duration // load the model this long before a paused window ends
StatsDir string // where the usage log is kept for the owner; "" = none
StatsRetention time.Duration // days of usage log kept; 0 = all
StateDir string // the manual level and other state that outlives a restart; "" = kept in memory only
ControlSocket string // Unix socket of the owner's control API; "" = none
Version string // reported by the control API
}
type ControlCallError ¶ added in v1.5.0
type ControlCallError struct {
Status int
ControlError
}
ControlCallError is a refusal from the daemon.
func (*ControlCallError) Error ¶ added in v1.5.0
func (e *ControlCallError) Error() string
type ControlClient ¶ added in v1.5.0
type ControlClient struct {
Socket string
// contains filtered or unexported fields
}
ControlClient talks to a running daemon over its control socket; the CLI and the tray both use it.
func NewControlClient ¶ added in v1.5.0
func NewControlClient(socket string) *ControlClient
func (*ControlClient) ClearOverride ¶ added in v1.5.0
func (c *ControlClient) ClearOverride(ctx context.Context) (*Status, error)
func (*ControlClient) Events ¶ added in v1.5.0
func (c *ControlClient) Events(ctx context.Context, fn func(*Status)) error
Events calls fn with each status the daemon streams until ctx ends or the stream breaks.
func (*ControlClient) PauseEngine ¶ added in v1.6.0
PauseEngine pauses (or, with paused false, resumes) one engine of a node with several.
func (*ControlClient) PreviewSchedule ¶ added in v1.5.0
func (c *ControlClient) PreviewSchedule(ctx context.Context, text string) (*ScheduleInfo, error)
func (*ControlClient) PutSchedule ¶ added in v1.5.0
func (c *ControlClient) PutSchedule(ctx context.Context, text string) (*ScheduleInfo, error)
func (*ControlClient) Schedule ¶ added in v1.5.0
func (c *ControlClient) Schedule(ctx context.Context) (*ScheduleInfo, error)
func (*ControlClient) SetOverride ¶ added in v1.5.0
func (c *ControlClient) SetOverride(ctx context.Context, req OverrideRequest) (*OverrideResult, error)
func (*ControlClient) SetScheduleSource ¶ added in v1.5.0
SetScheduleSource hands the schedule to KTMS ("ktms") or takes it back ("local").
func (*ControlClient) Settings ¶ added in v1.5.0
func (c *ControlClient) Settings(ctx context.Context) (*Settings, error)
type ControlError ¶ added in v1.5.0
type ControlError struct {
Error string `json:"error"`
Line int `json:"line,omitempty"` // schedule line at fault
}
ControlError is the body of every failed control call.
type DayWindows ¶ added in v1.5.0
DayWindows lists the windows rules set on one day; the rest of it runs at 100%.
type DecisionsInspector ¶
type DecisionsInspector struct{}
DecisionsInspector inspects engines serving decision models (/v1/decisions).
func (*DecisionsInspector) Inspect ¶
func (di *DecisionsInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)
type Doctor ¶
type Doctor struct {
Cfg AgentConfig
Model string // the model this node should serve; empty = any
// Seams for tests; zero values use the real thing.
HTTP *http.Client
DialTCP func(ctx context.Context, addr string) error
UsesProxy func(addr string) bool // true when HTTPS_PROXY or similar routes addr; gRPC honors it, a raw dial does not
LookPath func(name string) (string, error)
RunCmd func(ctx context.Context, name string, args ...string) (string, error) // combined output
MachOArchs func(path string) ([]string, error)
Now func() time.Time
GOOS string
GOARCH string
}
Doctor explains why a node is not (or is badly) serving. It sends one Heartbeat for a made-up node id, which the proxy answers without storing.
type EngineController ¶ added in v1.1.0
type EngineController interface {
Warm(ctx context.Context, endpoint, authToken, model string) error
Unload(ctx context.Context, endpoint, authToken, model string) error
}
EngineController is implemented by inspectors whose engine can load and free a model on demand; a paused node frees the machine's memory with it.
type EngineInspector ¶
type EngineInspector interface {
Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)
}
func GetInspector ¶
func GetInspector(engine string) EngineInspector
func InspectorFor ¶ added in v1.5.0
func InspectorFor(cfg AgentConfig) EngineInspector
InspectorFor is GetInspector with the engine settings the config carries.
type EngineLoad ¶ added in v0.13.1
EngineLoad is the engine's own view of its work: requests it is generating and requests it has accepted but not started. The proxy adds Waiting to its queue estimate, so a node busy with other clients is not overbooked.
type EngineSpec ¶ added in v1.6.0
EngineSpec is an inference engine a node serves next to its primary one, such as ktms-mt beside Ollama. The gateway routes each request by model.
func ParseEngineSpec ¶ added in v1.6.0
func ParseEngineSpec(v string) (EngineSpec, error)
ParseEngineSpec reads NAME=URL, e.g. mt=http://127.0.0.1:11436.
type FreeTokenInspector ¶ added in v1.5.0
type FreeTokenInspector struct {
// MaxRunning is the server's --max-running-requests; admitted requests
// beyond it are waiting. Zero means FreeTokenMaxRunning.
MaxRunning uint32
}
FreeTokenInspector reads a FreeToken server (`ft serve`): one model per process, no /metrics, its queue only as the count of admitted requests.
func (*FreeTokenInspector) Inspect ¶ added in v1.5.0
func (fi *FreeTokenInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)
func (*FreeTokenInspector) Load ¶ added in v1.5.0
func (fi *FreeTokenInspector) Load(ctx context.Context, endpoint, authToken string) (EngineLoad, error)
Load splits /v1/stats requests.active, which counts every admitted request, into the MaxRunning the engine generates and the rest it holds back.
type GPUStats ¶
type Gap ¶ added in v1.3.0
Gap is a stretch the proxy no longer had when the daemon pulled: requests in it may be missing from the log.
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway is the only door to the engine that the proxy gets: a bearer check plus an allowlist of the routes it needs (/v1/chat/completions, /v1/decisions, /v1/translate, /v1/models). Everything else (pull, delete, engine admin APIs) is unreachable.
func NewGateway ¶
NewGateway forwards to the engine at engineURL. accessKey is what callers must present; engineToken, if any, is what the engine itself expects.
func NewMultiGateway ¶ added in v1.6.0
func NewMultiGateway(primary string, primaryURL string, extra []EngineSpec, accessKey, engineToken string) *Gateway
NewMultiGateway fronts several engines: the primary and extra, routed by the model a request names.
func (*Gateway) Active ¶ added in v1.6.1
Active is how many engine requests run through the gateway now, all engines.
func (*Gateway) CancelInflight ¶ added in v1.5.0
CancelInflight cuts every engine request running now and returns how many.
func (*Gateway) Running ¶ added in v1.6.1
Running lists the ids of the oldest n engine requests running now, oldest first.
func (*Gateway) SetAccepting ¶ added in v1.1.0
SetAccepting opens or closes the door to engine routes. Closed, the node answers 503: a proxy that ignores the schedule still cannot reach the engine.
type GenericOpenAIInspector ¶
type GenericOpenAIInspector struct{}
Generic OpenAI Inspector
func (*GenericOpenAIInspector) Inspect ¶
func (goi *GenericOpenAIInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)
type LlamaCppInspector ¶
type LlamaCppInspector struct{}
LlamaCpp Inspector
func (*LlamaCppInspector) Inspect ¶
func (li *LlamaCppInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)
func (*LlamaCppInspector) Load ¶ added in v0.13.1
func (li *LlamaCppInspector) Load(ctx context.Context, endpoint, authToken string) (EngineLoad, error)
type LoadProber ¶ added in v0.13.1
type LoadProber interface {
Load(ctx context.Context, endpoint, authToken string) (EngineLoad, error)
}
LoadProber is implemented by inspectors whose engine publishes its queue. Ollama has no such API.
type MTInspector ¶ added in v1.6.0
type MTInspector struct{}
MTInspector inspects machine-translation servers (/v1/translate). Their models translate and nothing else, so each carries only the translate capability whatever the server lists.
func (*MTInspector) Inspect ¶ added in v1.6.0
func (mi *MTInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)
type OllamaInspector ¶
type OllamaInspector struct{}
Ollama Inspector
func (*OllamaInspector) Inspect ¶
func (oi *OllamaInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)
type Override ¶ added in v1.5.0
type Override struct {
Level uint32 `json:"level"`
Until time.Time `json:"until"`
SetAt time.Time `json:"set_at"`
Warm bool `json:"warm"` // warm the models before Until, as a schedule pause does
}
Override is a level the owner set by hand until a moment; it wins over the schedule until then. Until is wall clock, so a Mac that slept past it ends it on waking.
type OverrideRequest ¶ added in v1.5.0
type OverrideRequest struct {
Level uint32 `json:"level"`
For string `json:"for,omitempty"` // Go duration: 10m, 1h
Until time.Time `json:"until,omitzero"`
UntilNextWindow bool `json:"until_next_window,omitempty"`
Warm bool `json:"warm,omitempty"`
AbortInflight bool `json:"abort_inflight,omitempty"`
}
OverrideRequest is what the control API and the CLI ask for. Exactly one of For, Until and UntilNextWindow sets the end.
type OverrideResult ¶ added in v1.5.0
type OverrideResult struct {
Status *Status `json:"status"`
Aborted int `json:"aborted"` // requests cut by abort_inflight
}
OverrideResult answers POST /v1/override.
type Report ¶ added in v1.3.0
type Report struct {
From time.Time `json:"from"`
To time.Time `json:"to"`
By string `json:"by"`
Rows []ReportRow `json:"rows"`
Total ReportRow `json:"total"`
Gaps []Gap `json:"gaps,omitempty"`
}
Report is the usage log over [From, To) split by hour, day or model.
func BuildReport ¶ added in v1.3.0
BuildReport reads the log in [from, to) and sums it by "hour", "day" or "model".
type ReportRow ¶ added in v1.3.0
type ReportRow struct {
Key string `json:"key"`
Requests int `json:"requests"`
Errors int `json:"errors"` // outcome error or timeout
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
BusyMs int64 `json:"busy_ms"` // time with at least one request running
SpanMs int64 `json:"span_ms"` // the period, up to now
CooldownMs int64 `json:"cooldown_ms"`
NoDataMin int `json:"no_data_min"` // minutes without a sample: the daemon was not running
Samples int `json:"samples"`
TTFTp50Ms int64 `json:"ttft_p50_ms,omitempty"`
TTFTp95Ms int64 `json:"ttft_p95_ms,omitempty"`
TPS float64 `json:"tps,omitempty"`
}
ReportRow sums one period (or model) of the usage log.
type RequestRecord ¶ added in v1.3.0
type RequestRecord struct {
ID string `json:"id"`
RequestID string `json:"request_id"`
StartedAt time.Time `json:"started_at"`
DurationMs int64 `json:"duration_ms"`
TTFTMs int64 `json:"ttft_ms,omitempty"`
Model string `json:"model"`
Kind string `json:"kind"`
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
CacheReadTokens int64 `json:"cache_read_tokens,omitempty"`
Outcome string `json:"outcome"`
ErrorCode string `json:"error_code,omitempty"`
Level uint32 `json:"level"`
CooldownMs int64 `json:"cooldown_ms,omitempty"`
}
RequestRecord is one request the proxy sent to this node, one line of requests-YYYY-MM-DD.jsonl (the day it started, local time).
type Sample ¶ added in v1.3.0
type Sample struct {
At time.Time `json:"at"`
State string `json:"state"` // serving | paused | draining | offline
Level uint32 `json:"level"`
ProxyActive int32 `json:"proxy_active"`
EngineRunning uint32 `json:"engine_running,omitempty"`
EngineWaiting uint32 `json:"engine_waiting,omitempty"`
GPUUtil float64 `json:"gpu_util,omitempty"`
GPUTempC uint32 `json:"gpu_temp_c,omitempty"`
VRAMFreeMB uint64 `json:"vram_free_mb,omitempty"`
VRAMTotalMB uint64 `json:"vram_total_mb,omitempty"`
Warm []string `json:"warm,omitempty"`
}
Sample is the daemon's own view of the node once a minute, one line of samples-YYYY-MM-DD.jsonl.
type Schedule ¶ added in v1.1.0
type Schedule struct {
// contains filtered or unexported fields
}
Schedule is the node's capacity level for every minute of the week, in the machine's local time. Minutes no rule covers run at 100%.
func LoadSchedule ¶ added in v1.1.0
LoadSchedule parses the file at path. A missing file is no schedule: nil, nil.
func ParseSchedule ¶ added in v1.1.0
ParseSchedule reads rules of the form "[days] HH:MM-HH:MM level", one per line; "#" starts a comment. A window past midnight belongs to the day it starts on. Overlapping rules are an error.
func (*Schedule) Days ¶ added in v1.5.0
func (s *Schedule) Days() []DayWindows
Days splits the week into each day's windows, as an editor shows them.
func (*Schedule) Next ¶ added in v1.1.0
Next returns when the level next changes and to what; ok is false when it never does. It steps in real minutes, so DST gaps and repeats count right.
func (*Schedule) Status ¶ added in v1.1.0
Status is the one-line summary the CLI, the doctor and the installer print.
type ScheduleInfo ¶ added in v1.5.0
type ScheduleInfo struct {
File string `json:"file"`
Text string `json:"text"`
Exists bool `json:"exists"`
Error string `json:"error,omitempty"` // the file is invalid; the daemon keeps the last valid schedule
Line int `json:"line,omitempty"`
Days []DayWindows `json:"days,omitempty"`
Level uint32 `json:"level"` // what this text gives now
Upcoming []Switch `json:"upcoming,omitempty"`
Editable bool `json:"editable"`
Source string `json:"source,omitempty"` // local | ktms
ReadOnly string `json:"read_only,omitempty"` // why it is not editable
}
ScheduleInfo is the schedule file as the editor sees it.
type Settings ¶ added in v1.5.0
type Settings struct {
ScheduleSource string `json:"schedule_source"`
}
Settings are the owner's choices the tray changes at run time; they win over the flags.
type StatsStore ¶ added in v1.3.0
type StatsStore struct {
// contains filtered or unexported fields
}
StatsStore is the node's usage log on disk: JSON Lines per kind and local day, appended and fsynced, closed days gzipped. Plain files keep the binary cgo-free and readable with jq.
func OpenStats ¶ added in v1.3.0
func OpenStats(dir string, create bool) (*StatsStore, error)
OpenStats returns the store in dir, creating it for writing when create is set.
func (*StatsStore) AppendGap ¶ added in v1.3.0
func (s *StatsStore) AppendGap(g Gap) error
func (*StatsStore) AppendRequests ¶ added in v1.3.0
func (s *StatsStore) AppendRequests(recs []RequestRecord) error
AppendRequests writes records to the file of the day each started.
func (*StatsStore) AppendSample ¶ added in v1.3.0
func (s *StatsStore) AppendSample(sm Sample) error
func (*StatsStore) Cursor ¶ added in v1.3.0
func (s *StatsStore) Cursor() (string, error)
Cursor is the proxy log position already stored; "" before the first pull.
func (*StatsStore) CursorAge ¶ added in v1.3.0
CursorAge is how long ago the cursor last moved; ok is false before the first pull.
func (*StatsStore) Days ¶ added in v1.3.0
func (s *StatsStore) Days(kind, from, to string) ([]string, error)
Days lists the days in [from, to] (local dates) that have files of kind.
func (*StatsStore) Dir ¶ added in v1.3.0
func (s *StatsStore) Dir() string
func (*StatsStore) Gaps ¶ added in v1.3.0
func (s *StatsStore) Gaps(from, to time.Time) ([]Gap, error)
Gaps returns the recorded gaps that overlap [from, to).
func (*StatsStore) Maintain ¶ added in v1.3.0
Maintain gzips the files of closed days and deletes days older than retention (0 keeps everything). A record pulled late for a closed day lands in a fresh .jsonl, which joins the .gz as one more gzip member.
func (*StatsStore) Requests ¶ added in v1.3.0
func (s *StatsStore) Requests(from, to time.Time) ([]RequestRecord, error)
Requests returns the requests that started in [from, to), without the repeats a crash between a write and its cursor leaves behind.
func (*StatsStore) Samples ¶ added in v1.3.0
func (s *StatsStore) Samples(from, to time.Time) ([]Sample, error)
Samples returns the samples taken in [from, to), each once.
func (*StatsStore) SetCursor ¶ added in v1.3.0
func (s *StatsStore) SetCursor(id string) error
SetCursor moves the position, after the records before it are on disk: a crash in between repeats records (readers drop them by request_id), never loses them.
type Status ¶ added in v1.5.0
type Status struct {
Version string `json:"version"`
NodeID string `json:"node_id"`
Proxy string `json:"proxy"`
Connection StatusConn `json:"connection"`
Level StatusLevel `json:"level"`
State string `json:"state"`
Requests StatusRequests `json:"requests"`
CapacityApplied bool `json:"capacity_applied"` // false: the proxy predates levels and routes here at 100%
Models []StatusModel `json:"models"`
Engines []StatusEngine `json:"engines,omitempty"` // with more than one engine
GPU *StatusGPU `json:"gpu,omitempty"`
Endpoint string `json:"endpoint"`
ScheduleSource string `json:"schedule_source"` // local | ktms
ScheduleFile string `json:"schedule_file"`
ScheduleError string `json:"schedule_error"`
CanAbort bool `json:"can_abort"` // the built-in gateway can cut running requests
UpdatedAt time.Time `json:"updated_at"`
}
Status is what the owner sees of the running daemon. It carries no key or token.
type StatusConn ¶ added in v1.5.0
type StatusEngine ¶ added in v1.6.0
type StatusEngine struct {
Name string `json:"name"`
Primary bool `json:"primary"`
Up bool `json:"up"`
Error string `json:"error,omitempty"`
Paused bool `json:"paused"` // by the owner: its models are not offered to the proxy
Models []string `json:"models"`
}
StatusEngine is one engine of a node that runs several.
type StatusKTMS ¶ added in v1.5.0
type StatusLevel ¶ added in v1.5.0
type StatusLevel struct {
Effective uint32 `json:"effective"`
Schedule uint32 `json:"schedule"` // what the schedule alone says now
Source string `json:"source"` // schedule | override | ktms_schedule | ktms_override | default
Override *Override `json:"override,omitempty"` // the owner's, set on this machine
KTMS *StatusKTMS `json:"ktms,omitempty"` // in ktms mode: what KTMS last sent
Next *StatusNext `json:"next,omitempty"`
}
type StatusModel ¶ added in v1.5.0
type StatusNext ¶ added in v1.5.0
type StatusRequests ¶ added in v1.5.0
type StatusRequests struct {
ProxyActive int32 `json:"proxy_active"` // -1 when not yet known
Inflight int32 `json:"inflight"` // running on this node now, all engines
Running []uint64 `json:"running,omitempty"` // ids of the oldest of them, at most StatusRunning; gateway only
EngineRunning uint32 `json:"engine_running"`
EngineWaiting uint32 `json:"engine_waiting"`
}
type TGIInspector ¶
type TGIInspector struct{}
TGI Inspector
func (*TGIInspector) Inspect ¶
func (ti *TGIInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)
func (*TGIInspector) Load ¶ added in v0.13.1
func (ti *TGIInspector) Load(ctx context.Context, endpoint, authToken string) (EngineLoad, error)
type VLLMInspector ¶
type VLLMInspector struct{}
vLLM Inspector
func (*VLLMInspector) Inspect ¶
func (vi *VLLMInspector) Inspect(ctx context.Context, endpoint, authToken string) ([]*pb.NodeModelSpec, error)
func (*VLLMInspector) Load ¶ added in v0.13.1
func (vi *VLLMInspector) Load(ctx context.Context, endpoint, authToken string) (EngineLoad, error)