app

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppInfo added in v0.4.0

type AppInfo struct {
	ConfigPath string
}

AppInfo contains general app information and settings

type AppInformer added in v0.4.0

type AppInformer func() *AppInfo

type Application

type Application interface {
	RegisterService(name string, cfg any, factory ServiceFactory) error // service name must match the unquoted yaml key format (e.g. [a-zA-Z_]+)
	Run(config any)
}

Application is the main application interface

func New

func New(appName, appVersion string) Application

New creates a new Application instance

type Config

type Config struct {
	HTTP          httpserver.Config `yaml:"http" group:"HTTP endpoint configuration"`
	Sentry        sentry.Config     `yaml:"sentry" group:"Sentry configuration"`
	ShutdownDelay time.Duration     `yaml:"shutdown_delay" description:"Time to wait before shutting down"`
	LogLevel      string            `yaml:"log_level" description:"Log level in production mode" default:"info" choices:"debug,info,warn,error,dpanic,panic,fatal"`
	Production    bool              `yaml:"production" description:"Production mode"`
}

type HandlerDefinition

type HandlerDefinition struct {
	Endpoint string // used as "method" label for the `servicename_request_latency{method="endpoint"}` metric
	Method   string // GET, POST, etc.
	Path     string // URL path (Gorilla URL vars allowed)
	Func     httpserver.HandlerWithResult
}

HandlerDefinition contains method definition to use by HTTP server

type Service

type Service interface {
	GetHandlers() []HandlerDefinition
	Run(ctx context.Context) error
}

Service is an interface that application services should implement

type ServiceFactory

type ServiceFactory func(
	cfg any,
	logger log.MetaLogger,
	metricsRegistry *metrics.Registry,
	statusReporter appstatus.ServiceStatusReporter,
	appInformer AppInformer,
) (Service, error)

ServiceFactory is a function that creates a service instance

Jump to

Keyboard shortcuts

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