util

package
v0.0.0-...-9677058 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: GPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BQConn

func BQConn(env Environment) error

BQConn returns err

func DBConn

func DBConn(env Environment) (*sql.DB, error)

DBConn returns established connection

func DLMConn

func DLMConn(env Environment) (*dlm.DLM, error)

DLMConn returns distributed lock manager pool

func ESConn

func ESConn(env Environment) (*elastic.Client, error)

ESConn returns established connection

func Merge

func Merge(dest interface{}, values ...interface{}) error

Merge assembles []map[string]interface{} to dest

func OverwriteMerge

func OverwriteMerge(dest interface{}, values ...interface{}) error

OverwriteMerge assembles []map[string]interface{} to dest

func RDBConn

func RDBConn(env Environment) (*pool.Pool, error)

RDBConn returns established connection

Types

type Env

type Env struct {
	// GWURI listens a port as grpc gateway server
	GWURI string `envconfig:"APICUBE_URI" default:"http://0.0.0.0:50000"`
	// URI listens a port as grpc server
	URI string `envconfig:"APICUBE_URI" default:"grpc://0.0.0.0:50001"`

	// RDBURI is set server host and port with db number, that's like DSN
	RDBURI string `envconfig:"APICUBE_RDBURI" default:"redis://127.0.0.1:6379/10"`

	// DLMURI is set distributed lock server host and port with db number, that's like DSN
	DLMURI string `envconfig:"APICUBE_DLMURI" default:"redis://127.0.0.1:6379/9"`

	// URI is set server host and port, which means the same as FQDN
	ESURI string `envconfig:"APICUBE_ESURL" default:"http://127.0.0.1:9200"`

	// FURI is storage uri e.g. s3://data_bucket/path/data.flac or file://
	FURI string `envconfig:"APICUBE_FURI" default:"file://./storage/data.flac"`

	// BQGSURI is bigquery loader storage
	BQGSURI string `envconfig:"APICUBE_BQGSURI" default:"gs://apicube-bigquery-development/apicube/table.json"`

	// DSN is mysql data source name
	DSN string `envconfig:"APICUBE_DSN" default:"root:@tcp(127.0.0.1:3306)/apicube?parseTime=true&loc=Asia%2FTokyo"`

	// Mode defines project environment mode
	Mode string `envconfig:"APICUBE_MODE" default:"development"`

	// Debug controls
	Debug string `envconfig:"APICUBE_DEBUG" default:""` // debug|pprof|something

	// IPFilter blocks not allowed ipaddresses
	IPFilter string `envconfig:"APICUBE_IPFILTER" default:"0.0.0.0,1.1.1.1"`

	// GCProject: GOOGLE_PROJECT, GCLOUD_PROJECT
	GCProject string `envconfig:"GOOGLE_PROJECT" default:""`

	// SentryDSN: SENTRY_DSN
	SentryDSN string `envconfig:"SENTRY_DSN" default:""`
}

Env defines for configuration

func (*Env) IsAuth

func (e *Env) IsAuth(ipaddr string) bool

IsAuth returns

func (*Env) IsDebug

func (e *Env) IsDebug() bool

IsDebug returns

func (*Env) IsProd

func (e *Env) IsProd() bool

IsProd returns determined product environment mode

func (*Env) IsProfiler

func (e *Env) IsProfiler() bool

IsProfiler returns

func (*Env) IsSentry

func (e *Env) IsSentry() bool

IsSentry returns

func (*Env) IsUserFilter

func (e *Env) IsUserFilter() bool

IsUserFilter returns

type Environment

type Environment interface {
	// IsProd returns determined product environment mode
	IsProd() bool
	// IsSentry returns
	IsSentry() bool
	// IsDebug returns
	IsDebug() bool
	// IsProfiler returns
	IsProfiler() bool
	// IsUserFilter returns
	IsUserFilter() bool
	// IsAuth returns
	IsAuth(ipaddr string) bool
	// EnvString gets property variable
	EnvString(prop string) string // must be implement in children
	// EnvInt gets property variable
	EnvInt(prop string) int // must be implement in children
}

Environment defines public interfaces

Directories

Path Synopsis
Package logger is simply logger with sentry
Package logger is simply logger with sentry

Jump to

Keyboard shortcuts

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