Documentation ¶
Overview ¶
Package http contains a Alloy-serializable definition of the dskit config in https://github.com/grafana/dskit/blob/main/server/server.go#L72.
Index ¶
Constants ¶
const ( DefaultHTTPPort = 8080 // using zero as default grpc port to assing random free port when not configured DefaultGRPCPort = 0 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GRPCConfig ¶
type GRPCConfig struct { ListenAddress string `alloy:"listen_address,attr,optional"` ListenPort int `alloy:"listen_port,attr,optional"` ConnLimit int `alloy:"conn_limit,attr,optional"` MaxConnectionAge time.Duration `alloy:"max_connection_age,attr,optional"` MaxConnectionAgeGrace time.Duration `alloy:"max_connection_age_grace,attr,optional"` MaxConnectionIdle time.Duration `alloy:"max_connection_idle,attr,optional"` ServerMaxRecvMsg int `alloy:"server_max_recv_msg_size,attr,optional"` ServerMaxSendMsg int `alloy:"server_max_send_msg_size,attr,optional"` ServerMaxConcurrentStreams uint `alloy:"server_max_concurrent_streams,attr,optional"` }
GRPCConfig configures the gRPC dskit started by dskit.Server.
func (*GRPCConfig) Into ¶
func (g *GRPCConfig) Into(c *dskit.Config)
Into applies the configs from GRPCConfig into a dskit.Into.
type HTTPConfig ¶
type HTTPConfig struct { ListenAddress string `alloy:"listen_address,attr,optional"` ListenPort int `alloy:"listen_port,attr,optional"` ConnLimit int `alloy:"conn_limit,attr,optional"` ServerReadTimeout time.Duration `alloy:"server_read_timeout,attr,optional"` ServerWriteTimeout time.Duration `alloy:"server_write_timeout,attr,optional"` ServerIdleTimeout time.Duration `alloy:"server_idle_timeout,attr,optional"` }
HTTPConfig configures the HTTP dskit started by dskit.Server.
func (*HTTPConfig) Into ¶
func (h *HTTPConfig) Into(c *dskit.Config)
Into applies the configs from HTTPConfig into a dskit.Into.
type ServerConfig ¶
type ServerConfig struct { // HTTP configures the HTTP dskit. Note that despite the block being present or not, // the dskit is always started. HTTP *HTTPConfig `alloy:"http,block,optional"` // GRPC configures the gRPC dskit. Note that despite the block being present or not, // the dskit is always started. GRPC *GRPCConfig `alloy:"grpc,block,optional"` // GracefulShutdownTimeout configures a timeout to gracefully shut down the server. GracefulShutdownTimeout time.Duration `alloy:"graceful_shutdown_timeout,attr,optional"` }
ServerConfig is an Alloy configuration that allows one to configure a dskit.Server. It exposes a subset of the available configurations.
func DefaultServerConfig ¶
func DefaultServerConfig() *ServerConfig
DefaultServerConfig creates a new ServerConfig with defaults applied. Note that some are inherited from dskit, but copied in our config model to make the mixin logic simpler.
type TargetServer ¶
type TargetServer struct {
// contains filtered or unexported fields
}
TargetServer is wrapper around dskit.Server that handles some common configuration used in all components that expose a network server. It just handles configuration and initialization, the handlers implementation are left to the consumer.
func NewTargetServer ¶
func NewTargetServer(logger log.Logger, metricsNamespace string, reg prometheus.Registerer, config *ServerConfig) (*TargetServer, error)
NewTargetServer creates a new TargetServer, applying some defaults to the server configuration. If provided config is nil, a default configuration will be used instead.
func (*TargetServer) GRPCListenAddr ¶
func (ts *TargetServer) GRPCListenAddr() string
GRPCListenAddr returns the listen address of the gRPC server.
func (*TargetServer) HTTPListenAddr ¶
func (ts *TargetServer) HTTPListenAddr() string
HTTPListenAddr returns the listen address of the HTTP server.
func (*TargetServer) MountAndRun ¶
func (ts *TargetServer) MountAndRun(mountRoute func(router *mux.Router)) error
MountAndRun mounts the handlers and starting the server.
func (*TargetServer) StopAndShutdown ¶
func (ts *TargetServer) StopAndShutdown()
StopAndShutdown stops and shuts down the underlying server.