service

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Main added in v0.5.2

func Main(use, short string, s Runnable)

Main runs your service, calling its BindFlags and BindEnvironment methods if it implements them, and then calling its Run method.

func Run

func Run(service func(ctx context.Context, l logger.Logger) error) error

Run a service. A context is created which will be canceled when the service receives a SIGINT or SIGTERM signal. A logger is created. These are passed to the service function. The logger is created with a level of DEBUG if the DEBUG environment variable is set to true.

Types

type BindEnvironment added in v0.5.2

type BindEnvironment interface {
	BindEnvironment() error
}

BindEnvironment can optionally be implemented by a service to bind environment variables to the service. BindEnvironment will be called after BindFlags and before Run.

type BindFlags added in v0.5.2

type BindFlags interface {
	BindFlags(flags *pflag.FlagSet)
}

BindFlags can optionally be implemented by a service to bind command line flags to the service. BindFlags will be called before BindEnvironment and Run.

type Runnable added in v0.5.2

type Runnable interface {
	Run(ctx context.Context, l logger.Logger) error
}

Runnable must be implemented by all services that are run with Main.

Jump to

Keyboard shortcuts

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