runtime

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 14 Imported by: 0

README

Shared process runtime

This package owns resources and lifecycle behavior that are not specific to HTTP or gRPC.

Responsibilities and boundaries

  • Telemetry owns the logger and observability providers.
  • Runtime owns process-shared configuration plus PostgreSQL and Redis resources.
  • RunLifecycle coordinates blocking startup with root-context cancellation and bounded shutdown; each cmd package converts OS signals into that root context.

Extending

  • Add only resources whose construction and lifecycle are shared by multiple process types.
  • Expose one shutdown path for every owned resource and preserve reverse dependency order.
  • Keep handlers, services, workers, and feature wiring in their process composition packages.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunLifecycle added in v0.7.0

func RunLifecycle(rootCtx context.Context, stop context.CancelFunc, application Lifecycle) int

Types

type Application

type Application interface{ Shutdown(context.Context) error }

type Lifecycle added in v0.7.0

type Lifecycle struct {
	Start       func() error
	Shutdown    func(context.Context) error
	GracePeriod time.Duration
	Logger      logger.Logger
	Component   string
}

type Runtime

type Runtime struct {
	*Telemetry
	Config      config.RuntimeConfig
	DBPool      *pgxpool.Pool
	RedisClient *goredis.Client
}

func New

func New(ctx context.Context, cfg config.RuntimeConfig) (*Runtime, error)

func (*Runtime) Shutdown

func (r *Runtime) Shutdown(ctx context.Context) error

type Telemetry added in v0.7.0

type Telemetry struct {
	Logger        logger.Logger
	Observability observability.Runtime
}

Telemetry owns the process logger and observability providers without data services.

func NewTelemetry added in v0.7.0

func NewTelemetry(ctx context.Context, cfg config.RuntimeConfig) (*Telemetry, error)

NewTelemetry creates process telemetry with the configured service identity.

func (*Telemetry) Shutdown added in v0.7.0

func (t *Telemetry) Shutdown(ctx context.Context) error

Shutdown flushes exported telemetry before syncing the local logger.

Jump to

Keyboard shortcuts

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