g

package
v0.0.0-...-8b4736f Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2017 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DOMAIN     = "https://mmsystem.com"
	DOMAIN_API = "https://api.mmsystem.com"
	VERSION    = "0.0.1"
	AUTH_REALM = "mmsystem.com"

	AUTH_TOKEN_NS = "auth:" //认证token存取前缀

	CACHE_REDIS  = "redis"
	CACHE_MEMORY = "memory"

	RUN_MODE_DEV     = "dev"
	RUN_MODE_PRODUCT = "prod"

	LOG_ENGINE_FILE    = "file"
	LOG_ENGINE_MONGODB = "mongodb"

	THUMB_FOLDER_NUM = 1024
	THUMB_FORMAT     = ".png"

	LOCAL_TIME_ZONE_OFFSET = 8 * 60 * 60 //Beijing(UTC+8:00)

	DEFAULT_FILE_MODE = 0755

	USER = "user"
)
View Source
const (
	LOG_TYPE_DEFAULT = iota
	LOG_TYPE_REGISTER
	LOG_TYPE_ACTIVATION
	LOG_TYPE_LOGIN
)

todo log type

View Source
const (
	SUCCESS = 200

	//Common
	ERR_DB_FAILED           = 10001
	ERR_EMAIL_NOT_AVAILABLE = 10002
	ERR_UPLOAD_FAILED       = 10003
	ERR_DATA_INVALID        = 10004
	ERR_NO_PERMISSIONS      = 10005
	ERR_UNAUTHORIZED        = 10006
	ERR_RESOURCE_NOT_FOUND  = 10007
	ERR_RPC_FAILED          = 10008
	ERR_THUMB_FAILED        = 10009
	ERR_REDIS_NOT_AVAILABLE = 10010
	ERR_PERMISSION_DENIED   = 10011

	//Register
	ERR_REG_EMAIL_EXISTS     = 20001
	ERR_REG_EMAIL_INVALID    = 20002
	ERR_REG_PASSWORD_INVALID = 20003

	//login
	ERR_USER_NOT_EXISTS   = 20101
	ERR_PASSWORD_INVALID  = 20102
	ERR_USER_NOT_VERIFIED = 20103
	ERR_LOGIN_FAILED      = 20104
	ERR_LOGOUT_FAILED     = 20105

	//reset
	ERR_FORGET_FAILED = 20301
	ERR_RESET_INVALID = 20302
	ERR_RESET_FAILED  = 20303
)

Variables

View Source
var (
	Redis *redis.Client
	Cache *cache.Cache
)
View Source
var (
	Conf *Config

	ServiceControl string
)
View Source
var (
	DB           *mgo.Database
	MongoSession *mgo.Session
)
View Source
var (
	TempDir string
)

Functions

func EncryptPassword

func EncryptPassword(password string) string

func GetErrHttpStatus

func GetErrHttpStatus(errCode int) int

func GetErrMsg

func GetErrMsg(errCode int) string

func InitCache

func InitCache()

func InitGlobal

func InitGlobal()

func IsEmail

func IsEmail(email string) bool

func IsFileExists

func IsFileExists(filePath string) (bool, error)

目录或文件是否存在

func M

func M(collection string, f func(*mgo.Collection))

func Session

func Session() *mgo.Session

Types

type Config

type Config struct {
	//base
	Mode             string        `goconf:"base:mode"`
	Pidfile          string        `goconf:"base:pidfile"`
	MaxProc          int           `goconf:"base:maxproc"`
	HTTPBind         string        `goconf:"base:http.bind"`
	HTTPReadTimeout  time.Duration `goconf:"base:http.read.timeout:time"`
	HTTPWriteTimeout time.Duration `goconf:"base:http.write.timeout:time"`
	XSendFile        bool          `goconf:"base:http.sendfile"`
	Cache            string        `goconf:"base:cache"`
	//Storage	string	`goconf:"base.storage"`
	StoragePath      string        `goconf:"base:storage.path"`
	StorageThumbPath string        `goconf:"base:storage.thumb.path"`
	TokenDuration    time.Duration `goconf:"base:token.duration:time"`
	//db
	DBUrl     string        `goconf:"db:db.url"`
	DBName    string        `goconf:"db:db.name"`
	DBTimeout time.Duration `goconf:"db:db.timeout:time"`
	//redis
	RedisUrl      string `goconf:"redis:redis.url"`
	RedisPassword string `goconf:"redis:redis.password"`
	//rpc
	RPCProtocol        string        `goconf:"rpc:protocol"`
	RPCAddress         string        `goconf:"rpc:address"`
	RPCPoolMaxTotal    int           `goconf:"rpc:pool.maxTotal"`
	RPCPoolMaxIdle     int           `goconf:"rpc:pool.maxIdle"`
	RPCPoolMinIdle     int           `goconf:"rpc:pool.minIdle"`
	RPCPoolIdleTimeout time.Duration `goconf:"rpc:pool.idleTimeout:time"`
	//log
	LogEngine     string `goconf:"log:engine"`
	LogFilePath   string `goconf:"log:file.path"`
	LogFilePrefix string `goconf:"log:file.prefix"`
	LogMongodbUrl string `goconf:"log:mongodb.url"`
	LogMongodbDB  string `goconf:"log:mongodb.db"`
	//root user
	RootEmail    string `goconf:"root:email"`
	RootPassword string `goconf:"root:password"`
}

func ReloadConfig

func ReloadConfig() (*Config, error)

type DBLogger

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

func NewDBLogger

func NewDBLogger() *DBLogger

func (*DBLogger) Output

func (l *DBLogger) Output(calldepth int, s string) error

Jump to

Keyboard shortcuts

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