hut

package module
v0.0.0-...-8ddb9f8 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2015 License: MIT Imports: 19 Imported by: 2

README

Huts are little places where a single thing gets done. Some might call them services.

Gorillas live in the huts.

I really don't recommend using this yet.

Circle CI

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogxiLog

func NewLogxiLog(name string) logxi.Logger

Types

type Env

type Env interface {
	Get(string) interface{}
	GetString(string) string
	GetUint(string) uint64
	GetInt(string) int64
	GetBool(string) bool
	GetTCPServiceAddress(string, int) string
	GetUDPServiceAddress(string, int) string
	MustGetTCPServiceAddress(string, int) string
	MustGetUDPServiceAddress(string, int) string
	InProd() bool
}

type Logger

type Logger interface {
	Trace(msg string, args ...interface{})
	Debug(msg string, args ...interface{})
	Info(msg string, args ...interface{})
	Warn(msg string, args ...interface{}) error
	Error(msg string, args ...interface{}) error
	Fatal(msg string, args ...interface{})
	Log(level int, msg string, args []interface{})

	SetLevel(int)
	IsTrace() bool
	IsDebug() bool
	IsInfo() bool
	IsWarn() bool
}

type MapEnv

type MapEnv map[string]interface{}

func NewMapEnv

func NewMapEnv() MapEnv

func (MapEnv) Get

func (e MapEnv) Get(key string) interface{}

func (MapEnv) GetBool

func (e MapEnv) GetBool(key string) bool

func (MapEnv) GetInt

func (e MapEnv) GetInt(key string) int64

func (MapEnv) GetString

func (e MapEnv) GetString(key string) string

func (MapEnv) GetTCPServiceAddress

func (e MapEnv) GetTCPServiceAddress(name string, port int) string

func (MapEnv) GetUDPServiceAddress

func (e MapEnv) GetUDPServiceAddress(name string, port int) string

func (MapEnv) GetUint

func (e MapEnv) GetUint(key string) uint64

func (MapEnv) InProd

func (e MapEnv) InProd() bool

func (MapEnv) MustGetTCPServiceAddress

func (e MapEnv) MustGetTCPServiceAddress(name string, port int) string

func (MapEnv) MustGetUDPServiceAddress

func (e MapEnv) MustGetUDPServiceAddress(name string, port int) string

type OsEnv

type OsEnv struct{}

Reads the environment from the OS environment

func NewOsEnv

func NewOsEnv() *OsEnv

func (*OsEnv) Get

func (e *OsEnv) Get(key string) interface{}

func (*OsEnv) GetBool

func (*OsEnv) GetBool(key string) bool

func (*OsEnv) GetInt

func (*OsEnv) GetInt(key string) int64

func (*OsEnv) GetString

func (*OsEnv) GetString(key string) string

func (*OsEnv) GetTCPServiceAddress

func (e *OsEnv) GetTCPServiceAddress(name string, port int) string

func (*OsEnv) GetUDPServiceAddress

func (e *OsEnv) GetUDPServiceAddress(name string, port int) string

func (*OsEnv) GetUint

func (*OsEnv) GetUint(key string) uint64

func (*OsEnv) InProd

func (e *OsEnv) InProd() bool

func (*OsEnv) MustGetTCPServiceAddress

func (e *OsEnv) MustGetTCPServiceAddress(name string, port int) string

func (*OsEnv) MustGetUDPServiceAddress

func (e *OsEnv) MustGetUDPServiceAddress(name string, port int) string

type Service

type Service struct {

	// Use this to route HTTP requests to this service.
	Router *mux.Router
	// Represents the current environment the service is running in. The
	// environment can be filled out in a number of ways, but services can
	// always find the variables here.
	Env Env
	// A log helper with different levels of logging.
	Log Logger
	// Record stats about your service here. Defaults to having a prefix
	// that is the same as the service's binary name.
	Stats Statter
	// contains filtered or unexported fields
}

func NewService

func NewService(r *mux.Router) *Service

Optionally you can pass in a router to the service in order to instantiate it somewhere down the routing chaing. By default, the service assumes it's the root.

func (*Service) Debug

func (s *Service) Debug(msg string, args ...interface{})

func (*Service) Error

func (s *Service) Error(msg string, args ...interface{}) error

func (*Service) ErrorReply

func (s *Service) ErrorReply(err error, w http.ResponseWriter)

func (*Service) Fatal

func (s *Service) Fatal(msg string, args ...interface{})

func (*Service) HttpErrorReply

func (s *Service) HttpErrorReply(w http.ResponseWriter, message string, code int)

func (*Service) Info

func (s *Service) Info(msg string, args ...interface{})

func (*Service) NewDbClient

func (s *Service) NewDbClient(driver string) (*sqlx.DB, error)

func (*Service) NewFirebaseClient

func (s *Service) NewFirebaseClient() (firebase.Client, error)

func (*Service) NewRedisClient

func (s *Service) NewRedisClient() (redis.Conn, error)

func (*Service) NewStatsd

func (s *Service) NewStatsd() (client Statter)

Returns a new Statter object. Defaults to looking at the service environment for a statsd service, linked through docker link environment variables (`STATSD_PORT_8125_TCP_ADDR` and `STATSD_PORT_8125_TCP_PORT`) If those variables aren't set, returns a noop Statter that will still work but won't log your stats anywhere.

func (*Service) NotFound

func (s *Service) NotFound(w http.ResponseWriter)

func (*Service) Reply

func (s *Service) Reply(response interface{}, w http.ResponseWriter)

func (*Service) Start

func (s *Service) Start()

Starts this service running on a port specified in the env. Note that it's not necessary to call start if this service is going to be served by a different service.

func (*Service) SuccessReply

func (s *Service) SuccessReply(metadata map[string]interface{}, w http.ResponseWriter)

func (*Service) Trace

func (s *Service) Trace(msg string, args ...interface{})

Shortcuts to make logging from a service a little less verbose

func (*Service) Warn

func (s *Service) Warn(msg string, args ...interface{}) error

type Statter

type Statter statsd.Statter

Statter an interface for collecting statistics. It mirrors statsd directly.

type StdLog

type StdLog struct {
	// contains filtered or unexported fields
}

func NewStdLog

func NewStdLog() *StdLog

func (*StdLog) Debug

func (l *StdLog) Debug(msg string, args ...interface{})

func (*StdLog) Error

func (l *StdLog) Error(msg string, args ...interface{}) error

func (*StdLog) Fatal

func (l *StdLog) Fatal(msg string, args ...interface{})

func (*StdLog) Info

func (l *StdLog) Info(msg string, args ...interface{})

func (*StdLog) Trace

func (l *StdLog) Trace(msg string, args ...interface{})

func (*StdLog) Warn

func (l *StdLog) Warn(msg string, args ...interface{}) error

Jump to

Keyboard shortcuts

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