Documentation
¶
Overview ¶
Package proxy serves the named URLs of running jobs on one loopback port.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Forward ¶
func Forward(params ForwardParams) error
Forward relays every connection the privileged listeners accept to the run proxy, and blocks until they all stop accepting.
func Probe ¶
func Probe(params ProbeParams) int
Probe is which bind port answers behind Port, zero when what answers is not this proxy. The bind port in the reply is what separates a live redirection from one still pointing at a port the daemon no longer holds.
Types ¶
type ForwardParams ¶
type ForwardParams struct {
Listeners []net.Listener
// Target resolves where to relay. The forwarder speaks no HTTP: the Host
// header it would need to read is the proxy's business, and a byte relay
// keeps websockets and streaming working for free.
Target TargetFunc
}
type Plan ¶
type Plan struct {
Files []domain.ProxyPlannedFile
Script string
}
Plan is what Apply would write and run, rendered without writing anything — the recap the user confirms is this value.
type ProbeParams ¶
type Redirector ¶
type Redirector interface {
Plan() (Plan, error)
Apply(ctx context.Context) error
Remove(ctx context.Context) error
Inspect() domain.ProxyStatus
}
func NewRedirector ¶
func NewRedirector(_ RedirectorParams) Redirector
type RedirectorParams ¶
type RedirectorParams struct {
// Root is what every path is joined onto, "/" in production. It exists so
// the tests never touch a system file.
Root string
}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the routing table. It is a projection of the jobs the daemon is running, so it is only ever written from where those start and stop.
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) Add ¶
func (r *Registry) Add(route domain.ProxyRoute)
func (*Registry) List ¶
func (r *Registry) List() []domain.ProxyRoute
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(params ServerParams) *Server
func (*Server) Start ¶
Start binds the first usable port from the one asked for and serves until Close. Usable means free *and* one a browser will open: a port on the browsers' blocked list serves nothing however well it binds, so it is stepped over exactly like an occupied one. The port is not stable across restarts when the preferred one is taken, and that is the trade this makes: a caller reaches a job by name, so the number is a transport detail `run url` resolves for them — where a job's own port is one they memorise, which is why those never move.
type ServerParams ¶
type TargetFunc ¶
TargetFunc names the port the run proxy is really on. It is a function and not a number because the daemon may fall back to another port, or restart on one: baking a port into the LaunchAgent would make every such move break the privileged port until the agent was reinstalled.
func Cached ¶
func Cached(resolve TargetFunc, ttl time.Duration) TargetFunc
Cached spares the daemon a round-trip per connection without letting the forwarder keep aiming at a port the daemon has left.