app

package
v0.0.0-...-6f3dba9 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const FriendlyServiceName = "Boilerplate Cron/Daemon"

FriendlyServiceName is the visible name of the service.

View Source
const LogTag = ServiceName

LogTag is usually a static value across all instances of the same application as such it is set here as a constant value.

It represents an identifier which can be used to separate logs from different sources.

Falls back to the ServiceName.

View Source
const ServiceName = "boilerplate.crondaemon"

ServiceName is an identifier-like name used anywhere this app needs to be identified.

It identifies the service itself, the actual instance needs to be identified via environment and other details.

Variables

Module is the collection of all modules of the application.

Functions

func NewDebugConfig

func NewDebugConfig(config Config) *fxdebug.Config

NewDebugConfig creates a debug config for the debug server constructor.

func NewLoggerConfig

func NewLoggerConfig(config Config) (*fxlog.Config, error)

NewLoggerConfig creates a logger config for the logger constructor.

func NewService

func NewService(params ServiceParams) daemon.Daemon

NewService returns a new service instance.

Types

type Config

type Config struct {
	// Meaningful values are recommended (eg. production, development, staging, release/123, etc)
	//
	// "development" is treated special: address types will use the loopback interface as default when none is defined.
	// This is useful when developing locally and listening on all interfaces requires elevated rights.
	Environment string `env:"" default:"production"`

	// Turns on some debug functionality: more verbose logs, exposed pprof, expvar and net trace in the debug server.
	Debug bool `env:""`

	// Defines the log format.
	// Valid values are: json, logfmt
	LogFormat string `env:"" split_words:"true" default:"json"`

	// Debug and health check server address
	DebugAddr string `flag:"" split_words:"true" default:":10000" usage:"Debug and health check server address"`

	// Timeout for graceful shutdown
	ShutdownTimeout time.Duration `flag:"" split_words:"true" default:"15s" usage:"Timeout for graceful shutdown"`

	// Run the service in daemon mode instead of just running the job once.
	Daemon bool `flag:"" default:"false" usage:"Start as daemon instead of single run"`

	// Schedule of the job when running in daemon mode.
	DaemonSchedule time.Duration `env:"" split_words:"true"`
}

Config holds any kind of configuration that comes from the outside world and is necessary for running the application.

type Runner

type Runner struct {
	fx.In

	Logger log.Logger
	Status *healthz.StatusChecker

	DebugErr  fxdebug.Err
	DaemonErr daemon.Err
}

Runner executes the application and waits for it to end.

func (*Runner) Run

func (r *Runner) Run(app interface {
	Done() <-chan os.Signal
}) error

Run waits for the application to finish or exit because of some error.

type ServiceParams

type ServiceParams struct {
	dig.In

	Config       Config
	Logger       log.Logger       `optional:"true"`
	ErrorHandler emperror.Handler `optional:"true"`
}

ServiceParams provides a set of dependencies for the service constructor.

Jump to

Keyboard shortcuts

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