Documentation
¶
Index ¶
- Variables
- func Debug(v ...interface{})
- func Debugf(format string, params ...interface{})
- func Error(v ...interface{}) error
- func Errorf(format string, params ...interface{}) error
- func FlushLog()
- func GenUUID5(name string) string
- func Get(url string) ([]byte, error)
- func GetJSON(url string) (map[string]interface{}, error)
- func GetJSONArray(url string) ([]interface{}, error)
- func GoForever(f func() bool)
- func HttpClientIP(r *http.Request) string
- func Info(v ...interface{})
- func Infof(format string, params ...interface{})
- func InitLog(fileName string) error
- func InitLogDefault() error
- func InitLogDefaultWithConsole() error
- func LoadXml(fileName string, cfg interface{}) error
- func Panic(err interface{})
- func Post(url string, form url.Values, headers map[string]string) ([]byte, http.Header, error)
- func PostJSONArray(url string, form url.Values, headers map[string]string) ([]interface{}, http.Header, error)
- func PostJson(url string, form url.Values, headers map[string]string) (map[string]interface{}, http.Header, error)
- func RecoverError()
- func ReplyError(w http.ResponseWriter, res string, err error)
- func ReplyMap(w http.ResponseWriter, v map[string]interface{})
- func ReplyRawText(w http.ResponseWriter, text string)
- func ReplyString(w http.ResponseWriter, res string)
- func SaveXml(fileName string, cfg interface{}) error
- func Ternary(cond bool, trueValue, falseValue interface{}) interface{}
- type DB
- type DBConfig
- type DefaultParser
- type FileWatcher
- type HttpServer
- type HttpServerConfig
- type IAuth
- type IClient
- type IClientChanged
- type IDGenerator
- type IHandler
- type IParser
- type IState
- type JsonMsg
- type JsonMsgHandler
- type LogFunc
- type MultiThreadHandler
- type Uint64IDGenerator
- type WSClient
- type WSClientDialer
- type WSServer
- type WSServerConfig
Constants ¶
This section is empty.
Variables ¶
var ( InvalidDataError = fmt.Errorf("invalid data error") InvalidServiceError = fmt.Errorf("invalid service error") )
var (
DefaultIDGenerator = NewUint64IDGenerator()
)
var (
Logger = LogFunc(Info)
)
Functions ¶
func Debug ¶
func Debug(v ...interface{})
Debug formats message using the default formats for its operands and writes to default logger with ylog level = Debug
func Debugf ¶
func Debugf(format string, params ...interface{})
Debugf formats message according to format specifier and writes to default logger with ylog level = Debug.
func Error ¶
func Error(v ...interface{}) error
Error formats message using the default formats for its operands and writes to default logger with ylog level = Error
func Errorf ¶
Errorf formats message according to format specifier and writes to default logger with ylog level = Error
func GetJSONArray ¶
func HttpClientIP ¶
func Info ¶
func Info(v ...interface{})
Info formats message using the default formats for its operands and writes to default logger with ylog level = Info
func Infof ¶
func Infof(format string, params ...interface{})
Infof formats message according to format specifier and writes to default logger with ylog level = Info.
func InitLogDefault ¶
func InitLogDefault() error
func InitLogDefaultWithConsole ¶ added in v0.0.6
func InitLogDefaultWithConsole() error
func PostJSONArray ¶ added in v0.0.3
func RecoverError ¶
func RecoverError()
func ReplyError ¶
func ReplyError(w http.ResponseWriter, res string, err error)
func ReplyMap ¶
func ReplyMap(w http.ResponseWriter, v map[string]interface{})
func ReplyRawText ¶
func ReplyRawText(w http.ResponseWriter, text string)
func ReplyString ¶
func ReplyString(w http.ResponseWriter, res string)
Types ¶
type DB ¶
func NewDBFromConfigFile ¶
type DefaultParser ¶
type DefaultParser struct {
// contains filtered or unexported fields
}
func NewDefaultParser ¶
func NewDefaultParser(handler IHandler, maxLength int) *DefaultParser
func (*DefaultParser) OnNewData ¶
func (p *DefaultParser) OnNewData(client IClient, buf []byte) error
func (*DefaultParser) PackData ¶
func (p *DefaultParser) PackData(data interface{}) []byte
type FileWatcher ¶
func NewFileWatcher ¶
func NewFileWatcher(f func(fileName string, mode string)) (fileWatcher *FileWatcher, err error)
type HttpServer ¶
type HttpServer struct {
// contains filtered or unexported fields
}
func NewHttpServer ¶
func NewHttpServer(ctx context.Context, config *HttpServerConfig) (server *HttpServer, err error)
func NewHttpServerFromConfigFile ¶
func NewHttpServerFromConfigFile(ctx context.Context, fileName string) (server *HttpServer, err error)
func (*HttpServer) Close ¶
func (s *HttpServer) Close()
func (*HttpServer) HandleFunc ¶
func (s *HttpServer) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
func (*HttpServer) Start ¶
func (s *HttpServer) Start()
type HttpServerConfig ¶
type IClientChanged ¶
type IClientChanged interface { OnAdded(connId uint64, userId interface{}) OnRemoved(connId uint64, userId interface{}, beKickedClient IClient) }
在同一协程中调用
type IDGenerator ¶
type IDGenerator interface {
Next() interface{}
}
func NewUint64IDGenerator ¶
func NewUint64IDGenerator() IDGenerator
type JsonMsgHandler ¶
type JsonMsgHandler struct {
// contains filtered or unexported fields
}
json format data
func NewJsonMsgHandler ¶
func NewJsonMsgHandler(router map[string]func(jsonMsg *JsonMsg)) *JsonMsgHandler
func (*JsonMsgHandler) HandleNewData ¶
func (h *JsonMsgHandler) HandleNewData(client IClient, data interface{}) error
func (*JsonMsgHandler) PackData ¶
func (h *JsonMsgHandler) PackData(data interface{}) []byte
type MultiThreadHandler ¶
type MultiThreadHandler struct {
// contains filtered or unexported fields
}
func NewMultiThreadHandler ¶
func NewMultiThreadHandler(ctx context.Context, handler IHandler, threadCount int) *MultiThreadHandler
func (*MultiThreadHandler) HandleNewData ¶
func (h *MultiThreadHandler) HandleNewData(client IClient, data interface{}) error
func (*MultiThreadHandler) PackData ¶
func (h *MultiThreadHandler) PackData(data interface{}) []byte
type Uint64IDGenerator ¶
type Uint64IDGenerator struct {
// contains filtered or unexported fields
}
func (*Uint64IDGenerator) Next ¶
func (g *Uint64IDGenerator) Next() interface{}
type WSClientDialer ¶
type WSServer ¶
type WSServer struct { Auth IAuth Parser IParser ClientChanged IClientChanged // contains filtered or unexported fields }
func NewWSServer ¶
func NewWSServer(ctx context.Context, config *WSServerConfig) (*WSServer, error)