Documentation
¶
Overview ¶
internal/api/routes.go
internal/api/server.go
Index ¶
- Variables
- func ExtractName(host string) string
- type ConflictError
- type LimitError
- type RegisterRequest
- type Route
- type RouteRegistry
- func (r *RouteRegistry) Cleanup()
- func (r *RouteRegistry) Deregister(name string) bool
- func (r *RouteRegistry) Heartbeat(name string) error
- func (r *RouteRegistry) List() []Route
- func (r *RouteRegistry) Lookup(name string) (Route, bool)
- func (r *RouteRegistry) LookupByHost(host string) (Route, bool)
- func (r *RouteRegistry) Register(name, upstream, dir string) error
- type Server
Constants ¶
This section is empty.
Variables ¶
var Version = "dev"
Version is set via -ldflags at build time; defaults to "dev" for local builds.
Functions ¶
func ExtractName ¶
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 ¶
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 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