amalgam

package module
v0.0.0-...-18d19a3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2018 License: BSD-3-Clause Imports: 32 Imported by: 0

README

tango

golang library to interoperate with django

Documentation

Index

Constants

View Source
const (
	KeyDBTransaction = "dbtx"
	KeyDB            = "db"
	KeySession       = "http-session-id"
	KeyConnInfo      = "conninfo"
)
View Source
const (
	KeyWG = "wg"
)

Variables

View Source
var (
	Listen                       = ":8000"
	DbName                       = ""
	DbHost                       = "127.0.0.1"
	DbPort                       = 5432
	DbUser                       = "user"
	DbPass                       = ""
	Verbosity                    = 4
	Secret                       = ""
	Config                       = ""
	CreateConf                   = false
	Debug                        = true
	Sentry                       = ""
	UseSession                   = true
	UseTransaction               = true
	StatsD                       = ""
	App                          = "acko"
	FLAGSET        *flag.FlagSet = nil

	Confs map[string]interface{}
)
View Source
var (
	LETTERS = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
	DIGITS  = []byte("1234567890")
)
View Source
var (
	LOGGER            log15.Logger
	LOGGER_STATS_Lock sync.Mutex
	LOGGER_STATS      = &LoggerStatsType{}
)

Functions

func BoolFlag

func BoolFlag(
	varName *bool,
	name string,
	defVal bool,
	description string,
)

func Counter

func Counter(name string, value int, sampling float64) error

func Ctx2ConnInfo

func Ctx2ConnInfo(ctx context.Context) (string, error)

func Ctx2Db

func Ctx2Db(ctx context.Context) (*sqlx.DB, error)

func Ctx2SessionKey

func Ctx2SessionKey(ctx context.Context) (string, error)

func Ctx2Tx

func Ctx2Tx(ctx context.Context) (*sqlx.Tx, error)

func DecodeEID

func DecodeEID(eid string, model string) (string, error)

func EncodeID

func EncodeID(id int64, model string) string

func Exec

func Exec(
	ctx context.Context, q string, args ...interface{},
) error

func Gauge

func Gauge(name string, value int) error

func GetContext

func GetContext() (context.Context, error)

func GetIPFromRequest

func GetIPFromRequest(r *http.Request) (string, error)

func GetRandomString

func GetRandomString(size int) string

func GetTrackerFromRequest

func GetTrackerFromRequest(r *http.Request) string

func Init

func Init()

func IntFlag

func IntFlag(
	varName *int,
	name string,
	defVal int,
	description string,
)

func LoggerStatter

func LoggerStatter(r *log15.Record) error

func LvlFilterHandler

func LvlFilterHandler(exactLvl log15.Lvl, h log15.Handler) log15.Handler

func NotifyR2D2

func NotifyR2D2(oid, app, okind, ekind string, edata, odata interface{}) error

func NullString

func NullString(val *string) sql.NullString

func QueryIntoInt

func QueryIntoInt(
	ctx context.Context, q string, args ...interface{},
) (int, error)

func QueryIntoMap

func QueryIntoMap(
	ctx context.Context, q string, args ...interface{},
) (map[string]interface{}, error)

QueryIntoMap will return a map[string]interface{} representation of exactly one row only. This is because you cannot have a single map object which contains data for multiple rows

func QueryIntoSlice

func QueryIntoSlice(
	ctx context.Context, v interface{}, q string, args ...interface{},
) error

func QueryIntoString

func QueryIntoString(
	ctx context.Context, q string, args ...interface{},
) (string, error)

func QueryIntoStruct

func QueryIntoStruct(
	ctx context.Context, v interface{}, q string, args ...interface{},
) error

func SetLoggingVerbosity

func SetLoggingVerbosity(level int)

Logging verbosity level, from 0 (nothing) upwards.

func StringFlag

func StringFlag(
	varName *string,
	name string,
	defVal string,
	description string,
)

func Timer

func Timer(name string, tt time.Duration) error

Types

type AError

type AError struct {
	Human   string      `json:"human"`
	Code    string      `json:"code"`
	Context interface{} `json:"context"`
}

type LoggerStatsType

type LoggerStatsType struct {
	Warns  int `json:"warns"`
	Errors int `json:"errors"`
	Crits  int `json:"crits"`
}

type NullPgJson

type NullPgJson struct {
	PgJson PgJson
	Valid  bool
}

func (*NullPgJson) Scan

func (p *NullPgJson) Scan(src interface{}) error

func (NullPgJson) Value

func (p NullPgJson) Value() (driver.Value, error)

type PgJson

type PgJson map[string]interface{}

Custom data type for easy mapping of jsonB DB column to a GO struct member.

func (*PgJson) Scan

func (p *PgJson) Scan(src interface{}) error

Scan is the only method of the Scanner interface under the sql package. Scan assigns a value from the DB driver to the object that calls it

func (PgJson) Value

func (p PgJson) Value() (driver.Value, error)

This is the only method of the interface Valuer under the sql/driver package. Types implementing this interface can convert themselves to a driver acceptable value.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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