service

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GRPC

GRPC returns a standard GRPC server for the provided handler. Router-bypass and TLS config are inferred from the environment.

Currently only supports running in router-bypass mode, unlike HTTP.

func HTTP

func HTTP(l logrus.FieldLogger, m metrics.Provider, h http.Handler, opts ...func(*httpOptions)) cmdutil.Server

HTTP returns a standard HTTP server for the provided handler. Port, TLS, and router-bypass config are inferred from the environment.

func SkipEnforceHTTPS

func SkipEnforceHTTPS() func(*httpOptions)

SkipEnforceHTTPS allows services to opt-out of SSL enforcement required for productionization. It should only be used in environments where SSL is not available.

func WithTLSConfig

func WithTLSConfig(tlscfg *tls.Config) func(*httpOptions)

WithTLSConfig allows services to use a specific TLS configuration instead of the default one constructed from environment variables.

Types

type OptionFunc

type OptionFunc func(*options)

OptionFunc is a function that modifies internal service options.

func CustomMetricsSuffix

func CustomMetricsSuffix(s string) OptionFunc

CustomMetricsSuffix is an OptionFunc that has New use the given suffix on metrics recorded with MetricsProvider instead of inferring it from DYNO.

func SkipMetricsSuffix

func SkipMetricsSuffix() OptionFunc

SkipMetricsSuffix is an OptionFunc that has New skip automatically adding the process type from DYNO as a suffix on metrics recorded with MetricsProvider.

type Standard

type Standard struct {
	App             string
	Deploy          string
	Logger          logrus.FieldLogger
	MetricsProvider xmetrics.Provider
	// contains filtered or unexported fields
}

Standard is a standard service.

func New

func New(appConfig interface{}, ofs ...OptionFunc) *Standard

New returns a Standard service with logging, rollbar, metrics, debugging, and common signal handling.

It calls envdecode.MustStrictDecode on the provided appConfig.

func (*Standard) Add

func (s *Standard) Add(svs ...cmdutil.Server)

Add adds cmdutil.Servers to be managed.

func (*Standard) Run

func (s *Standard) Run()

Run runs all standard and Added cmdutil.Servers.

If a panic is encountered, it is reported to Rollbar.

If the error returned by oklog/run.Run is non-nil, it is logged with s.Logger.Fatal.

Jump to

Keyboard shortcuts

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