setup

package
v0.0.0-...-086ef7a Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GitVersion string

GitVersion should be substituted during build time by the git version. This is done using go linker flags: -ldflags "-X bitbucket.org/sweetbridge/oracles/go-lib/setup.GitVersion=$(git describe)

Functions

func CPUProfile

func CPUProfile(filename string, minutes int)

CPUProfile dumps a CPU profile every given `minutes`

func Flag

func Flag(positionalArgs string, commands ...string)

Flag parses flag and setups usage function. `positionalArgs` is a string representing positional args, eg: "arg1 arg2 arg3" `commands` if provided is a positional argument command description.

func FlagCheckMany

func FlagCheckMany(checkers ...Checker) error

FlagCheckMany is a helper function to check many flag components

func FlagFail

func FlagFail(err error)

FlagFail - exits the main process and displays usage information

func FlagSimpleInit

func FlagSimpleInit(name, positionalArgs string, rollbarKey *string, flags ...Checker)

FlagSimpleInit provides a common functionality to setup the command line flags. `positionalArgs` documents expected positional argumentes, eg `"arg1 arg2 arg3"`. `rollbarKey` is a pointer, because it can be a flag, which is gonig to be initialized

in this function.

func FlagValidate

func FlagValidate(positionalArgs string, checkers ...Checker)

FlagValidate runs flag checkers

func HTTPServer

func HTTPServer(name, port string, router http.Handler)

HTTPServer starts an HTTP server

func MemProfile

func MemProfile(filename string, minutes int)

MemProfile dumps a memory profile every given `minutes`

func MustEthFactory

func MustEthFactory(n network, contractsPath string, txrF ethereum.TxrFactory) (
	*ethclient.Client, ethereum.ContractFactory)

MustEthFactory creates new eth client and ContractFactory based on the network name.

func MustLogger

func MustLogger(appname string, rollbartoken string)

MustLogger setups logger

func ReadOpts

func ReadOpts(opts interface{}) errstack.E

ReadOpts reads command line params using the go-flags library

func Root

func Root() string

Root returns an absolute path to the project root It panics if root can't be located

Types

type BaseOracleFlags

type BaseOracleFlags struct {
	EthFlags
	RollbarFlags
}

BaseOracleFlags represents common oracle flags

func NewBaseOracleFlags

func NewBaseOracleFlags() BaseOracleFlags

NewBaseOracleFlags setups common flags

func (BaseOracleFlags) Check

func (b BaseOracleFlags) Check() error

Check validates the flags. It may panic!

type Checker

type Checker interface {
	Check() error
}

Checker is an interface for type which has a Check function

type ConfigFileOption

type ConfigFileOption struct {
	Config string `short:"c" long:"config" no-ini:"true" required:"true"`
}

ConfigFileOption is a struct that enables the usage of a configuration files to read options. This type is to be embedded into the the options structure. the file crawlerOpts.go gives an example

func (*ConfigFileOption) ConfigFilepath

func (r *ConfigFileOption) ConfigFilepath() string

ConfigFilepath returns the path of the config file.

type ConfigFilePathGetter

type ConfigFilePathGetter interface {
	ConfigFilepath() string
}

ConfigFilePathGetter is an Interface that allows reading the config file path

type EthFlags

type EthFlags struct {
	PkHex         *string
	PkFile        *string
	PkPwd         *string
	ContractsPath *string
	Network       *string
	NetworkConfig *string
}

EthFlags represents common Ethereum client flags

func NewEthFlags

func NewEthFlags() EthFlags

NewEthFlags associate ethereum client flags with the structure fields. This should be called before flag.Parse or Flag function.

func (EthFlags) Check

func (ef EthFlags) Check() error

Check validates the flags.

func (EthFlags) MustEthFactory

func (ef EthFlags) MustEthFactory() (*ethclient.Client, ethereum.ContractFactory)

MustEthFactory creates ethclient and contract factory based on flag options

type GasPriceFlags

type GasPriceFlags struct {
	GasPrice *big.Int
	// contains filtered or unexported fields
}

GasPriceFlags defines flag to customize gas price.

func NewGasPriceFlags

func NewGasPriceFlags() *GasPriceFlags

NewGasPriceFlags instantiates GasPriceFlags. This should be called before flag.Parse or Flag function.

func (*GasPriceFlags) Check

func (gp *GasPriceFlags) Check() error

Check validates the flags.

type PgFlags

type PgFlags struct {
	User *string `long:"user" required:"yes" description:"Username"`
	Pwd  *string `long:"pwd" description:"Password"`
	DB   *string `long:"db" description:"Database name"`
	Addr *string `long:"addr" description:"Server address" default:"localhost:5432"`
}

PgFlags represents PostgreSQL flags

func NewPgFlags

func NewPgFlags() PgFlags

NewPgFlags associate PostgreSQL client flags with the structure fields. This should be called before flag.Parse or Flag function.

func (PgFlags) Check

func (pf PgFlags) Check() error

Check validates the flags.

func (PgFlags) MustConnect

func (pf PgFlags) MustConnect() *pg.DB

MustConnect initiates Postgersql connection manager. It panics in case of error

type RollbarFlags

type RollbarFlags struct {
	Rollbar *string `long:"t" description:"rollbar token" default:""`
}

RollbarFlags wraps flags for Rollbar client

func NewRollbarFlags

func NewRollbarFlags() RollbarFlags

NewRollbarFlags setups flags for Rollbar client

func (RollbarFlags) Check

func (r RollbarFlags) Check() error

Check is a dummy Check interface implementation

Jump to

Keyboard shortcuts

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