Documentation
¶
Overview ¶
Package dial is the client half of the holt: a persistent attach loop that dials the hub, serves an http.Handler over the reverse tunnel, and redials with jittered backoff until the context ends or the hub sends a terminal GoAway.
The loop rides an existing *grpc.ClientConn, so it reuses whatever connection (and auth interceptors) the application already holds to the hub — the tunnel is one more stream on that connection, not a second dial.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run attaches to the hub and serves Handler over the tunnel, redialing with jittered exponential backoff (500 ms doubling to 30 s) until ctx is cancelled or the hub sends a terminal GoAway. A successful handshake resets the backoff. Returns nil on a terminal GoAway (clean exit) and ctx.Err() on shutdown.
Types ¶
type Options ¶
type Options struct {
// Conn is the peer's existing gRPC connection to the hub. The
// attach loop opens one Tunnel.Attach stream on it.
Conn grpc.ClientConnInterface
// Handler is served over the tunnel — the hub dials it as if it
// were a normal HTTP server.
Handler http.Handler
// Version is the peer build version, sent in Hello (observability).
Version string
Logger *zap.Logger
// TLSConfig, when set, encrypts the payload end-to-end INSIDE the
// tunnel: after the plaintext holt handshake the peer runs a
// TLS server over the stream and serves Handler over HTTPS. The
// hub must dial with a matching client config (hub.WithPeerTLS).
// This is independent of any TLS on the outer gRPC connection —
// it stays encrypted even if that hop is plaintext or terminated
// at a proxy. NextProtos is forced to h2.
TLSConfig *tls.Config
}
Options wires one attach loop.