api

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

internal/api/routes.go

internal/api/server.go

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is set via -ldflags at build time; defaults to "dev" for local builds.

Functions

func ExtractName

func ExtractName(host string) string

ExtractName extracts the route name from a host string like "myapp.test", "frontend.myapp.test:443", etc. Strips port and .test suffix.

Types

type ConflictError

type ConflictError struct {
	Name        string
	ExistingDir string
}

func (*ConflictError) Error

func (e *ConflictError) Error() string

type LimitError

type LimitError struct {
	Limit int
}

func (*LimitError) Error

func (e *LimitError) Error() string

type RegisterRequest

type RegisterRequest struct {
	Name     string `json:"name"`
	Upstream string `json:"upstream"`
	Dir      string `json:"dir"`
}

type Route

type Route struct {
	Name          string    `json:"name"`
	Upstream      string    `json:"upstream"`
	Dir           string    `json:"dir"`
	Registered    time.Time `json:"registered"`
	LastHeartbeat time.Time `json:"lastHeartbeat"`
}

type RouteRegistry

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

func NewRouteRegistry

func NewRouteRegistry(timeout time.Duration) *RouteRegistry

func (*RouteRegistry) Cleanup

func (r *RouteRegistry) Cleanup()

Cleanup removes routes whose heartbeat has expired. It uses a read-lock to scan for expired routes, then upgrades to a write-lock only if deletions are needed, reducing contention on the hot path.

func (*RouteRegistry) Deregister

func (r *RouteRegistry) Deregister(name string) bool

func (*RouteRegistry) Heartbeat

func (r *RouteRegistry) Heartbeat(name string) error

func (*RouteRegistry) List

func (r *RouteRegistry) List() []Route

List returns copies of all registered routes.

func (*RouteRegistry) Lookup

func (r *RouteRegistry) Lookup(name string) (Route, bool)

Lookup returns a copy of the route with the given name. Returning a copy prevents callers from mutating registry-owned data.

func (*RouteRegistry) LookupByHost

func (r *RouteRegistry) LookupByHost(host string) (Route, bool)

LookupByHost extracts the route name from a host string and looks it up.

func (*RouteRegistry) Register

func (r *RouteRegistry) Register(name, upstream, dir string) error

type Server

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

func NewServer

func NewServer(socketPath string, registry *RouteRegistry) *Server

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop() error

Jump to

Keyboard shortcuts

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