Documentation
¶
Index ¶
- func NewLogxiLog(name string) logxi.Logger
- type Env
- type Logger
- type MapEnv
- func (e MapEnv) Get(key string) interface{}
- func (e MapEnv) GetBool(key string) bool
- func (e MapEnv) GetInt(key string) int64
- func (e MapEnv) GetString(key string) string
- func (e MapEnv) GetTCPServiceAddress(name string, port int) string
- func (e MapEnv) GetUDPServiceAddress(name string, port int) string
- func (e MapEnv) GetUint(key string) uint64
- func (e MapEnv) InProd() bool
- func (e MapEnv) MustGetTCPServiceAddress(name string, port int) string
- func (e MapEnv) MustGetUDPServiceAddress(name string, port int) string
- type OsEnv
- func (e *OsEnv) Get(key string) interface{}
- func (*OsEnv) GetBool(key string) bool
- func (*OsEnv) GetInt(key string) int64
- func (*OsEnv) GetString(key string) string
- func (e *OsEnv) GetTCPServiceAddress(name string, port int) string
- func (e *OsEnv) GetUDPServiceAddress(name string, port int) string
- func (*OsEnv) GetUint(key string) uint64
- func (e *OsEnv) InProd() bool
- func (e *OsEnv) MustGetTCPServiceAddress(name string, port int) string
- func (e *OsEnv) MustGetUDPServiceAddress(name string, port int) string
- type Service
- func (s *Service) Debug(msg string, args ...interface{})
- func (s *Service) Error(msg string, args ...interface{}) error
- func (s *Service) ErrorReply(err error, w http.ResponseWriter)
- func (s *Service) Fatal(msg string, args ...interface{})
- func (s *Service) HttpErrorReply(w http.ResponseWriter, message string, code int)
- func (s *Service) Info(msg string, args ...interface{})
- func (s *Service) NewDbClient(driver string) (*sqlx.DB, error)
- func (s *Service) NewFirebaseClient() (firebase.Client, error)
- func (s *Service) NewRedisClient() (redis.Conn, error)
- func (s *Service) NewStatsd() (client Statter)
- func (s *Service) NotFound(w http.ResponseWriter)
- func (s *Service) Reply(response interface{}, w http.ResponseWriter)
- func (s *Service) Start()
- func (s *Service) SuccessReply(metadata map[string]interface{}, w http.ResponseWriter)
- func (s *Service) Trace(msg string, args ...interface{})
- func (s *Service) Warn(msg string, args ...interface{}) error
- type Statter
- type StdLog
- func (l *StdLog) Debug(msg string, args ...interface{})
- func (l *StdLog) Error(msg string, args ...interface{}) error
- func (l *StdLog) Fatal(msg string, args ...interface{})
- func (l *StdLog) Info(msg string, args ...interface{})
- func (l *StdLog) Trace(msg string, args ...interface{})
- func (l *StdLog) Warn(msg string, args ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLogxiLog ¶
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 (MapEnv) GetTCPServiceAddress ¶
func (MapEnv) GetUDPServiceAddress ¶
func (MapEnv) MustGetTCPServiceAddress ¶
type OsEnv ¶
type OsEnv struct{}
Reads the environment from the OS environment
func (*OsEnv) GetTCPServiceAddress ¶
func (*OsEnv) GetUDPServiceAddress ¶
func (*OsEnv) MustGetTCPServiceAddress ¶
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 ¶
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) ErrorReply ¶
func (s *Service) ErrorReply(err error, w http.ResponseWriter)
func (*Service) HttpErrorReply ¶
func (s *Service) HttpErrorReply(w http.ResponseWriter, message string, code int)
func (*Service) NewStatsd ¶
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)
