app

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 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 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 Options added in v0.4.1

type Options struct {
	Logger          log.MetaLogger
	MetricsRegistry *metrics.Registry
	ServiceReporter appstatus.ServiceStatusReporter
	Production      bool
	ConfigPath      string
}

AppInfo contains general app information and settings

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,
	options Options,
) (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