config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config holds config data and operations

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrGotHelp returned after showing requested help
	ErrGotHelp = errors.New("help printed")
	// ErrBadArgs returned after showing command args error message
	ErrBadArgs = errors.New("option error printed")
	// ErrCancelled returned when Ctrl+C pressed (Interrupt signal)
	ErrCancelled = errors.New("cancelled")
)

Functions

func Close

func Close(exitFunc func(code int), e error)

Close runs exit after deferred cleanups have run and able show config parsing errors

func New

func New(cfg interface{}, args ...string) error

New loads flags from args (if given) or command flags and ENV otherwise

func WaitSignal

func WaitSignal(gctx context.Context) error

WaitSignal waits group for gracefull shutdown

Types

type Config

type Config struct {
	Args struct {
		//nolint:staticcheck // Multiple struct tag "choice" is allowed
		Command string `choice:"mono" choice:"bus" choice:"handler" choice:"proxy" description:"mono|bus|handler|proxy"`
	} `positional-args:"yes" required:"yes"`
	Debug       bool   `long:"debug"  description:"Run in debug mode"`
	MQ          string `long:"mq_url" default:"localhost:4222" description:"Addr:port for NATS server"`
	OutsideHost string `long:"host" default:"localhost:8081" description:"Addr:port for request from outside"`
	BindHTTP    string `long:"bind_http" default:":8081" description:"Addr:port for HTTP server"`
	HTML        string `long:"html" default:"" description:"Path to static html files"`
}

Config holds all config vars

func (Config) UseNRPC

func (cfg Config) UseNRPC() bool

UseNRPC returns true if NRPC used

func (Config) UseProxy

func (cfg Config) UseProxy() bool

UseProxy returns true if Proxy services used

func (Config) UseServer

func (cfg Config) UseServer() bool

UseServer returns true if applied logic used

Jump to

Keyboard shortcuts

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