Documentation ¶
Index ¶
- Variables
- func ContextWithClientCert(ctx context.Context, clientCert *x509.Certificate) context.Context
- func NewLoggingHandler(handler http.Handler, logger *zap.Logger, suffix string) http.Handler
- func RegisterAdminHandlers(gateway *Gateway, mux *http.ServeMux)
- func UserAgentInterceptor(call connect.UnaryFunc) connect.UnaryFunc
- type AdminConfig
- type DescriptorCacheConfig
- type Gateway
- type GatewayConfig
- type ServiceConfig
Constants ¶
This section is empty.
Variables ¶
var (
// Version is the gateway version to report.
Version = buildVersion + buildVersionSuffix
)
Functions ¶
func ContextWithClientCert ¶
ContextWithClientCert stores the given client certificate in the given context. This is set when handling an incoming request, allowing the client's identity to be sent to backends in request headers.
func NewLoggingHandler ¶
NewLoggingHandler wraps the given handler so that all incoming requests are logged.
func RegisterAdminHandlers ¶
RegisterAdminHandlers registers "/admin/" HTTP handlers on the given mux, to expose admin functions for the given gateway.
Types ¶
type AdminConfig ¶
type AdminConfig struct { // If true, admin endpoints are served via the same listeners/ports // as other traffic. If false, the following two properties are // used to construct a separate listener. UseMainListeners bool ListenAddress string UseTLS bool }
AdminConfig is the configuration for the gateway's admin endpoints.
type DescriptorCacheConfig ¶
type DescriptorCacheConfig interface {
// contains filtered or unexported methods
}
DescriptorCacheConfig is the configuration for the mechanism used to cache schemas, so that a last-known-good cached schema can be used if a schema can't otherwise be loaded from a remote source on startup.
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway is a hot-swappable Knit gateway. It watches schemas for updates and then replaces the underlying HTTP handler with one that has new configuration when an update is observed.
func CreateGateway ¶
func CreateGateway(ctx context.Context, logger *zap.Logger, config *GatewayConfig) (g *Gateway, err error)
CreateGateway creates a new gateway with the given configuration. This starts background goroutines which will terminate when the given context is cancelled.
func (*Gateway) AwaitReady ¶
AwaitReady returns nil when the gateway is ready and all schemas have been downloaded. It returns an error if the given context is cancelled or if the configured startup max wait period elapses.
func (*Gateway) CreateHandler ¶
CreateHandler creates the underlying HTTP handler. This must be called explicitly once by the application. Thereafter, it is called automatically when schemas are updated.
func (*Gateway) Pattern ¶
Pattern returns the URI pattern that this gateeway handles. This method should only be invoked after first calling CreateHandler.
func (*Gateway) ServeHTTP ¶
func (g *Gateway) ServeHTTP(responseWriter http.ResponseWriter, request *http.Request)
ServeHTTP implements http.Handler. If the gateway is not yet ready (schemas have not yet been successfully loaded; AwaitReady returns an error), this will return 503 Service Unavailable.
type GatewayConfig ¶
type GatewayConfig struct { ListenAddress string UnixSocket string TLSConfig *tls.Config CORSConfig cors.Options Services map[string]ServiceConfig MaxParallelismPerRequest int StartupMaxWait time.Duration PollingPeriod time.Duration PollingJitter float64 PollingDebounce time.Duration Cache DescriptorCacheConfig Admin *AdminConfig RawConfig []byte }
GatewayConfig is the configuration for a Knit gateway.
func LoadConfig ¶
func LoadConfig(path string) (*GatewayConfig, error)
LoadConfig reads the config file at the given path and returns the resulting GatewayConfig on success.
type ServiceConfig ¶
type ServiceConfig struct { BaseURL *url.URL HTTPClient connect.HTTPClient ConnectOpts []connect.ClientOption Descriptors prototransform.SchemaPoller Cacheable bool }
ServiceConfig is the configuration for a single RPC service.