service

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: MIT Imports: 13 Imported by: 0

README

service

GoDoc Tests codecov

Helper functions for service in golang.

Installation

go get github.com/pkgz/service

Usage

TODO

Licence

MIT License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingArgs = errors.New("helper.ARGS not find in args")
)

Functions

func ContextWithCancel

func ContextWithCancel() (context.Context, context.CancelFunc)

ContextWithCancel - creating context with cancel. Also start goroutine which waiting for SIGTERM signal and closing the context.

func Init

func Init(args interface{}) (context.Context, context.CancelFunc, error)

Init - allows easily initialize app. Will parse environment arguments, and will initialize application context with cancel.

func NewMongo added in v0.0.2

func NewMongo(ctx context.Context, host string) (*mongo.Client, error)

NewMongo - initialize mongo-driver client. Also pinging mongo.

func ParseEnv

func ParseEnv(args interface{}) error

ParseEnv - parsing environment arguments. Expect pointer to struct.

Types

type ARGS

type ARGS struct {
	Port  int  `long:"port" env:"PORT" default:"8080" description:"service rest port"`
	Debug bool `long:"debug" env:"DEBUG" description:"debug mode"`
}

ARGS - default argument for application

Jump to

Keyboard shortcuts

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