Documentation ¶
Index ¶
- Constants
- Variables
- func InitFilters(filters []Filter)
- func Return(code uint32, message string, err error, result interface{}) (resp []byte)
- type AsyncResult
- type Client
- func (c *Client) Call(req Packet) (rsp Packet, err *dogError.CodeError)
- func (c *Client) CallAsync(req Packet, skipResponse bool) (*AsyncResult, *dogError.CodeError)
- func (c *Client) CallRetry(req Packet, retryNum uint32) (rsp Packet, err *dogError.CodeError)
- func (c *Client) CallTimeout(req Packet, timeout time.Duration, retryNum uint32) (rsp Packet, err *dogError.CodeError)
- func (c *Client) SendUDP(req Packet) (err *dogError.CodeError)
- func (c *Client) Start()
- func (c *Client) Stop()
- type Context
- type DialFunc
- type DogPacket
- type DogPacketDecoder
- type DogPacketEncoder
- type Filter
- type Filters
- type GlFilter
- type HandlerFunc
- type Header
- type Listener
- type LogFilter
- type MessageDecoder
- type MessageDecoderFunc
- type MessageEncoder
- type MessageEncoderFunc
- type Packet
- type RpcClient
- func (c *RpcClient) AddAddr(addr string)
- func (c *RpcClient) Connect() (*Client, error)
- func (c *RpcClient) DogConnect() (*Client, error)
- func (c *RpcClient) DogInvoke(cmd uint32, req []byte, client ...*Client) (code uint32, rsp []byte, err *dogError.CodeError)
- func (c *RpcClient) Invoke(cmd uint32, req []byte, client ...*Client) (code uint32, rsp []byte, err *dogError.CodeError)
- func (c *RpcClient) Stop()
- type RpcHandlerFunc
- type RpcPacket
- type RpcPacketDecoder
- type RpcPacketEncoder
- type RpcServer
- type Server
Constants ¶
View Source
const ( DefaultConcurrency = 8 * 1024 DefaultRequestTimeout = 20 * time.Second DefaultPendingMessages = 32 * 1024 DefaultFlushDelay = -1 DefaultBufferSize = 64 * 1024 DefaultDialRetryTime = 0 DefaultConnectNumbers = 1 )
View Source
const ( HeaderLen = 24 Version = 1 Padding = 0 SOH = 0x10 EOH = 0x24 )
View Source
const (
DefaultDialNetWork = "tcp"
)
Variables ¶
View Source
var ( TimeOutError = derror.SetCodeType(10001, "timeout error.") OverflowError = derror.SetCodeType(10002, "overflow error.") InternalServerError = derror.SetCodeType(10003, "interval server error.") InvalidParam = derror.SetCodeType(10004, "invalid param") )
Functions ¶
func InitFilters ¶
func InitFilters(filters []Filter)
Types ¶
type AsyncResult ¶
type AsyncResult struct { Response Packet Error error Done chan struct{} Request Packet // contains filtered or unexported fields }
func (*AsyncResult) Cancel ¶
func (m *AsyncResult) Cancel()
type Client ¶
type Client struct { Addr string Conns int Dial DialFunc DialRetryTime int PendingRequests int FlushDelay time.Duration RequestTimeout time.Duration SendBufferSize int RecvBufferSize int Encoder MessageEncoderFunc Decoder MessageDecoderFunc // contains filtered or unexported fields }
func (*Client) CallTimeout ¶
type Context ¶
type Context struct { ClientAddr string Seq uint32 Method string Handler RpcHandlerFunc Req []byte }
type DogPacketDecoder ¶
type DogPacketDecoder struct {
// contains filtered or unexported fields
}
func (*DogPacketDecoder) Decode ¶
func (d *DogPacketDecoder) Decode() (Packet, error)
type DogPacketEncoder ¶
type DogPacketEncoder struct {
// contains filtered or unexported fields
}
func (*DogPacketEncoder) Encode ¶
func (e *DogPacketEncoder) Encode(p Packet) error
func (*DogPacketEncoder) Flush ¶
func (e *DogPacketEncoder) Flush() error
type GlFilter ¶
type GlFilter struct { IfLogAll bool SlowCostThreshold int // contains filtered or unexported fields }
example: gl filter
type HandlerFunc ¶
type LogFilter ¶
type LogFilter struct { IfLogAll bool SlowCostThreshold int // contains filtered or unexported fields }
example: log filter
type MessageDecoder ¶
type MessageDecoderFunc ¶
type MessageDecoderFunc func(r io.Reader, bufferSize int) (decoder MessageDecoder, err error)
type MessageEncoder ¶
type MessageEncoderFunc ¶
type MessageEncoderFunc func(w io.Writer, bufferSize int) (encoder MessageEncoder, err error)
type RpcClient ¶
type RpcClient struct { Cm map[string]*Client Timeout time.Duration RetryNum uint32 // contains filtered or unexported fields }
func (*RpcClient) DogConnect ¶
dog packet establish connection
func (*RpcClient) DogInvoke ¶
func (c *RpcClient) DogInvoke(cmd uint32, req []byte, client ...*Client) (code uint32, rsp []byte, err *dogError.CodeError)
dog packet. Invoke rpc call
type RpcHandlerFunc ¶
type RpcPacket ¶
type RpcPacket struct { Seq uint32 ErrCode uint32 Cmd uint32 // also be a string, for dispatch. PacketLen uint32 Body []byte }
func NewRpcPacket ¶
func NewRpcPacketWithRet ¶
func (*RpcPacket) SetErrCode ¶
type RpcPacketDecoder ¶
type RpcPacketDecoder struct {
// contains filtered or unexported fields
}
func (*RpcPacketDecoder) Decode ¶
func (d *RpcPacketDecoder) Decode() (Packet, error)
type RpcPacketEncoder ¶
type RpcPacketEncoder struct {
// contains filtered or unexported fields
}
func (*RpcPacketEncoder) Encode ¶
func (e *RpcPacketEncoder) Encode(p Packet) error
func (*RpcPacketEncoder) Flush ¶
func (e *RpcPacketEncoder) Flush() error
type RpcServer ¶
type RpcServer struct { Addr int `inject:"rpcHost"` // contains filtered or unexported fields }
func NewDogRpcServer ¶
func NewDogRpcServer() *RpcServer
func NewRpcServer ¶
func NewRpcServer() *RpcServer
func (*RpcServer) AddDogHandler ¶
func (*RpcServer) AddHandler ¶
func (s *RpcServer) AddHandler(headCmd uint32, f RpcHandlerFunc)
func (*RpcServer) DogRpcRegister ¶
type Server ¶
type Server struct { Addr string Handler HandlerFunc Concurrency int FlushDelay time.Duration PendingResponses int SendBufferSize int RecvBufferSize int Listener Listener Encoder MessageEncoderFunc Decoder MessageDecoderFunc // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.