net

package
v0.37.2 Latest Latest
Warning

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

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

Documentation

Overview

Package http contains a River serializable definition of the dskit config in https://github.com/grafana/dskit/blob/main/server/server.go#L72.

Index

Constants

View Source
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        `river:"listen_address,attr,optional"`
	ListenPort                 int           `river:"listen_port,attr,optional"`
	ConnLimit                  int           `river:"conn_limit,attr,optional"`
	MaxConnectionAge           time.Duration `river:"max_connection_age,attr,optional"`
	MaxConnectionAgeGrace      time.Duration `river:"max_connection_age_grace,attr,optional"`
	MaxConnectionIdle          time.Duration `river:"max_connection_idle,attr,optional"`
	ServerMaxRecvMsg           int           `river:"server_max_recv_msg_size,attr,optional"`
	ServerMaxSendMsg           int           `river:"server_max_send_msg_size,attr,optional"`
	ServerMaxConcurrentStreams uint          `river:"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        `river:"listen_address,attr,optional"`
	ListenPort         int           `river:"listen_port,attr,optional"`
	ConnLimit          int           `river:"conn_limit,attr,optional"`
	ServerReadTimeout  time.Duration `river:"server_read_timeout,attr,optional"`
	ServerWriteTimeout time.Duration `river:"server_write_timeout,attr,optional"`
	ServerIdleTimeout  time.Duration `river:"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 `river:"http,block,optional"`

	// GRPC configures the gRPC dskit. Note that despite the block being present or not,
	// the dskit is always started.
	GRPC *GRPCConfig `river:"grpc,block,optional"`

	// GracefulShutdownTimeout configures a timeout to gracefully shut down the server.
	GracefulShutdownTimeout time.Duration `river:"graceful_shutdown_timeout,attr,optional"`
}

ServerConfig is a River 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 flow 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.

Jump to

Keyboard shortcuts

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