Documentation ¶
Index ¶
- Constants
- Variables
- 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 DialFunc
- type DogPacket
- type DogPacketDecoder
- type DogPacketEncoder
- type Handler
- type HandlerFunc
- type Header
- type Listener
- type MessageDecoder
- type MessageDecoderFunc
- type MessageEncoder
- type MessageEncoderFunc
- type Packet
- type Server
- type TcpClient
- func (c *TcpClient) AddAddr(addr string)
- func (c *TcpClient) Connect() (*Client, error)
- func (c *TcpClient) DogConnect() (*Client, error)
- func (c *TcpClient) DogInvoke(cmd uint32, req []byte, client ...*Client) (rsp []byte, err *dogError.CodeError)
- func (c *TcpClient) Invoke(cmd uint32, req []byte, client ...*Client) (rsp []byte, err *dogError.CodeError)
- func (c *TcpClient) Stop()
- type TcpPacket
- type TcpPacketDecoder
- type TcpPacketEncoder
- type TcpServer
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 NoPort = 0
Variables ¶
View Source
var ( TimeOutError = error.SetCodeType(10001, "timeout error.") OverflowError = error.SetCodeType(10002, "overflow error.") InternalServerError = error.SetCodeType(10003, "interval server error.") InvalidParam = error.SetCodeType(10004, "invalid param") )
View Source
var (
NoTcpPort = errors.New("no tcp serve port")
)
Functions ¶
This section is empty.
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 DogPacket ¶
func NewDogPacket ¶
func NewDogPacketWithRet ¶
func NewDogTcpPacketWithSeq ¶
func (*DogPacket) SetErrCode ¶
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 HandlerFunc ¶
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 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 }
type TcpClient ¶
type TcpClient struct { Cm map[string]*Client Timeout time.Duration RetryNum uint32 // contains filtered or unexported fields }
func (*TcpClient) DogConnect ¶
dog packet establish connection
func (*TcpClient) DogInvoke ¶
func (c *TcpClient) DogInvoke(cmd uint32, req []byte, client ...*Client) (rsp []byte, err *dogError.CodeError)
dog packet. Invoke rpc call
type TcpPacket ¶
type TcpPacket struct { Seq uint32 ErrCode uint32 Cmd uint32 // also be a string, for dispatch. PacketLen uint32 Body []byte }
func NewTcpPacket ¶
func NewTcpPacketWithRet ¶
func (*TcpPacket) SetErrCode ¶
type TcpPacketDecoder ¶
type TcpPacketDecoder struct {
// contains filtered or unexported fields
}
func (*TcpPacketDecoder) Decode ¶
func (d *TcpPacketDecoder) Decode() (Packet, error)
type TcpPacketEncoder ¶
type TcpPacketEncoder struct {
// contains filtered or unexported fields
}
func (*TcpPacketEncoder) Encode ¶
func (e *TcpPacketEncoder) Encode(p Packet) error
func (*TcpPacketEncoder) Flush ¶
func (e *TcpPacketEncoder) Flush() error
type TcpServer ¶
type TcpServer struct {
// contains filtered or unexported fields
}
func NewDogTcpServer ¶
func NewDogTcpServer() *TcpServer
func NewTcpServer ¶
func NewTcpServer() *TcpServer
func (*TcpServer) AddTcpHandler ¶
Click to show internal directories.
Click to hide internal directories.