kit

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: Apache-2.0 Imports: 55 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TraceMiddleware added in v0.2.12

func TraceMiddleware(lg *zap.Logger, m *otelMetrics, tp *trace.TracerProvider, debugHeaders bool) defaultMiddleware

func WithAfterStart

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

WithAfterStart executes functions after engine start.

func WithAfterStop

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

WithAfterStop executes functions after engine stop.

func WithBeforeStart

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

WithBeforeStart executes functions before engine start.

func WithBeforeStop

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

WithBeforeStop executes functions before engine stop.

func WithChiAndGRPCServer added in v0.2.7

func WithChiAndGRPCServer(cfg ChiConfig, gcfg GRPCConfig) func(*Server)

WithChiAndGRPCServer provides metrics http and grpc engine and runs them after Start.

func WithChiServer

func WithChiServer(cfg ChiConfig) func(*Server)

WithChiServer provides metrics 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 WithEndToEndTests added in v0.2.11

func WithEndToEndTests(configPath string) func(*Server)

WithEndToEndTests enables server to run end-to-end tests in cli mode.

func WithGRPCServer

func WithGRPCServer(cfg GRPCConfig) 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 GinConfig, gcfg GRPCConfig) func(*Server)

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

func WithGinServer

func WithGinServer(cfg GinConfig) 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 engine 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 ChiConfig added in v0.2.12

type ChiConfig struct {
	Default bool
}

func (*ChiConfig) NewDefaultChi added in v0.2.12

func (c *ChiConfig) NewDefaultChi(ctx context.Context, lg *zap.Logger, serverName, serverVersion, jaegerHost string, debugHeaders bool) (*chi.Mux, *trace.TracerProvider)

type E2eTests added in v0.2.12

type E2eTests []e2eTest

type GRPCConfig added in v0.2.12

type GRPCConfig struct {
	Default bool
}

func (*GRPCConfig) NewDefaultGRPCServer added in v0.2.12

func (c *GRPCConfig) NewDefaultGRPCServer() *grpc.Server

type GinConfig added in v0.2.12

type GinConfig struct {
	Default bool
	Blank   bool
}

func (*GinConfig) NewBlankGin added in v0.2.12

func (c *GinConfig) NewBlankGin() *gin.Engine

func (*GinConfig) NewDefaultGin added in v0.2.12

func (c *GinConfig) NewDefaultGin() *gin.Engine

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 work without Start.

func (*Server) Start

func (s *Server) Start() error

Start starts all engine. Start runs engine with provided options.

Jump to

Keyboard shortcuts

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