Documentation
¶
Index ¶
- func ParseSize(s string) (int64, error)
- func RequestIDFromContext(ctx context.Context) string
- type Config
- type EndpointConfig
- type GRPCConfig
- type HTTPConfig
- type HTTPServer
- type Hub
- func (h *Hub) IsConnected(endpointID string) bool
- func (h *Hub) Register(endpointID string, sender TunnelSender, ep *EndpointConfig) error
- func (h *Hub) Resolve(requestID string, resp *hookerv1.WebhookResponse) bool
- func (h *Hub) RouteAsync(req *hookerv1.WebhookRequest) error
- func (h *Hub) RouteSync(ctx context.Context, req *hookerv1.WebhookRequest) (*hookerv1.WebhookResponse, error)
- func (h *Hub) Unregister(endpointID string)
- type LogConfig
- type Server
- type ServerConfig
- type TLSConfig
- type TunnelSender
- type TunnelService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequestIDFromContext ¶
RequestIDFromContext extracts the request ID from context, if present.
Types ¶
type Config ¶
type Config struct {
Server ServerConfig `mapstructure:"server"`
Log LogConfig `mapstructure:"log"`
Endpoints []EndpointConfig `mapstructure:"endpoints"`
}
func LoadConfig ¶
type EndpointConfig ¶
type GRPCConfig ¶
type HTTPConfig ¶
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
func NewHTTPServer ¶
func NewHTTPServer(hub *Hub, endpoints []EndpointConfig, maxBodySize string, logger *slog.Logger) (*HTTPServer, error)
func (*HTTPServer) Handler ¶
func (s *HTTPServer) Handler() http.Handler
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub manages active tunnel connections and routes incoming webhooks to the correct CLI agent.
func (*Hub) IsConnected ¶
IsConnected returns true if a tunnel client is connected for the endpoint.
func (*Hub) Register ¶
func (h *Hub) Register(endpointID string, sender TunnelSender, ep *EndpointConfig) error
Register associates a tunnel stream with an endpoint. Returns an error if another connection already holds the endpoint.
func (*Hub) Resolve ¶
func (h *Hub) Resolve(requestID string, resp *hookerv1.WebhookResponse) bool
Resolve delivers a webhook response from the CLI back to the waiting HTTP handler. Returns false if no handler is waiting for this request ID.
func (*Hub) RouteAsync ¶
func (h *Hub) RouteAsync(req *hookerv1.WebhookRequest) error
RouteAsync sends a webhook to the tunnel client without waiting for a response. Returns an error if no client is connected.
func (*Hub) RouteSync ¶
func (h *Hub) RouteSync(ctx context.Context, req *hookerv1.WebhookRequest) (*hookerv1.WebhookResponse, error)
RouteSync sends a webhook and blocks until the CLI responds or the context deadline is reached.
func (*Hub) Unregister ¶
Unregister removes the tunnel connection for an endpoint.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server orchestrates the HTTP and gRPC listeners.
type ServerConfig ¶
type ServerConfig struct {
HTTP HTTPConfig `mapstructure:"http"`
GRPC GRPCConfig `mapstructure:"grpc"`
TLS TLSConfig `mapstructure:"tls"`
}
type TunnelSender ¶
type TunnelSender interface {
Send(*hookerv1.ServerMessage) error
}
TunnelSender abstracts the ability to send a webhook down a gRPC stream.
type TunnelService ¶
type TunnelService struct {
hookerv1.UnimplementedTunnelServiceServer
// contains filtered or unexported fields
}
TunnelService implements the gRPC TunnelService defined in tunnel.proto.
func NewTunnelService ¶
func NewTunnelService(hub *Hub, endpoints []EndpointConfig, logger *slog.Logger) *TunnelService
func (*TunnelService) Connect ¶
func (s *TunnelService) Connect(stream hookerv1.TunnelService_ConnectServer) error