server

package
v0.0.0-...-ebae57e Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Overview

DI registration for shared servers and the application orchestrator.

gRPC server construction and interceptors.

Package server constructs and configures the shared HTTP and gRPC servers.

Application orchestrates starting and gracefully shutting down HTTP, gRPC, database (gorm), Valkey, and telemetry providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGRPC

func NewGRPC(logger *zerolog.Logger) *grpc.Server

NewGRPC builds and returns a *grpc.Server with OTel StatsHandler, panic recovery + logging interceptors (unary and stream), and conservative message-size limits.

func NewHTTP

func NewHTTP(cfg *config.Config, logger *zerolog.Logger, registry *telemetry.Registry) *echo.Echo

NewHTTP builds and returns an *echo.Echo with the standard middleware stack and shared routes (/healthz, /readyz, /metrics).

func Register

func Register(c do.Injector) error

Register wires *echo.Echo, *grpc.Server, and the Application orchestrator into the DI container. It depends on config, logger, telemetry providers, and the health registry already being registered.

Note: samber/do v2's Provide signature is `func Provide[T any](i Injector, provider Provider[T])` and returns no error. Any construction failure surfaces later via do.Invoke. We rely on the provider functions to surface their own errors via Invoke.

Types

type Application

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

Application holds the runtime components required to start and stop the service. It is constructed from a populated DI container and keeps the orchestration logic separate from the wiring code.

func NewApplication

func NewApplication(injector do.Injector, cfg *config.Config, logger *zerolog.Logger) *Application

NewApplication builds the runtime orchestrator from a populated DI container. It reads optional shutdown callbacks from the container and will look up infrastructure dependencies at runtime inside Run.

func (*Application) Echo

func (a *Application) Echo() *echo.Echo

Echo returns the underlying HTTP server. Tests and callers outside the package may use it to mount routes or drive httptest servers. The server is resolved lazily on the first call so that routes are available before Run().

func (*Application) HTTPAddr

func (a *Application) HTTPAddr() string

HTTPAddr returns the bound listener address after Run() has started the HTTP server. It returns an empty string before the server has started.

func (*Application) HasHTTPStarted

func (a *Application) HasHTTPStarted() <-chan struct{}

HasHTTPStarted returns a channel that is closed once the HTTP listener has been bound. Callers can use it to wait for the server to be ready.

func (*Application) Logger

func (a *Application) Logger() *zerolog.Logger

Logger returns the application logger.

func (*Application) Run

func (a *Application) Run(ctx context.Context) error

Run starts the HTTP and gRPC servers and blocks until a signal or a server error occurs, then performs an ordered graceful shutdown.

func (*Application) StartHTTP

func (a *Application) StartHTTP(ctx context.Context) error

StartHTTP eagerly resolves and starts the HTTP server. It is safe to call multiple times; subsequent calls are no-ops. The gRPC server is still started inside Run().

Jump to

Keyboard shortcuts

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