Documentation ¶
Index ¶
- Constants
- Variables
- func GetBuffer(n int) (buf []byte)
- func GetConnType(data []byte) (connType uint32)
- type Client
- func (c *Client) ClientRead()
- func (c *Client) Close()
- func (c *Client) Do(funcName string, params []byte, callback RespHandler) (err error)
- func (c *Client) HandlerResp(resp *Response)
- func (c *Client) ProcessResp()
- func (c *Client) Read(length int) (data []byte, err error)
- func (c *Client) Write() (err error)
- type ErrHandler
- type Request
- type RespHandler
- type RespHandlerMap
- type Response
- type RetStruct
Constants ¶
View Source
const ( MIN_DATA_SIZE = 12 UINT32_SIZE = 4 QUEUE_SIZE = 64 BUFFER_SIZE = 512 DEFAULT_TIME_OUT = 5 * time.Second //package data type PDT_OK = 1 PDT_ERROR = 2 PDT_CAN_DO = 3 PDT_CANT_DO = 4 PDT_NO_JOB = 5 PDT_HAVE_JOB = 6 PDT_TOSLEEP = 7 PDT_WAKEUP = 8 PDT_WAKEUPED = 9 PDT_S_GET_DATA = 10 PDT_S_RETURN_DATA = 11 PDT_W_GRAB_JOB = 12 PDT_W_ADD_FUNC = 13 PDT_W_DEL_FUNC = 14 PDT_W_RETURN_DATA = 15 PDT_C_DO_JOB = 16 PDT_C_GET_DATA = 17 )
View Source
const ( CONN_TYPE_INIT = 0 CONN_TYPE_SERVER = 1 CONN_TYPE_WORKER = 2 CONN_TYPE_CLIENT = 3 PARAMS_TYPE_ONE = 4 PARAMS_TYPE_MUL = 5 JOB_STATUS_INIT = 6 JOB_STATUS_DOING = 7 JOB_STATUS_DONE = 8 )
Variables ¶
View Source
var RESTIMEOUT = errors.New("RESTIMEOUT")
Functions ¶
func GetConnType ¶
Types ¶
type Client ¶
type Client struct { sync.Mutex Req *Request ResQueue chan *Response Timeout time.Duration ErrHandler ErrHandler RespHandlers *RespHandlerMap // contains filtered or unexported fields }
func (*Client) ClientRead ¶
func (c *Client) ClientRead()
func (*Client) Do ¶
func (c *Client) Do(funcName string, params []byte, callback RespHandler) (err error)
func (*Client) HandlerResp ¶
func (*Client) ProcessResp ¶
func (c *Client) ProcessResp()
type ErrHandler ¶
type ErrHandler func(err error)
type Request ¶
type Request struct { DataType uint32 Data []byte DataLen uint32 Handle string HandleLen uint32 ParamsType uint32 ParamsLen uint32 Params []byte Ret []byte RetLen uint32 }
type RespHandler ¶
type RespHandler func(resp *Response)
type RespHandlerMap ¶
func NewResHandlerMap ¶
func NewResHandlerMap() *RespHandlerMap
func (*RespHandlerMap) DelResHandlerMap ¶
func (rhm *RespHandlerMap) DelResHandlerMap(key string)
func (*RespHandlerMap) GetResHandlerMap ¶
func (rhm *RespHandlerMap) GetResHandlerMap(key string) (handler RespHandler, exist bool)
func (*RespHandlerMap) PutResHandlerMap ¶
func (rhm *RespHandlerMap) PutResHandlerMap(key string, handler RespHandler)
Click to show internal directories.
Click to hide internal directories.