server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package server implements the local HTTP API consumed by the embedded dashboard. It binds to 127.0.0.1 only and serves the contract defined in api/openapi.yaml. See docs/superpowers/plans (plan P2) for the implementation plan.

Package server implements the local HTTP API consumed by the embedded dashboard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DaemonStatusProvider

type DaemonStatusProvider interface {
	Status(ctx context.Context) (contracts.DaemonStatus, error)
}

DaemonStatusProvider reports the current daemon runtime status.

type Deps

type Deps struct {
	Store    contracts.Store
	Pricing  contracts.PricingTable
	Profiles ProfileLister
	WebRoot  http.FileSystem
	Daemon   DaemonStatusProvider
	Hooks    HookStatusProvider
	Headroom HeadroomEvaluator
	Ingestor HeadroomIngestor
	Quota    QuotaProvider
	// Recommendations streams pressure-driven profile recommendation events.
	Recommendations RecommendationsSource
}

Deps is the set of dependencies the server needs.

type HeadroomEvaluator

type HeadroomEvaluator interface {
	Evaluate(ctx context.Context, profiles []contracts.Profile, opts headroom.Options) (headroom.Result, error)
}

HeadroomEvaluator evaluates profile headroom candidates.

type HeadroomIngestor

type HeadroomIngestor interface {
	IngestHeadroomProfiles(ctx context.Context, profiles []contracts.Profile) (map[string]string, error)
}

HeadroomIngestor best-effort ingests profiles before headroom evaluation.

type HookStatusProvider

type HookStatusProvider interface {
	Status(ctx context.Context, opts hooks.StatusOptions) ([]hooks.Result, error)
}

HookStatusProvider reports hook installation status.

type ProfileLister

type ProfileLister interface {
	List(ctx context.Context) ([]contracts.Profile, error)
}

ProfileLister exposes the subset of the profile manager the server needs.

type QuotaProvider

type QuotaProvider interface {
	Quota(ctx context.Context, profileFilter string) ([]contracts.ProfileQuota, error)
}

QuotaProvider returns per-profile plan-aware quota windows. profileFilter is the value of the profile query parameter; empty means all profiles.

type RecommendationsSource

type RecommendationsSource interface {
	Subscribe(ctx context.Context) <-chan contracts.RecommendationEvent
}

RecommendationsSource provides per-request RecommendationEvent subscriptions.

type Server

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

Server is the local HTTP server.

func New

func New(deps Deps, version string) *Server

New constructs a Server.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the underlying http.Handler.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, startPort, endPort int) (boundPort int, run func() error, err error)

Serve listens on 127.0.0.1 within [startPort, endPort].

Jump to

Keyboard shortcuts

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