Documentation
¶
Overview ¶
Package server assembles the hub half: a registry, a tunnel endpoint peers attach to, and (optionally) a proxy endpoint that reaches them, served together under one lifecycle.
Index ¶
Constants ¶
const ( DefaultTunnelAddr = "127.0.0.1:7200" DefaultProxyAddr = "127.0.0.1:7202" )
The addresses New serves on when WithTunnel / WithProxy are not given — holt's canonical loopback ports.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option interface{ ApplyServer(*Server) }
Option configures a Server; every SharedOption is one too.
func WithLogger ¶
WithLogger sets the logger. Default: no logging.
func WithProxy ¶
WithProxy serves the given proxy endpoint instead of the default one on DefaultProxyAddr (see proxy.NewProxy). Nil disables the proxy entirely, for a tunnel-only process.
func WithRegistry ¶
WithRegistry supplies the registry instead of the default registry.NewRegistry(logger) — the way to set a hub id, a shared presence Directory, or a MeterProvider.
func WithTunnel ¶
WithTunnel serves the given tunnel endpoint instead of the default one on DefaultTunnelAddr (see tunnel.NewTunnel). Nil disables the tunnel entirely, for a proxy-only process.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the assembled hub: a Registry, a Tunnel endpoint peers attach to, and (optionally) a Proxy endpoint that reaches them. It is the one-call counterpart of client.New for the server side.
Zero configuration works: New().Run(ctx) serves a tunnel on 127.0.0.1:7200 and a proxy on 127.0.0.1:7202 with the development identity — peers name themselves with the x-holt-peer header (or get a generated name) and nothing verifies the claim. That identity is loopback-only by construction: a tunnel bound to anything other than a loopback address with no identity configured refuses to start, so the trusting default cannot reach a network.
The operator surface stays reachable through Registry: roster, stop, watch, or mounting the admin service.
func New ¶
New assembles a hub from the options, laid over the defaults — the caller's options are just applied last, so overriding a default is passing the same option with another value. Nothing binds or serves until Run.
func (*Server) Registry ¶
Registry is the operational surface over the server's live tunnels: roster, stop, watch, and the value to build an admin service on.