app

package module
v0.0.0-...-bd6f409 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2021 License: MIT Imports: 25 Imported by: 0

README

go-bootstrap

Simple library for bootstrapping your Go application.

It takes care of reading application config, setting up logging, and handling termination signals.

You may extend its capabilities by registering a custom extension with app.Extension interface.

@todo more detailed docs, add tests, ...

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Release string
)

Functions

func LogLevel

func LogLevel() zapcore.Level

func LogLevelHttpHandler

func LogLevelHttpHandler() http.Handler

func Run

func Run(appCallback func(appCtx context.Context, logger *zap.SugaredLogger))

func SetLogLevel

func SetLogLevel(level zapcore.Level)

func Start

func Start(appCallback func(appCtx Context, logger *zap.SugaredLogger))

Types

type Application

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

func WithConfig

func WithConfig(config interface{}) *Application

func WithExtensions

func WithExtensions(extensions ...Extension) *Application

func WithPanicwatchConfig

func WithPanicwatchConfig(panicwatchConfig func(*panicwatch.Config, *zap.SugaredLogger)) *Application

func WithSentryConfig

func WithSentryConfig(sentryConfig func(*sentry.ClientOptions)) *Application

func WithTerminationSignals

func WithTerminationSignals(signals ...os.Signal) *Application

func WithZapConfig

func WithZapConfig(zapConfig func(*zap.Config)) *Application

func (*Application) Run

func (app *Application) Run(appCallback func(appCtx context.Context, logger *zap.SugaredLogger))

func (*Application) Start

func (app *Application) Start(appCallback func(appCtx Context, logger *zap.SugaredLogger))

func (*Application) WithConfig

func (app *Application) WithConfig(config interface{}) *Application

func (*Application) WithExtensions

func (app *Application) WithExtensions(extensions ...Extension) *Application

func (*Application) WithPanicwatchConfig

func (app *Application) WithPanicwatchConfig(
	panicwatchConfig func(*panicwatch.Config, *zap.SugaredLogger),
) *Application

func (*Application) WithSentryConfig

func (app *Application) WithSentryConfig(sentryConfig func(*sentry.ClientOptions)) *Application

func (*Application) WithTerminationSignals

func (app *Application) WithTerminationSignals(signals ...os.Signal) *Application

func (*Application) WithZapConfig

func (app *Application) WithZapConfig(zapConfig func(*zap.Config)) *Application

type CliContext

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

func NewCliContext

func NewCliContext(signals ...os.Signal) *CliContext

func (*CliContext) Deadline

func (c *CliContext) Deadline() (deadline time.Time, ok bool)

func (*CliContext) Done

func (c *CliContext) Done() <-chan struct{}

func (*CliContext) Err

func (c *CliContext) Err() error

func (*CliContext) IsShuttingDown

func (c *CliContext) IsShuttingDown() bool

func (*CliContext) Shutdown

func (c *CliContext) Shutdown()

func (*CliContext) StartWorker

func (c *CliContext) StartWorker(worker func())

func (*CliContext) Value

func (c *CliContext) Value(key interface{}) interface{}

func (*CliContext) WaitForWorkers

func (c *CliContext) WaitForWorkers()

type ConfigValidator

type ConfigValidator interface {
	Validate() error
}

type Context

type Context interface {
	context.Context

	Shutdown()
	IsShuttingDown() bool
	StartWorker(worker func())
	WaitForWorkers()
}

type Extension

type Extension interface {
	Initialize(configLoader func(config interface{}), logger *zap.SugaredLogger) error
	Start(appCtx Context, logger *zap.SugaredLogger)
}

type PanicwatchSentryIntegration

type PanicwatchSentryIntegration struct {
}

func (*PanicwatchSentryIntegration) Name

func (*PanicwatchSentryIntegration) SetupOnce

func (p *PanicwatchSentryIntegration) SetupOnce(client *sentry.Client)

type TrimPathSentryIntegration

type TrimPathSentryIntegration struct {
	// AppModule is optional (for cases where auto-detection doesn't work) and is used when building with -trimpath.
	// Full module name is expected (optionally ending with slash), eg: github.com/grongor/panicwatch
	AppModule string
	// AppPath is optional (for cases where auto-detection doesn't work) and is used when building without -trimpath.
	// Absolute path to the root module is expected (optionally ending with slash), eg: /myprojects/panicwatch/
	AppPath string
}

func (*TrimPathSentryIntegration) Name

func (*TrimPathSentryIntegration) SetupOnce

func (t *TrimPathSentryIntegration) SetupOnce(client *sentry.Client)

Jump to

Keyboard shortcuts

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