ogo

package module
v0.0.0-...-861d2e8 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2016 License: BSD-2-Clause Imports: 37 Imported by: 9

README

ogo

Odin's go daemon/HTTP framework

Original Features

  • Daemonize, 可在.conf中用 Daemonize={bool}配置, pidfile默认写到程序目录的run/.pid
  • DebugLevel配置,.conf中 DebugLevel={int}配置,数字越高级别越高
  • Support HTTP! 默认支持http, 编译时候如果开启-a --tags 'daemon', 则是daemon模式

Daemon

  • main.go如下:
package main

import (
    "github.com/Odinman/ogo"
    _ "<gopath_to_workers>/workers"
)

func main() {
    ogo.Run()
}
  • workers目录下,文件名自定,以'test'为例,代码如下:
package workers

import (
    "github.com/Odinman/ogo"
)

type TestWorker struct {
    ogo.Worker
}

func init() {
    ogo.AddWorker(&TestWorker{})
}

func (w *TestWorker) Main() error {
    return nil
}

主要看worker的名字, 框架会自动调用Main()

HTTP

  • main.go
package main

import (
	"github.com/Odinman/ogo"

	_ "./hooks"
	_ "./routers"
)

func main() {
	ogo.Run()
}
  • routers, 该目录下, 文件名可以自定, 范例如下:
package routers

import (
	"github.com/Odinman/ogo"

	"../models"
)

type TestRouter struct {
	ogo.Router
}

func init() {
	r := ogo.NewRouter(new(TestRouter), "test").(*TestRouter)
	//先自定义路由, 因为优先级高, 自定义路由后定义的会覆盖先定义的
	//r.AddRoute("GET", "/test", r.Root, ogo.RouteOption{ogo.KEY_SKIPLOGIN: true, ogo.KEY_SKIPAUTH: true})
	// 初始化并载入默认路由, 默认路由不会覆盖自定义路由
	r.GenericRoute(new(models.Test), ogo.GA_ALL)
	r.Init(r)
}

func (this *TestRouter) Root(c *ogo.RESTContext) {
    // do something
}

Documentation

Overview

Package ogo provides ...

Package ogo provides ...

解析http请求的各种条件

Index

Constants

View Source
const (
	DBTAG    string = "db"
	READTAG  string = "read"
	WRITETAG string = "write"
)
View Source
const (
	OriginalRemoteAddrKey = "originalRemoteAddr"

	// 查询类型
	CTYPE_IS = iota
	CTYPE_NOT
	CTYPE_OR
	CTYPE_LIKE
	CTYPE_GT
	CTYPE_LT
	CTYPE_JOIN
	CTYPE_RANGE
	CTYPE_ORDER
	CTYPE_PAGE
	CTYPE_RAW
)

Key to use when setting the request ID.

View Source
const (
	// db tag
	DBTAG_PK    = "pk"
	DBTAG_LOGIC = "logic"

	//tag
	TAG_REQUIRED    = "R"     // 必填
	TAG_GENERATE    = "G"     // 服务端生成, 同时不可编辑
	TAG_CONDITION   = "C"     // 可作为查询条件
	TAG_DENY        = "D"     // 不可编辑, 可为空
	TAG_SECRET      = "S"     // 保密,一般不见人
	TAG_HIDDEN      = "H"     // 隐藏
	TAG_DEFAULT     = "DEF"   // 默认
	TAG_TIMERANGE   = "TR"    // 时间范围条件
	TAG_REPORT      = "RPT"   // 报表字段
	TAG_CANGROUP    = "GRP"   // 可以group操作
	TAG_ORDERBY     = "O"     // 可排序(默认DESC)
	TAG_AORDERBY    = "AO"    // 正排序(默认DESC)
	TAG_VERIFIABLE  = "V"     // 验证后可修改
	TAG_RETURN      = "RET"   // 返回,创建后需要返回数值
	TAG_SUM         = "SUM"   // 求和
	TAG_TSUM        = "TS"    // 总求和(放到聚合中,只能有一个)
	TAG_COUNT       = "COUNT" // 计数
	TAG_AGGREGATION = "AGG"   // 聚合

	// ext field
	EXF_SUM   = "sum"
	EXF_COUNT = "count"
)
View Source
const (
	// ogo daemon/http framework version.
	VERSION      = "1.0"
	DEFAULT_PORT = "8001"

	// generic action const
	GA_GET = 1 << iota
	GA_SEARCH
	GA_POST
	GA_DELETE
	GA_PATCH
	//GA_PUT
	GA_HEAD
	GA_ALL = GA_GET | GA_SEARCH | GA_POST | GA_DELETE | GA_PATCH | GA_HEAD

	KEY_SKIPAUTH  = "skipauth"
	KEY_SKIPLOGIN = "skiplogin"
	KEY_SKIPPERM  = "skipperm"
	KEY_TPL       = "tpl"

	//env key
	RequestIDKey      = "_reqid_"
	SaveBodyKey       = "_sb_"
	NoLogKey          = "_nl_"
	PaginationKey     = "_pagination_"
	FieldsKey         = "_fields_"
	TimeRangeKey      = "_tr_"
	OrderByKey        = "_ob_"
	ConditionsKey     = "_conditions_"
	LogPrefixKey      = "_prefix_"
	EndpointKey       = "_endpoint_"
	RowkeyKey         = "_rk_"
	SelectorKey       = "_selector_"
	MimeTypeKey       = "_mimetype_"
	DispositionMTKey  = "_dmt_"
	ContentMD5Key     = "_md5_"
	DispositionPrefix = "_dp_"
	DIMENSION_KEY     = "_dimension_" //在restcontext中的key
	SIDE_KEY          = "_sidekey_"
	USERID_KEY        = "_userid_"
	APPID_KEY         = "_appid_"
	STAG_KEY          = "_stag_"
	PERMISSION_KEY    = "_perm_"
	EXT_KEY           = "_ext_"

	// 内容类型
	ContentTypeJSON = 1 << iota
	ContentTypeHTML
	ContentTypeXML
)

{{{ const

View Source
const (
	TD_TOTAL_FIELD = "_total_"
)

Variables

View Source
var (
	ErrRequired      = errors.New("field is required")
	ErrNonEditable   = errors.New("field is non-editable")
	ErrNonSearchable = errors.New("field is non-searchable")
	ErrExists        = errors.New("field value exists")
	ErrInvalid       = errors.New("invalid_query")
	ErrNoRecord      = errors.New("No_record")
	ErrNeedField     = errors.New("Need field but missing")
)

错误代码

View Source
var (
	DataAccessor = make(map[string]string) // tablename::{read/write} => tag
)
View Source
var (
	EmptyGifBytes, _ = base64.StdEncoding.DecodeString(base64GifPixel)
)

Functions

func Accessor

func Accessor() *logs.OLogger

{{{ func Accessor() *logs.OLogger *

func AddTagHook

func AddTagHook(tag string, hook TagHook)

{{{ func AddTagHook(tag string, hook TagHook) * tag hook

func AddWorker

func AddWorker(w WorkerInterface)

worker registor

func CacheGet

func CacheGet(key string) (string, error)

{{{ func CacheGet(key) (string,error) *

func CacheIncrByFloat

func CacheIncrByFloat(key string, value float64) error

{{{ func CacheIncrByFloat(key string, value float64) error *

func CacheSet

func CacheSet(key, value string, expire int) error

{{{ func CacheSet(key, value string, expire int) error *

func ClusterClient

func ClusterClient() *redis.ClusterClient

{{{ func ClusterClient() *redis.ClusterClient *

func Config

func Config() config.ConfigContainer

{{{ func Config() config.ConfigContainer * 默认的配置就是DMux的配置

func Critical

func Critical(format string, v ...interface{})

func Debug

func Debug(format string, v ...interface{})

func Defer

func Defer(c *web.C, h http.Handler) http.Handler

{{{ func Defer(c *web.C, h http.Handler) http.Handler * recovers from panics

func EnvInit

func EnvInit(c *web.C, h http.Handler) http.Handler

{{{ func EnvInit(c *web.C, h http.Handler) http.Handler * 初始化环境

func Error

func Error(format string, v ...interface{})

func GetDbFields

func GetDbFields(i interface{}, ops ...interface{}) (s []string)

{{{ GetDbFields(i interface{}, ops ...interface{}) (s string) * 从struct中解析数据库字段以及字段选项

func GetLock

func GetLock(key string) (string, error)

{{{ func GetLock(key string) (string, error) * 获取锁

func GetSumFields

func GetSumFields(i interface{}, g []string) (s string)

{{{ func GetSumFields(i interface{}, g []string) (s string) * 从struct中解析数据库字段以及字段选项,为了报表

func Info

func Info(format string, v ...interface{})

func Log

func Log(level, format string, v ...interface{})

func Logger

func Logger() *logs.OLogger

{{{ func Logger() *logs.OLogger *

func OmqBlockTask

func OmqBlockTask(msg ...string) (string, error)

{{{ func OmqBlockTask(msg ...string) (string, error) *

func OmqDel

func OmqDel(key string) (string, error)

{{{ func OmqDel(key string) (string, error) *

func OmqGet

func OmqGet(key string) (string, error)

{{{ func OmqGet(key string) (string, error) *

func OmqPool

func OmqPool() *omq.Pool

{{{ func OmqPool() *omq.Pool *

func OmqPop

func OmqPop(msg ...string) ([]string, error)

{{{ func OmqPop(msg ...string) error *

func OmqSet

func OmqSet(key, value string, expire int) error

{{{ func OmqSet(key, value string, expire int) error *

func OmqTask

func OmqTask(msg ...string) error

{{{ func OmqTask(msg ...string) error *

func OpenDB

func OpenDB(tag, dns string) (err error)

{{{ func OpenDB(tag,dns string) error *

func ParseHeaders

func ParseHeaders(c *web.C, h http.Handler) http.Handler

{{{ func ParseHeaders(c *web.C, h http.Handler) http.Handler * headers相关处理

func ParseParams

func ParseParams(c *web.C, h http.Handler) http.Handler

{{{ func ParseParams(c *web.C, h http.Handler) http.Handler { *

func PostHook

func PostHook(hook OgoHook)

{{{ func PostHook(hook OgoHook) * 正式程序之前的钩子

func PreHook

func PreHook(hook OgoHook)

{{{ func PreHook(hook OgoHook) * 正式程序之前的钩子

func ReleaseLock

func ReleaseLock(key string) error

{{{ func ReleaseLock(key string) error * 释放锁

func Run

func Run()

{{{ func Run() * 默认Run()

func SetOnlineKey

func SetOnlineKey(id, key string, p interface{}) bool

{{{ func SetOnlineKey(id string, ol *Online,p interface{}) bool *

func Trace

func Trace(format string, v ...interface{})

func Warn

func Warn(format string, v ...interface{})

func WriteMsg

func WriteMsg(v ...interface{})

立即输出

Types

type Access

type Access struct {
	Time     time.Time   `json:"t"`
	Service  string      `json:"sn,omitempty"`
	Session  string      `json:"s"`
	Duration string      `json:"d"`
	Http     *HTTPLog    `json:"http,omitempty"`
	App      interface{} `json:"app,omitempty"`   //rest app日志
	Debug    interface{} `json:"debug,omitempty"` //app debug日志
}

func NewAccess

func NewAccess(opts ...interface{}) *Access

{{{ func NewAccess(opts ...interface{}) *Access *

func (*Access) GetApp

func (ac *Access) GetApp() interface{}

{{{ func (ac *Access) GetApp() interface{} * 放置app日志

func (*Access) Save

func (ac *Access) Save()

{{{ func (ac *Access) Save() * 记录access日志

func (*Access) SaveApp

func (ac *Access) SaveApp(al interface{})

{{{ func (ac *Access) SaveApp(al interface{}) * 放置app日志

func (*Access) SaveDebug

func (ac *Access) SaveDebug(i interface{})

{{{ func (ac *Access) SaveDebug(i interface{}) * 放置app日志

type ActionInterface

type ActionInterface interface {
	PreGet(i interface{}) (interface{}, error)  //获取前
	OnGet(i interface{}) (interface{}, error)   //获取中
	PostGet(i interface{}) (interface{}, error) //获取后

	PreSearch(i interface{}) (interface{}, error)  // 搜索前的检查
	OnSearch(i interface{}) (interface{}, error)   // 搜索前的检查
	PostSearch(i interface{}) (interface{}, error) // 搜索后的检查

	PreCreate(i interface{}) (interface{}, error)  // 插入前的检查
	OnCreate(i interface{}) (interface{}, error)   // 插入前的检查
	PostCreate(i interface{}) (interface{}, error) // 插入后的处理

	PreUpdate(i interface{}) (interface{}, error)  // 更新前的检查
	OnUpdate(i interface{}) (interface{}, error)   // 更新前的检查
	PostUpdate(i interface{}) (interface{}, error) // 更新后的操作

	PreDelete(i interface{}) (interface{}, error)  // 删除前的检查
	OnDelete(i interface{}) (interface{}, error)   // 删除前的检查
	PostDelete(i interface{}) (interface{}, error) // 删除后的检查

	PreCheck(i interface{}) (interface{}, error)  // 搜索前的检查
	OnCheck(i interface{}) (interface{}, error)   // 搜索前的检查
	PostCheck(i interface{}) (interface{}, error) // 搜索后的检查

	Trigger(i interface{}) (interface{}, error) //触发器
	Defer(i interface{})                        //触发器
}

type Aggregation

type Aggregation struct {
	Key    string  `json:"key,omitempty"`
	Value  string  `json:"value,omitempty"`
	Count  int     `json:"count"`
	Amount float64 `json:"amount"`
}

func UpdateAggregation

func UpdateAggregation(as []Aggregation, a Aggregation) []Aggregation

{{{ func UpdateAggregation(as []Aggregation, a Aggregation) []Aggregation *

type Aggregations

type Aggregations map[string][]Aggregation

func BuildAggregationsFromList

func BuildAggregationsFromList(l *List, groups ...[]string) (as Aggregations)

{{{ func BuildAggregationsFromList(l *List, groups ...[]string) Aggregations * 从list生成Aggregations, 传入groups

type AppLog

type AppLog struct {
	Ctag   string      `json:"ctag"`
	Query  interface{} `json:"query,omitempty"`
	New    interface{} `json:"new,omitempty"`
	Old    interface{} `json:"old,omitempty"`
	Result interface{} `json:"result,omitempty"`
}

type BaseConverter

type BaseConverter struct{}

func (BaseConverter) FromDb

func (_ BaseConverter) FromDb(target interface{}) (gorp.CustomScanner, bool)

{{{ func (_ BaseConverter) FromDb(target interface{}) (gorp.CustomScanner, bool) * 类型转换, 主要处理标准类型; 自定义类型通过SelfConverter实现

func (BaseConverter) ToDb

func (_ BaseConverter) ToDb(val interface{}) (interface{}, error)

{{{ func (_ BaseConverter) ToDb(val interface{}) (interface{}, error) *

type BaseModel

type BaseModel struct {
	Count int64                  `json:"count,omitempty" filter:",H,G,D"` // 计数
	Sum   float64                `json:"sum,omitempty" filter:",H,G,D"`   // 求和
	Ext   map[string]interface{} `json:"ext,omitempty" filter:",H,G,D"`   // 扩展
	Error error                  `json:"-" db:"-"`
	Model Model                  `json:"-" db:"-"`
	// contains filtered or unexported fields
}

基础model,在这里可以实现Model接口, 其余的只需要嵌入这个struct,就可以继承这些方法

func (*BaseModel) AddTable

func (bm *BaseModel) AddTable(tags ...string)

{{{ func (bm *BaseModel) AddTable(tags ...string) * 注册表结构

func (*BaseModel) CheckerFactory

func (bm *BaseModel) CheckerFactory() Checker

{{{ func (bm *BaseModel) CheckerFactory() Checker *

func (*BaseModel) CreateRow

func (bm *BaseModel) CreateRow() (Model, error)

{{{ func (bm *BaseModel) CreateRow() (Model, error) * 根据条件获取一条记录, model为表结构

func (*BaseModel) DBConn

func (bm *BaseModel) DBConn(tag string) *gorp.DbMap

{{{ func (bm *BaseModel) DBConn(tag string) *gorp.DbMap * 默认数据库连接为admin

func (*BaseModel) DeleteRow

func (bm *BaseModel) DeleteRow(id string) (affected int64, err error)

{{{ func (bm *BaseModel) DeleteRow(id string) (affected int64, err error) * 删除记录(逻辑删除)

func (*BaseModel) Fill

func (bm *BaseModel) Fill(j []byte) error

{{{ func (bm *BaseModel) Fill(j []byte) error * 根据条件获取一条记录, model为表结构

func (*BaseModel) Filter

func (bm *BaseModel) Filter() (Model, error)

{{{ func (bm *BaseModel) Filter() (Model, error) * 数据过滤

func (*BaseModel) GetChecker

func (bm *BaseModel) GetChecker() Checker

{{{ func (bm *BaseModel) GetChecker() Checker *

func (*BaseModel) GetConditions

func (bm *BaseModel) GetConditions() []*Condition

{{{ func (bm *BaseModel) GetConditions() []*Condition *

func (*BaseModel) GetCount

func (bm *BaseModel) GetCount() (cnt int64, err error)

{{{ func (bm *BaseModel) GetCount() (cnt int64, err error) * 获取list, 通用函数

func (*BaseModel) GetCountNSum

func (bm *BaseModel) GetCountNSum() (cnt int64, sum float64)

{{{ func (bm *BaseModel) GetCountNSum() (cnt int64, sum float64) * 获取计数以及求和, 通用函数

func (*BaseModel) GetCtx

func (bm *BaseModel) GetCtx() *RESTContext

{{{ func (bm *BaseModel) GetCtx() *RESTContext *

func (*BaseModel) GetFields

func (bm *BaseModel) GetFields() []string

{{{ func (bm *BaseModel) GetFields() []string *

func (*BaseModel) GetModel

func (bm *BaseModel) GetModel() Model

{{{ func (bm *BaseModel) GetModel() Model *

func (*BaseModel) GetOlder

func (bm *BaseModel) GetOlder() Model

{{{ func (bm *BaseModel) GetOlder() Model * 获取旧记录

func (*BaseModel) GetPagination

func (bm *BaseModel) GetPagination() *Pagination

{{{ func (bm *BaseModel) GetPagination() *Pagination *

func (*BaseModel) GetRow

func (bm *BaseModel) GetRow(ext ...interface{}) (Model, error)

{{{ func (bm *BaseModel) GetRow(ext ...interface{}) (Model, error) * 根据条件获取一条记录, model为表结构

func (*BaseModel) GetRows

func (bm *BaseModel) GetRows() (l *List, err error)

{{{ func (bm *BaseModel) GetRows() (l *List, err error) * 获取list, 通用函数

func (*BaseModel) GetSum

func (bm *BaseModel) GetSum(d []string) (l *List, err error)

{{{ func (bm *BaseModel) GetSum(d []string) (l *List, err error) * 获取list, 通用函数

func (*BaseModel) New

func (bm *BaseModel) New(c ...interface{}) Model

{{{ func (bm *BaseModel) New(c ...interface{}) Model * 初始化model, 后面的c选填

func (*BaseModel) NewList

func (bm *BaseModel) NewList() interface{}

{{{ func (bm *BaseModel) NewList() *[]Model *

func (*BaseModel) PKey

func (bm *BaseModel) PKey() (f string, v string, ai bool)

{{{ func (bm *BaseModel) PKey() (string, string, bool) * 通过配置找到pk

func (*BaseModel) Protect

func (bm *BaseModel) Protect() (Model, error)

{{{ func (bm *BaseModel) Protect() (Model, error) * 数据过滤

func (*BaseModel) ReadPrepare

func (bm *BaseModel) ReadPrepare() (b *gorp.Builder, err error)

{{{ func (bm *BaseModel) ReadPrepare() (b *gorp.Builder, err error) * 查询准备

func (*BaseModel) SetConditions

func (bm *BaseModel) SetConditions(cs ...*Condition) (cons []*Condition, err error)

{{{ func (bm *BaseModel) SetConditions(cs ...*Condition) (cons []*Condition, err error) * 生成条件

func (*BaseModel) SetCtx

func (bm *BaseModel) SetCtx(c *RESTContext)

{{{ func (bm *BaseModel) SetCtx(c *RESTContext) *

func (*BaseModel) SetFields

func (bm *BaseModel) SetFields(fs []string)

{{{ func (bm *BaseModel) SetFields(fs []string) * 生成条件

func (*BaseModel) SetModel

func (bm *BaseModel) SetModel(m Model) Model

{{{ func (bm *BaseModel) SetModel(m Model) Model *

func (*BaseModel) SetPagination

func (bm *BaseModel) SetPagination(p *Pagination)

{{{ func (bm *BaseModel) SetPagination(p *Pagination) * 生成条件

func (*BaseModel) TableName

func (bm *BaseModel) TableName() (n string)

{{{ func (bm *BaseModel) TableName() (n string) * 获取表名称, 默认为结构名

func (*BaseModel) UpdateRow

func (bm *BaseModel) UpdateRow(ext ...interface{}) (affected int64, err error)

{{{ func (bm *BaseModel) UpdateRow(ext ...interface{}) (affected int64, err error) * 更新record

func (*BaseModel) Valid

func (bm *BaseModel) Valid() (Model, error)

{{{ func (bm *BaseModel) Valid() (Model, error) * 根据条件获取一条记录, model为表结构

type Checker

type Checker func(string) (interface{}, error)

type Condition

type Condition struct {
	Table string
	Field string
	Is    interface{}
	Not   interface{}
	Or    interface{}
	Gt    interface{}
	Lt    interface{}
	Like  interface{}
	Join  interface{}
	Range interface{} //范围条件, btween ? and ?
	Order interface{}
	Page  interface{}
	Raw   string //原始字符串
}

func GetCondition

func GetCondition(cs []*Condition, k string) (con *Condition, err error)

{{{ func GetCondition(cs []*Condition, k string) (con *Condition, err error) *

func NewCondition

func NewCondition(typ int, field string, cs ...interface{}) *Condition

func ParseCondition

func ParseCondition(typ string, con *Condition) *Condition

{{{ func ParseCondition(typ string, con *Condition) *Condition *

func (*Condition) DoWhere

func (v *Condition) DoWhere(b *gorp.Builder)

{{{ func (v *Condition) DoWhere(b *gorp.Builder) * 只负责生成部分sql, IS/NOT/LIKE/GT/LT

func (*Condition) Merge

func (con *Condition) Merge(oc *Condition)

{{{ func (con *Condition) Merge(oc *Condition) * 直接覆盖

type Environ

type Environ struct {
	WorkPath      string         // working path(abs)
	AppPath       string         // application path
	ProcName      string         // proc name
	Worker        string         // worker name
	AppConfigPath string         // config file path
	RunMode       string         // run mode, "dev" or "prod"
	AccessPath    string         // acces log file path
	TplDir        string         // tpl dir
	Daemonize     bool           // daemonize or not
	EnableGzip    bool           // enable gzip or not
	DebugLevel    int            // debug level
	PidFile       string         // pidfile abs path
	Port          string         // http port
	IndentJSON    bool           // indent JSON
	MaxMemory     int64          //max memory(form-data)
	Location      *time.Location // location
	// contains filtered or unexported fields
}

{{{ type Environ struct

func Env

func Env() *Environ

{{{ func Env() *Environ * 默认的配置就是DMux的配置

type HStack

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

type HTTPLog

type HTTPLog struct {
	Status    int          `json:"sc"`
	IP        string       `json:"ip"`
	Method    string       `json:"m"`
	URI       string       `json:"uri"`
	Proto     string       `json:"p"`
	ReqBody   string       `json:"qb,omitempty"`
	ReqLength int          `json:"ql"` //请求body大小
	RepLength int          `json:"pl"` //返回body大小
	Host      string       `json:"h"`
	InHeader  *http.Header `json:"ih,omitempty"`
	OutHeader http.Header  `json:"oh,omitempty"`
}

type Handler

type Handler func(c *RESTContext)

type List

type List struct {
	Info  ListInfo               `json:"info,omitempty"`
	Total int64                  `json:"total"`
	List  interface{}            `json:"list"`
	Ext   map[string]interface{} `json:"ext,omitempty"`
}

type ListInfo

type ListInfo struct {
	Page    *int        `json:"page,omitempty"`     //当前页面
	PerPage *int        `json:"per_page,omitempty"` //每页元素个数
	Sum     interface{} `json:"sum,omitempty"`      //求和
}

type Lock

type Lock struct {
	Key string
	// contains filtered or unexported fields
}

func NewLock

func NewLock(key string) (lk *Lock)

{{{ func NewLock(key string) (lk *Lock) *

func (*Lock) Get

func (lk *Lock) Get() (err error)

{{{ func (lk *Lock) Get() error * 获取锁

func (*Lock) Release

func (lk *Lock) Release() (err error)

{{{ func (lk *Lock) Release() error * 释放锁

type Model

type Model interface {
	SetModel(m Model) Model
	GetModel() Model
	SetCtx(c *RESTContext)
	GetCtx() *RESTContext
	SetConditions(cs ...*Condition) ([]*Condition, error)
	GetConditions() []*Condition
	SetPagination(p *Pagination)
	GetPagination() *Pagination
	SetFields(fs []string)
	GetFields() []string
	GetChecker() Checker

	New(c ...interface{}) Model
	NewList() interface{} // 返回一个空结构列表

	// db
	AddTable(tags ...string)
	DBConn(tag string) *gorp.DbMap // 数据库连接
	TableName() string             // 返回表名称, 默认结构type名字(小写), 有特别的表名称,则自己implement 这个方法
	PKey() (string, string, bool)  // key字段,以及是否auto incr
	ReadPrepare() (*gorp.Builder, error)

	// data accessor
	GetRow(ext ...interface{}) (Model, error)    //获取单条记录
	GetRows() (*List, error)                     //获取多条记录
	GetOlder() Model                             //获取旧记录
	GetSum(d []string) (*List, error)            //获取多条记录
	GetCount() (int64, error)                    //获取多条记录
	GetCountNSum() (int64, float64)              //获取count and sum
	CreateRow() (Model, error)                   //创建单条记录
	UpdateRow(ext ...interface{}) (int64, error) //更新记录
	DeleteRow(id string) (int64, error)          //更新记录
	CheckerFactory() Checker                     //检查存在性
	Fill([]byte) error                           //填充内容
	Valid() (Model, error)                       //数据验证
	Filter() (Model, error)                      //数据过滤(创建,更新后)
	Protect() (Model, error)                     //数据保护(获取数据时过滤字段)
}

func BuildModel

func BuildModel(m Model, c ...interface{}) Model

{{{ func BuildModel(m Model,c ...interface{}) Model { * 第一个参数,model,必须是指针; 第二个参数, *RESTContext

func NewModel

func NewModel(m Model, c ...interface{}) Model

{{{ func NewModel(m Model,c ...interface{}) Model { * 第一个参数,model,必须是指针; 第二个参数, *RESTContext

type Mux

type Mux struct {
	Workers map[string]*Worker
	Routes  map[string]*Route
	Hooks   HStack
	//TagHooks map[string]TagHook
	TagHooks *utils.SafeMap
	// contains filtered or unexported fields
}

{{{ type Mux struct

var (
	DMux *Mux
)

{{{ variables

func New

func New() *Mux

{{{ func New() *Mux

func (*Mux) Accessor

func (mux *Mux) Accessor() (*logs.OLogger, error)

{{{ func (mux *Mux) Accessor() config.LoggerContainer *

func (*Mux) AddTagHook

func (mux *Mux) AddTagHook(tag string, hook TagHook)

{{{ func (mux *Mux) AddTagHook(tag string, hook TagHook) * struct 中定义tag来调用钩子

func (*Mux) ClusterClient

func (mux *Mux) ClusterClient() (*redis.ClusterClient, error)

{{{ func (mux *Mux) ClusterClient() (*redis.ClusterClient, error) *

func (*Mux) Config

func (mux *Mux) Config() (config.ConfigContainer, error)

{{{ func (mux *Mux) Config() (config.ConfigContainer, error) * 获取配置信息

func (*Mux) Env

func (mux *Mux) Env() (*Environ, error)

{{{ func (mux *Mux) Env(path string) *Environ, error * 获取env变量

func (*Mux) Logger

func (mux *Mux) Logger() (*logs.OLogger, error)

{{{ func (mux *Mux) Logger() config.LoggerContainer *

func (*Mux) NewRouter

func (mux *Mux) NewRouter(c interface{}, endpoint string) RouterInterface

{{{ func (mux *Mux) NewRouter(c interface{}, endpoint string) RouterInterface * 这样做的目的是给rounter设置mux(mux可多个) -- mux=multiplexer,复用器

func (*Mux) OmqPool

func (mux *Mux) OmqPool() (*omq.Pool, error)

{{{ func (mux *Mux) OmqPool() (*omq.Pool, error) *

func (*Mux) PostHook

func (mux *Mux) PostHook(hook OgoHook)

{{{ func (mux *Mux) PostHook(hook OgoHook) * 正式程序之后的钩子

func (*Mux) PreHook

func (mux *Mux) PreHook(hook OgoHook)

{{{ func (mux *Mux) PreHook(hook OgoHook) * 正式程序之前的钩子

func (*Mux) Run

func (mux *Mux) Run()

{{{ func (mux *Mux) Run() * Run ogo application.

type OTPSpec

type OTPSpec struct {
	Value string
	Type  string
	Sn    string
}

type OgoHook

type OgoHook func(c *RESTContext) error

type Online

type Online struct {
	Key  string
	Ex   time.Time
	Item interface{}
}

func GetOnlineKey

func GetOnlineKey(id string) (ol *Online, err error)

{{{ func GetOnlineKey(id string) (*Online,error) * 获取在线的key

type OnlineMap

type OnlineMap struct {
	// contains filtered or unexported fields
}
var (
	OnlineCache *OnlineMap
)

func (*OnlineMap) Delete

func (m *OnlineMap) Delete(k string)

Delete the given key and value.

func (*OnlineMap) Get

func (m *OnlineMap) Get(k string) (ol *Online)

Get from maps return the k's value

func (*OnlineMap) Set

func (m *OnlineMap) Set(k string, v *Online) bool

Maps the given key and value. Returns false if the key is already in the map and changes nothing.

type OrderBy

type OrderBy struct {
	Field string
	Sort  string
}

order by

type Pagination

type Pagination struct {
	Page    int
	PerPage int
	Offset  int
}

分页信息

func NewPagination

func NewPagination(page, perPage string) (p *Pagination)

条件信息

{{{ func NewPagation(page, perPage string) (p *Pagination)

type RESTContext

type RESTContext struct {
	web.C
	Response      http.ResponseWriter
	Request       *http.Request
	Status        int
	ContentLength int
	RequestBody   []byte
	Accept        int //接受类型
	Version       string
	OTP           *OTPSpec
	Access        *Access
	Route         *Route
	App           interface{}
	// contains filtered or unexported fields
}

http context, 封装第三方包goji

func RCHolder

{{{ func rcHolder(c web.C, w http.ResponseWriter, r *http.Request) (func(c web.C, w http.ResponseWriter, r *http.Request) *RESTContext) * 利用闭包初始化RESTContext, 并防止某些关键字段被重写(RequestBody)

func (*RESTContext) AppLoggingCtag

func (rc *RESTContext) AppLoggingCtag(ctag string)

{{{ func (rc *RESTContext) AppLoggingCtag(ctag string) * 新

func (*RESTContext) AppLoggingNew

func (rc *RESTContext) AppLoggingNew(i interface{})

{{{ func (rc *RESTContext) AppLoggingNew(i interface{}) * 设置环境变量

func (*RESTContext) AppLoggingOld

func (rc *RESTContext) AppLoggingOld(i interface{})

{{{ func (rc *RESTContext) AppLoggingOld(i interface{}) * 旧

func (*RESTContext) AppLoggingResult

func (rc *RESTContext) AppLoggingResult(i interface{})

{{{ func (rc *RESTContext) AppLoggingResult(i interface{}) * 结果日志

func (*RESTContext) Critical

func (rc *RESTContext) Critical(format string, v ...interface{})

func (*RESTContext) Debug

func (rc *RESTContext) Debug(format string, v ...interface{})

func (*RESTContext) Error

func (rc *RESTContext) Error(format string, v ...interface{})

func (*RESTContext) GetCondition

func (rc *RESTContext) GetCondition(k string) (con *Condition, err error)

{{{ func (rc *RESTContext) GetCondition(k string) (con *Condition, err error) * 设置参数查询条件

func (*RESTContext) GetEnv

func (rc *RESTContext) GetEnv(k string) (v interface{})

{{{ func (rc *RESTContext) GetEnv(k string) (v interface{}) * 设置环境变量

func (*RESTContext) GetLock

func (rc *RESTContext) GetLock(key string) (err error)

{{{ func (rc *RESTContext) GetLock(key string) (err error) *

func (*RESTContext) GetQueryParam

func (rc *RESTContext) GetQueryParam(key string) (r string, c int)

{{{ func (rc *RESTContext) GetQueryParam(key string) (string, int)

func (*RESTContext) GetQueryParams

func (rc *RESTContext) GetQueryParams(key string) (rs []string)

{{{ func (rc *RESTContext) GetQueryParams(key string) (string, int)

func (*RESTContext) HTTPBack

func (rc *RESTContext) HTTPBack() (err error)

{{{ func (rc *RESTContext) HTTPBack() (err error) * 属于request的错误

func (*RESTContext) HTTPEmptyGif

func (rc *RESTContext) HTTPEmptyGif() (err error)

{{{ func (rc *RESTContext) HTTPEmptyGif() (err error) * 属于request的错误

func (*RESTContext) HTTPError

func (rc *RESTContext) HTTPError(status int) (err error)

{{{ func (rc *RESTContext) HTTPError(status int) (err error) *

func (*RESTContext) HTTPOK

func (rc *RESTContext) HTTPOK(data []byte) (err error)

{{{ func (rc *RESTContext) HTTPOK(data []byte) (err error) * 属于request的错误

func (*RESTContext) HTTPRedirect

func (rc *RESTContext) HTTPRedirect(url string) (err error)

{{{ func (rc *RESTContext) HTTPRedirect(url string) (err error) * 属于request的错误

func (*RESTContext) Info

func (rc *RESTContext) Info(format string, v ...interface{})

func (*RESTContext) LaunchTasks

func (rc *RESTContext) LaunchTasks() error

{{{ func (rc *RESTContext) LaunchTasks() error *

func (*RESTContext) NewAppLogging

func (rc *RESTContext) NewAppLogging(al *AppLog)

{{{ func (rc *RESTContext) NewAppLogging(al *AppLog) * 新建App日志

func (*RESTContext) NewRESTError

func (rc *RESTContext) NewRESTError(status int, msg interface{}) (re error)

{{{ func (rc *RESTContext) NewRESTError(status int, msg interface{}) (re error) *

func (*RESTContext) Output

func (rc *RESTContext) Output(data interface{}) (err error)

{{{ func (rc *RESTContext) Output(data interface{}) (err error) *

func (*RESTContext) Print

func (rc *RESTContext) Print(format string, v ...interface{})

func (*RESTContext) PushTask

func (rc *RESTContext) PushTask(queue, tag, value string) error

{{{ func (rc *RESTContext) PushTask(queue, tag, value string) error *

func (*RESTContext) RESTBadRequest

func (rc *RESTContext) RESTBadRequest(msg interface{}) (err error)

{{{ func (rc *RESTContext) RESTBadRequest(msg interface{}) (err error) * BadRequest

func (*RESTContext) RESTError

func (rc *RESTContext) RESTError(err error) error

{{{ func (rc *RESTContext) RESTError(msg interface{}) (err error) * 内部错误

func (*RESTContext) RESTGenericError

func (rc *RESTContext) RESTGenericError(status int, msg interface{}) (err error)

{{{ func (rc *RESTContext) RESTGenericError(status int, msg interface{}) (err error) * 普通错误,就是没有抓到error时报的错

func (*RESTContext) RESTNotFound

func (rc *RESTContext) RESTNotFound(msg interface{}) (err error)

{{{ func (rc *RESTContext) RESTNotFound(msg interface{}) (err error) *

func (*RESTContext) RESTNotOK

func (rc *RESTContext) RESTNotOK(msg interface{}) (err error)

{{{ func (rc *RESTContext) RESTNotOK(msg interface{}) (err error) * 属于request的错误

func (*RESTContext) RESTOK

func (rc *RESTContext) RESTOK(data interface{}) (err error)

{{{ func (rc *RESTContext) RESTOK(data interface{}) (err error) * 属于request的错误

func (*RESTContext) RESTPanic

func (rc *RESTContext) RESTPanic(msg interface{}) (err error)

{{{ func (rc *RESTContext) RESTPanic(msg interface{}) (err error) * 内部错误

func (*RESTContext) RESTTFA

func (rc *RESTContext) RESTTFA(data interface{}) (err error)

{{{ func (rc *RESTContext) RESTTFA(data interface{}) (err error) * rest tfa回应

func (*RESTContext) ReleaseLocks

func (rc *RESTContext) ReleaseLocks()

{{{ func (rc *RESTContext) ReleaseLocks() * 释放所有锁

func (*RESTContext) SaveAccess

func (rc *RESTContext) SaveAccess()

{{{ func (rc *RESTContext) SaveAccess() * 设置环境变量

func (*RESTContext) ServeBinary

func (rc *RESTContext) ServeBinary(mimetype string, data []byte)

{{{ func (rc *RESTContext) ServeBinary(mimetype string, data []byte) * 直接出二进制内容

func (*RESTContext) SetEnv

func (rc *RESTContext) SetEnv(k string, v interface{})

{{{ func (rc *RESTContext) SetEnv(k string, v interface{}) * 设置环境变量

func (*RESTContext) SetHeader

func (rc *RESTContext) SetHeader(k, v string)

{{{ func (rc *RESTContext) SetHeader(k,v string) * set header

func (*RESTContext) SetOTP

func (rc *RESTContext) SetOTP(s ...string)

{{{ func (rc *RESTContext) SetOTP(v,t,s string) * 设置环境变量

func (*RESTContext) SetStatus

func (rc *RESTContext) SetStatus(status int)

{{{ func (rc *RESTContext) SetStatus(status int) * 构建Status Code

func (*RESTContext) Trace

func (rc *RESTContext) Trace(format string, v ...interface{})

{{{ RESTContext loggers * 可以在每个debug信息带上session

func (*RESTContext) Warn

func (rc *RESTContext) Warn(format string, v ...interface{})

func (*RESTContext) WriteBytes

func (rc *RESTContext) WriteBytes(data []byte) (n int, e error)

{{{ func (rc *RESTContext) WriteBytes(data []byte) (n int, e error) * 输出内容,如果需要压缩,统一在这里进行

type RESTError

type RESTError struct {
	Message string            `json:"message"`
	Errors  map[string]string `json:"errors"`
	// contains filtered or unexported fields
}

func (*RESTError) Error

func (re *RESTError) Error() string

implement error interface

type Report

type Report struct {
	ReportInfo   *ReportInfo  `json:"report_info,omitempty"`
	Aggregations Aggregations `json:"aggregations,omitempty"` //聚合
	List         *List        `json:"list,omitempty"`
}

func (*Report) WithDefaults

func (rpt *Report) WithDefaults() *Report

{{{ func (rpt *Report) WithDefaults() *Report *

type ReportInfo

type ReportInfo struct {
	Dimension []string   `json:"dimension,omitempty"` // 维度
	Type      string     `json:"type,omitempty"`      // 报表类型
	Tz        string     `json:"tz,omitempty"`        // 时区
	Currency  string     `json:"currency,omitempty"`  // 货币
	Start     *time.Time `json:"start,omitempty"`     // 开始时间
	End       *time.Time `json:"end,omitempty"`       // 开始时间
}

type Route

type Route struct {
	Key      string //独立标识
	Endpoint string
	Pattern  interface{}
	Method   string
	Handler  Handler
	Options  *utils.SafeMap
	Updating bool
	Creating bool
}

func NewRoute

func NewRoute(p interface{}, ep string, m string, h Handler, options ...RouteOption) *Route

{{{ func NewRoute(p interface{}, ep string, m string, h Handler, options ...RouteOption) *Route *

type RouteOption

type RouteOption map[interface{}]interface{}

type Router

type Router struct {
	Endpoint   string
	Routes     map[string]*Route
	Hooks      map[string]TagHook
	SRoutes    []*Route //排序的Route
	ReqCount   int      //访问计数
	Mux        *Mux
	Controller interface{} //既是RouterInterface, 也是 ActionInterface
}

func (*Router) AddRoute

func (rtr *Router) AddRoute(m string, p interface{}, h Handler, options ...RouteOption)

{{{ func (rtr *Router) AddRoute(m string, p interface{}, h Handler, options ...RouteOption) *

func (*Router) CRUD

func (rtr *Router) CRUD(i interface{}, flag int) Handler

{{{ func (rtr *Router) CRUD(i interface{}, flag int) Handler * 通用的操作方法, 根据flag返回 * 必须符合通用的restful风格

func (*Router) DefaultRoutes

func (rtr *Router) DefaultRoutes()

{{{ func (rtr *Router) DefaultRoutes() * 默认路由, 如果已经定义了则忽略,没有定义则加上

func (*Router) Defer

func (_ *Router) Defer(i interface{})

}}} {{{ func (_ *Router) Defer(i interface{}) *

func (*Router) Delete

func (rtr *Router) Delete(c *RESTContext)

func (*Router) EmptyGif

func (rtr *Router) EmptyGif(c *RESTContext)

func (*Router) EmptyHtml

func (rtr *Router) EmptyHtml(c *RESTContext)

func (*Router) GenericRoute

func (rtr *Router) GenericRoute(i interface{}, flag int)

{{{ func (rtr *Router) GenericRoute(i interface{}, flag int) * 自动路由, 任何implelent了Action的类型都可以使用

func (*Router) Get

func (rtr *Router) Get(c *RESTContext)

{{{ Routers Default Action *

func (*Router) GetEndpoint

func (rtr *Router) GetEndpoint() string

{{{ func (rtr *Router) GetEndpoint() string *

func (*Router) Head

func (rtr *Router) Head(c *RESTContext)

func (*Router) Init

func (rtr *Router) Init()

{{{ func (rtr *Router) Init() *

func (*Router) New

func (rtr *Router) New(c interface{}, mux *Mux, endpoint string)

{{{ func (rtr *Router) New(c interface{},mux *Mux, endpoint string) *

func (*Router) NotFound

func (rtr *Router) NotFound(c *RESTContext)

func (*Router) OnCheck

func (_ *Router) OnCheck(i interface{}) (interface{}, error)

}}} {{{ func (_ *Router) OnCheck(i interface{}) (interface{}, error) *

func (*Router) OnCreate

func (_ *Router) OnCreate(i interface{}) (interface{}, error)

}}} {{{ func (_ *Router) OnCreate(i interface{}) (interface{}, error) *

func (*Router) OnDelete

func (_ *Router) OnDelete(i interface{}) (interface{}, error)

}}} {{{ func (_ *Router) OnDelete(i interface{}) (interface{}, error) *

func (*Router) OnGet

func (_ *Router) OnGet(i interface{}) (interface{}, error)

}}} {{{ func (_ *Router) OnGet(i interface{}) (interface{}, error) *

func (*Router) OnSearch

func (_ *Router) OnSearch(i interface{}) (interface{}, error)

}}} {{{ func (_ *Router) OnSearch(i interface{}) (interface{}, error) *

func (*Router) OnUpdate

func (_ *Router) OnUpdate(i interface{}) (interface{}, error)

}}} {{{ func (_ *Router) OnUpdate(i interface{}) (interface{}, error) *

func (*Router) Options

func (rtr *Router) Options(c *RESTContext)

func (*Router) Patch

func (rtr *Router) Patch(c *RESTContext)

func (*Router) Post

func (rtr *Router) Post(c *RESTContext)

func (*Router) PostCheck

func (_ *Router) PostCheck(i interface{}) (interface{}, error)

}}} {{{ func (_ *Router) PostCheck(i interface{}) (interface{}, error) *

func (*Router) PostCreate

func (_ *Router) PostCreate(i interface{}) (interface{}, error)

}}} {{{ func (_ *Router) PostCreate(i interface{}) (interface{}, error) *

func (*Router) PostDelete

func (_ *Router) PostDelete(i interface{}) (interface{}, error)

}}} {{{ func (_ *Router) PostDelete(i interface{}) (interface{}, error) *

func (*Router) PostGet

func (_ *Router) PostGet(i interface{}) (interface{}, error)

}}} {{{ func (_ *Router) PostGet(i interface{}) (interface{}, error) *

func (*Router) PostSearch

func (_ *Router) PostSearch(i interface{}) (interface{}, error)

}}} {{{ func (_ *Router) PostSearch(i interface{}) (interface{}, error) *

func (*Router) PostUpdate

func (_ *Router) PostUpdate(i interface{}) (interface{}, error)

}}} {{{ func (_ *Router) PostUpdate(i interface{}) (interface{}, error) *

func (*Router) PreCheck

func (_ *Router) PreCheck(i interface{}) (interface{}, error)

{{{ func (_ *Router) PreCheck(i interface{}) (interface{}, error) *

func (*Router) PreCreate

func (_ *Router) PreCreate(i interface{}) (interface{}, error)

{{{ func (_ *Router) PreCreate(i interface{}) (interface{}, error) *

func (*Router) PreDelete

func (_ *Router) PreDelete(i interface{}) (interface{}, error)

{{{ func (_ *Router) PreDelete(i interface{}) (interface{}, error) *

func (*Router) PreGet

func (_ *Router) PreGet(i interface{}) (interface{}, error)

{{{ func (_ *Router) PreGet(i interface{}) (interface{}, error) *

func (*Router) PreSearch

func (_ *Router) PreSearch(i interface{}) (interface{}, error)

{{{ func (_ *Router) PreSearch(i interface{}) (interface{}, error) *

func (*Router) PreUpdate

func (_ *Router) PreUpdate(i interface{}) (interface{}, error)

{{{ func (_ *Router) PreUpdate(i interface{}) (interface{}, error) *

func (*Router) Put

func (rtr *Router) Put(c *RESTContext)

func (*Router) RouteDelete

func (rtr *Router) RouteDelete(rt *Route)

func (*Router) RouteGet

func (rtr *Router) RouteGet(rt *Route)

{{{ goji's methods *

func (*Router) RouteHead

func (rtr *Router) RouteHead(rt *Route)

func (*Router) RouteNotFound

func (rtr *Router) RouteNotFound(rt *Route)

func (*Router) RoutePatch

func (rtr *Router) RoutePatch(rt *Route)

func (*Router) RoutePost

func (rtr *Router) RoutePost(rt *Route)

func (*Router) RoutePut

func (rtr *Router) RoutePut(rt *Route)

func (*Router) Trace

func (rtr *Router) Trace(c *RESTContext)

func (*Router) Trigger

func (_ *Router) Trigger(i interface{}) (interface{}, error)

{{{ func (_ *Router) Trigger(i interface{}) (interface{}, error) *

type RouterInterface

type RouterInterface interface {
	New(interface{}, *Mux, string)
	AddRoute(m string, p interface{}, h Handler, options ...RouteOption)
	DefaultRoutes() //默认路由
	GetEndpoint() string
	Init()

	//method
	Get(*RESTContext)
	Post(*RESTContext)
	Put(*RESTContext)
	Delete(*RESTContext)
	Patch(*RESTContext)
	Head(*RESTContext)
	Options(*RESTContext)
	Trace(*RESTContext)
	NotFound(*RESTContext)

	// action
	CRUD(i interface{}, flag int) Handler
}

func NewRouter

func NewRouter(c interface{}, endpoint string) RouterInterface

{{{ func NewRouter(c interface{}, endpoint string) RouterInterface * 默认用DMux设置给router

type SelfConverter

type SelfConverter interface {
	ToDb() (interface{}, error)                    //入库
	FromDb(interface{}) (gorp.CustomScanner, bool) //出库
}

出/入库转换器

type TagHook

type TagHook func(v reflect.Value) reflect.Value

struct里面的field可定义处理函数

type Task

type Task struct {
	Queue string
	Tag   string
	Value string
}

type TemporaryCounter

type TemporaryCounter struct {
	Name          string // 计数器名称
	Total         string // 汇总字段
	TotalAmount   float64
	Journal       string  //流水号
	JournalAmount float64 //金额
}

func (*TemporaryCounter) ClearJournal

func (tc *TemporaryCounter) ClearJournal(journal string) error

{{{ func (tc *TemporaryCounter) ClearJournal(journal string) error * 清除临时扣除

func (*TemporaryCounter) GetTotalAmount

func (tc *TemporaryCounter) GetTotalAmount() (float64, error)

{{{ func (tc *TemporaryCounter) GetTotalAmount() (float64, error) * 获取临时扣除总额

func (*TemporaryCounter) Incr

func (tc *TemporaryCounter) Incr(amount float64) error

{{{ func (tc *TemporaryCounter) Incr(amount float64) error * 临时扣除(就是在TemporaryCounter增加一笔)

type TimeRange

type TimeRange struct {
	Start time.Time
	End   time.Time
}

时间段

type Worker

type Worker struct {
	WorkerName string
	WorkerType reflect.Type
	Mux        *Mux
}

func (*Worker) Critical

func (w *Worker) Critical(format string, v ...interface{})

func (*Worker) Debug

func (w *Worker) Debug(format string, v ...interface{})

func (*Worker) Error

func (w *Worker) Error(format string, v ...interface{})

func (*Worker) Info

func (w *Worker) Info(format string, v ...interface{})

func (*Worker) Init

func (w *Worker) Init(mux *Mux, name string)

初始化, 赋值

func (*Worker) Main

func (w *Worker) Main() error

func (*Worker) Print

func (w *Worker) Print(format string, v ...interface{})

func (*Worker) Trace

func (w *Worker) Trace(format string, v ...interface{})

{{{ Worker loggers * 可以在每个debug信息带上session

func (*Worker) Warn

func (w *Worker) Warn(format string, v ...interface{})

type WorkerInterface

type WorkerInterface interface {
	Init(mux *Mux, name string)
	Main() error
}

Directories

Path Synopsis
zhaoonline storage service
zhaoonline storage service
config
Package main provides ...
Package main provides ...
hooks
Package hooks provides ...
Package hooks provides ...
routers
zhaoonline storage service zhaoonline storage service
zhaoonline storage service zhaoonline storage service
libs
这里实现bitmap索引 Package serving provides ...
这里实现bitmap索引 Package serving provides ...

Jump to

Keyboard shortcuts

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