kit

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithAfterStart

func WithAfterStart(funcs []func() error) func(*Server)

WithAfterStart executes functions after servers start.

func WithAfterStop

func WithAfterStop(funcs []func() error) func(*Server)

WithAfterStop executes functions after servers stop.

func WithBeforeStart

func WithBeforeStart(funcs []func() error) func(*Server)

WithBeforeStart executes functions before servers start.

func WithBeforeStop

func WithBeforeStop(funcs []func() error) func(*Server)

WithBeforeStop executes functions before servers stop.

func WithChiAndGRPCServer added in v0.2.7

func WithChiAndGRPCServer(cfg chi.Config, gcfg grpc.Config) func(*Server)

WithChiAndGRPCServer provides chi http and grpc servers and runs them after Start.

func WithChiServer

func WithChiServer(cfg chi.Config) func(*Server)

WithChiServer provides chi http kit and runs it after Start.

func WithCustomGoroutines

func WithCustomGoroutines(funcs []func() error) func(*Server)

WithCustomGoroutines adds goroutines to main errgroup instance of kit.

func WithGRPCServer

func WithGRPCServer(cfg grpc.Config) func(*Server)

WithGRPCServer provides grpc kit and runs it after Start.

func WithGRPCServerPort

func WithGRPCServerPort(port string) func(*Server)

WithGRPCServerPort sets provided port to grpc kit.

func WithGinAndGRPCServer added in v0.2.7

func WithGinAndGRPCServer(cfg gin.Config, gcfg grpc.Config) func(*Server)

WithGinAndGRPCServer provides gin http and grpc servers and runs them after Start.

func WithGinServer

func WithGinServer(cfg gin.Config) func(*Server)

WithGinServer provides gin http kit and runs it after Start.

func WithHTTPServerPort

func WithHTTPServerPort(port string) func(*Server)

WithHTTPServerPort sets provided port to http kit.

func WithParallelMode

func WithParallelMode() func(*Server)

WithParallelMode sets http and grpc servers to bind on one port and segregate requests by headers.

func WithServerName

func WithServerName(name string) func(*Server)

WithServerName sets name of service.

Types

type Env

type Env struct {
	ServerVersion string `env:"KIT_SERVER_VERSION" envDefault:"0.0.0"`

	GracefulShutdownTimeout time.Duration `env:"KIT_GRACEFUL_SHUTDOWN" envDefault:"5s"`

	OTELJaegerHost string `env:"KIT_TRACING_JAEGER_HOST" envDefault:"localhost:4318"`

	FgprofEnable bool `env:"KIT_METRICS_FGPROF" envDefault:"false"`

	PprofEnable bool `env:"KIT_METRICS_PPROF" envDefault:"false"`

	DebugHeaders bool `env:"KIT_DEBUG_HEADERS" envDefault:"false"`
}

type Server

type Server struct {
	// !ATTENTION! Options must be set before Start.
	ServerName    string
	ServerVersion string

	RootCtx context.Context

	GinServer *gincore.Engine
	ChiServer *chicore.Mux

	GRPCServer *grpccore.Server

	// Loggers.
	DefaultLogger *zapl.Logger

	PromCollectors []prometheus.Collector
	// contains filtered or unexported fields
}

Server describes all services configurations, must be executed with Start.

func New

func New(options ...func(*Server)) *Server

New is base constructor function to create service with options, but won't start it without Start.

func (*Server) AddChiAndGRPCMixedServer added in v0.2.7

func (s *Server) AddChiAndGRPCMixedServer()

func (*Server) AddChiServer added in v0.2.7

func (s *Server) AddChiServer()

func (*Server) AddFgprofServer added in v0.2.7

func (s *Server) AddFgprofServer()

func (*Server) AddGRPCServer added in v0.2.7

func (s *Server) AddGRPCServer()

func (*Server) AddGinAndGRPCMixedServer added in v0.2.7

func (s *Server) AddGinAndGRPCMixedServer()

func (*Server) AddGinServer added in v0.2.7

func (s *Server) AddGinServer()

func (*Server) AddGracefulShutdown added in v0.2.7

func (s *Server) AddGracefulShutdown(ctx context.Context)

func (*Server) AddPrometheusServer added in v0.2.7

func (s *Server) AddPrometheusServer()

func (*Server) Start

func (s *Server) Start() error

Start runs servers with provided options.

Directories

Path Synopsis
servers
chi
gin

Jump to

Keyboard shortcuts

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