def

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package def provides default values for both commands and tests.

Index

Constants

View Source
const (
	LogServer     = "server"     // "OpenAPI", "gRPC", "Prometheus metrics", etc.
	LogRemoteIP   = "remoteIP"   // IP address.
	LogAddr       = "addr"       // host:port.
	LogHost       = "host"       // DNS hostname or IPv4/IPv6 address.
	LogPort       = "port"       // TCP/UDP port number.
	LogHTTPMethod = "httpMethod" // GET, POST, etc.
	LogHTTPStatus = "httpStatus" // Status code: 200, 404, etc.
	LogFunc       = "func"       // RPC/event handler method name, REST resource path.
	LogUserID     = "userID"
)

Log field names.

Variables

View Source
var (
	ProgName    = strings.TrimSuffix(path.Base(os.Args[0]), ".test")
	Hostname, _ = os.Hostname()

	TestSecond  = time.Duration(float64(time.Second) * testTimeFactor)
	TestTimeout = 7 * TestSecond
)

Constants.

Functions

func Init

func Init() error

Init must be called once before using this package. It provides common initialization for both commands and tests.

func MergeCancel added in v1.4.0

func MergeCancel(parent context.Context, extra Cancellation) (ctx context.Context, cancel context.CancelFunc)

MergeCancel implements proposal https://github.com/golang/go/issues/36503.

func NewGoose added in v1.3.0

func NewGoose() *goose.Instance

NewGoose creates a goose instance with configured logger.

func NewMySQLConfig added in v1.3.0

func NewMySQLConfig(cfg MySQLConfig) *mysql.Config

NewMySQLConfig creates a new default config for MySQL.

func Version

func Version() string

Version returns application version based on build info.

Types

type Cancellation added in v1.4.0

type Cancellation interface {
	Deadline() (deadline time.Time, ok bool)
	Done() <-chan struct{}
	Err() error
}

A Cancellation is an interface capturing only the deadline and cancellation functionality of a context.

type Metrics

type Metrics struct {
	PanicsTotal           prometheus.Counter
	MisconfigurationTotal prometheus.Counter
}

Metrics shared by all packages.

func NewMetrics

func NewMetrics(reg *prometheus.Registry) Metrics

NewMetrics registers and returns metrics shared by all packages.

type MySQLConfig added in v1.3.0

type MySQLConfig struct {
	Addr   netx.Addr
	DBName string
	User   string
	Pass   string
}

MySQLConfig contains MySQL connection and authentication details.

Jump to

Keyboard shortcuts

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