knitgateway

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2023 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Version is the gateway version to report.
	Version = buildVersion + buildVersionSuffix
)

Functions

func ContextWithClientCert added in v0.0.2

func ContextWithClientCert(ctx context.Context, clientCert *x509.Certificate) context.Context

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

func NewLoggingHandler(handler http.Handler, logger *zap.Logger, suffix string) http.Handler

NewLoggingHandler wraps the given handler so that all incoming requests are logged.

func RegisterAdminHandlers added in v0.1.0

func RegisterAdminHandlers(gateway *Gateway, mux *http.ServeMux)

RegisterAdminHandlers registers "/admin/" HTTP handlers on the given mux, to expose admin functions for the given gateway.

func UserAgentInterceptor added in v0.1.0

func UserAgentInterceptor(call connect.UnaryFunc) connect.UnaryFunc

Types

type AdminConfig added in v0.1.0

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 added in v0.0.2

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 added in v0.0.2

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 added in v0.0.2

func (g *Gateway) AwaitReady(ctx context.Context) error

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 added in v0.0.2

func (g *Gateway) CreateHandler() error

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 added in v0.0.2

func (g *Gateway) Pattern() string

Pattern returns the URI pattern that this gateeway handles. This method should only be invoked after first calling CreateHandler.

func (*Gateway) ServeHTTP added in v0.0.2

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL