app

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 23 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Flags added in v0.3.1

func Flags(v *viper.Viper, f *pflag.FlagSet)

Flags register viper compatible pflags for app

Types

type API

type API interface {
	RegisterHandler(mux *httprouter.Router)
}

API is a service that exposes API routes

type App

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

An App is a modular application with HTTP server. It allows users to register custom Services and automatically deals with the lifecycle of those services on call to Run()

func New

func New(cfg *Config) (*App, error)

New creates a new App

func (*App) Logger

func (app *App) Logger() *logrus.Logger

func (*App) RegisterService

func (app *App) RegisterService(svc interface{})

4. Service Close: `svc.Close() error` Service

  • MAY clean its state

func (*App) Run

func (app *App) Run() error

Run can be interupted by sending a SIGTERM, SIGINT signal. In which, case Run will attempt to gracefully stop all services and HTTP server

func (*App) SetLogger added in v0.4.0

func (app *App) SetLogger(logger *logrus.Logger)

type Checkable

type Checkable interface {
	RegisterCheck(h *health.Health) error
}

Checkable is a service that can expose its health status

type Closable

type Closable interface {
	Close() error
}

Closable is a service that needs to clean its state at the end of its execution

type Config

type Config struct {
	Logger       *kilnlog.Config
	Server       *kilnhttp.ServerConfig
	Healthz      *kilnhttp.ServerConfig
	StartTimeout *types.Duration
	StopTimeout  *types.Duration
}

func ConfigFromViper added in v0.3.1

func ConfigFromViper(v *viper.Viper) *Config

ConfigFromViper construct app Config from viper

func (*Config) SetDefault

func (cfg *Config) SetDefault() *Config

type Initializable

type Initializable interface {
	Init(context.Context) error
}

Initializable is a service that can initialize

type Loggable

type Loggable interface {
	SetLogger(logger logrus.FieldLogger)
}

Loggaable is a service that holds a logger

type Measurable

type Measurable interface {
	RegisterMetrics(prometheus.Registerer) error
}

Checkable is a service that can expose metrics

type Middleware

type Middleware interface {
	RegisterMiddleware(chain alice.Chain) alice.Chain
}

Middleware is a service that exposes a middleware to be set on an App

type Runnable

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

Runnable is a service that maintains long living task(s)

Jump to

Keyboard shortcuts

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