lifecycle

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default max message sizes - can be overridden via environment variables
	DefaultMaxRecvSize = 4 * 1024 * 1024 // 4MB
	DefaultMaxSendSize = 4 * 1024 * 1024 // 4MB
	ShutdownTimeout    = 10 * time.Second
)

Variables

View Source
var (
	ErrInvalidSizeFormat = errors.New("invalid size format")
)

Static errors for err113 compliance

Functions

func CreateComponentLogger

func CreateComponentLogger(ctx context.Context, component string, config *logger.Config) (logger.Logger, error)

CreateComponentLogger creates a logger for a specific component.

func CreateLogger

func CreateLogger(ctx context.Context, config *logger.Config) (logger.Logger, error)

CreateLogger creates a new logger instance with the provided configuration. This returns a logger that can be injected into services.

func InitializeLogger

func InitializeLogger(ctx context.Context, config *logger.Config) error

InitializeLogger initializes the logger with the provided configuration. If config is nil, it uses the default configuration.

func RunServer

func RunServer(ctx context.Context, opts *ServerOptions) error

RunServer starts a service with the provided options and handles lifecycle.

func ShutdownLogger

func ShutdownLogger() error

ShutdownLogger shuts down the logger, flushing any pending logs.

Types

type GRPCServiceRegistrar

type GRPCServiceRegistrar func(*ggrpc.Server) error

GRPCServiceRegistrar is a function type for registering gRPC services.

type LoggerImpl

type LoggerImpl struct {
	// contains filtered or unexported fields
}

LoggerImpl implements the logger.Logger interface without using global state

func NewLoggerImpl

func NewLoggerImpl(ctx context.Context, config *logger.Config) (*LoggerImpl, error)

NewLoggerImpl creates a new logger implementation

func (*LoggerImpl) Debug

func (l *LoggerImpl) Debug() *zerolog.Event

func (*LoggerImpl) Error

func (l *LoggerImpl) Error() *zerolog.Event

func (*LoggerImpl) Fatal

func (l *LoggerImpl) Fatal() *zerolog.Event

func (*LoggerImpl) Info

func (l *LoggerImpl) Info() *zerolog.Event

func (*LoggerImpl) Panic

func (l *LoggerImpl) Panic() *zerolog.Event

func (*LoggerImpl) SetDebug

func (l *LoggerImpl) SetDebug(debug bool)

func (*LoggerImpl) SetLevel

func (l *LoggerImpl) SetLevel(level zerolog.Level)

func (*LoggerImpl) Trace added in v1.0.55

func (l *LoggerImpl) Trace() *zerolog.Event

func (*LoggerImpl) Warn

func (l *LoggerImpl) Warn() *zerolog.Event

func (*LoggerImpl) With

func (l *LoggerImpl) With() zerolog.Context

func (*LoggerImpl) WithComponent

func (l *LoggerImpl) WithComponent(component string) zerolog.Logger

func (*LoggerImpl) WithFields

func (l *LoggerImpl) WithFields(fields map[string]interface{}) zerolog.Logger

type ServerOptions

type ServerOptions struct {
	ListenAddr           string
	ServiceName          string
	Service              Service
	RegisterGRPCServices []GRPCServiceRegistrar
	EnableHealthCheck    bool
	Security             *models.SecurityConfig
	LoggerConfig         *logger.Config
	Logger               logger.Logger // Optional: if provided, uses this logger instead of creating a new one
	DisableTelemetry     bool
	TelemetryFilter      grpc.TelemetryFilter
}

ServerOptions holds configuration for creating a server.

type Service

type Service interface {
	Start(context.Context) error
	Stop(context.Context) error
}

Service defines the interface that all services must implement.

Jump to

Keyboard shortcuts

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