Documentation ¶
Index ¶
- Constants
- func BuildControlBuffer(buf *ControlBuffer, max uint32)
- func NewBodyPool(size uint32)
- type Buffer
- type ConnOption
- type ControlBuffer
- type DialOption
- type Frame
- type Framer
- type IClientTransport
- type IServerTransport
- type IUnboundedChan
- type ReceiveBuf
- type SenderWrapper
- type Stream
- type StreamMsg
- type StreamState
- type Streams
- func (ins *Streams) Close(onClose func(stream *Stream))
- func (ins *Streams) Del(id int64)
- func (ins *Streams) Exist(id int64) (exist bool)
- func (ins *Streams) Get(id int64) (*Stream, bool)
- func (ins *Streams) GetAndDel(id int64) (*Stream, bool)
- func (ins *Streams) Len() int
- func (ins *Streams) Range(iter func(stream *Stream))
- func (ins *Streams) Reg(id int64, s *Stream)
- func (ins *Streams) StreamId() int64
- type TcpClient
- func (tc *TcpClient) Close(reason string) error
- func (tc *TcpClient) CloseStream(streamId int64)
- func (tc *TcpClient) DialWithOps(ops DialOption)
- func (tc *TcpClient) HandleData(in *Frame)
- func (tc *TcpClient) NewStream(ctx context.Context, initialSize int) (*Stream, error)
- func (tc *TcpClient) SendData(data packet.IPacket) error
- func (tc *TcpClient) StateCompareAndSwap(old, new uint32) bool
- func (tc *TcpClient) Write(s *Stream, pack packet.IPacket, isLast bool) error
- func (tc *TcpClient) WriteData(s *Stream, data []byte, isLast bool) error
- type TcpCodec
- type TcpServer
- func (ts *TcpServer) Close(_ string) error
- func (ts *TcpServer) CloseStream(streamId int64)
- func (ts *TcpServer) HandleData(in *Frame)
- func (ts *TcpServer) HandleLoop()
- func (ts *TcpServer) OnData(data packet.IPacket) error
- func (ts *TcpServer) SendData(body packet.IPacket) error
- func (ts *TcpServer) Write(stream *Stream, pack packet.IPacket) (err error)
- func (ts *TcpServer) WriteData(stream *Stream, data []byte) (err error)
Constants ¶
View Source
const ( BatchLimit = 100 PingTimeOut = time.Second * 30 AckInterval = time.Second * 5 MaxTransPacket = 1048576 MaxRetried = 5 HeadLen = 4 //包头字节数 ReadTimeout = time.Second * 60 WriteTimeout = time.Second * 5 )
View Source
const ( StatusConnecting = iota StatusConnected StatusDisconnected )
View Source
const ( TypeWorking = 1 TypeStopped = 2 )
View Source
const ( ZMinLen = 200 GzippedSize = 1 )
View Source
const ( FrameRaw = iota FrameReplyRaw FrameStreamHeartbeat FrameStartStream FrameCleanStream FrameCliHalfClosedAck )
Variables ¶
This section is empty.
Functions ¶
func BuildControlBuffer ¶
func BuildControlBuffer(buf *ControlBuffer, max uint32)
func NewBodyPool ¶
func NewBodyPool(size uint32)
Types ¶
type ConnOption ¶
type ConnOption struct { MaxIncomingPacket uint32 StreamRecvBufSize int StreamHandler func(st IServerTransport, s *Stream) }
type ControlBuffer ¶
type ControlBuffer struct {
// contains filtered or unexported fields
}
func NewControlBuffer ¶
func NewControlBuffer(max uint32, _sw *SenderWrapper) *ControlBuffer
func (*ControlBuffer) Kick ¶
func (ins *ControlBuffer) Kick()
func (*ControlBuffer) OnClose ¶
func (ins *ControlBuffer) OnClose()
OnClose TODO: Is it reasonable to reject stream input immediately?
func (*ControlBuffer) Run ¶
func (ins *ControlBuffer) Run(_sw *SenderWrapper)
type DialOption ¶
type IClientTransport ¶
type IClientTransport interface { Write(stream *Stream, pack packet.IPacket, isLast bool) error WriteData(s *Stream, data []byte, isLast bool) error Close(reason string) error NewStream(ctx context.Context, initialSize int) (*Stream, error) CloseStream(streamId int64) }
func NewTcpClient ¶
func NewTcpClient(_ops DialOption) IClientTransport
type IServerTransport ¶
type IUnboundedChan ¶
type ReceiveBuf ¶
type ReceiveBuf struct {
// contains filtered or unexported fields
}
func NewReceiveBuf ¶
func NewReceiveBuf(size int) *ReceiveBuf
func (*ReceiveBuf) OnClose ¶
func (rb *ReceiveBuf) OnClose()
type SenderWrapper ¶
type SenderWrapper struct {
// contains filtered or unexported fields
}
func (*SenderWrapper) OnClose ¶
func (ins *SenderWrapper) OnClose()
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
func (*Stream) OnElegantlyClose ¶
func (s *Stream) OnElegantlyClose()
type StreamState ¶
type StreamState uint32
const ( StreamActive StreamState = iota StreamWriteDone )
type Streams ¶
type Streams struct {
// contains filtered or unexported fields
}
func NewStreams ¶
func NewStreams() *Streams
type TcpClient ¶
type TcpClient struct {
// contains filtered or unexported fields
}
func (*TcpClient) CloseStream ¶
func (*TcpClient) DialWithOps ¶
func (tc *TcpClient) DialWithOps(ops DialOption)
func (*TcpClient) HandleData ¶
func (*TcpClient) StateCompareAndSwap ¶
type TcpCodec ¶
type TcpCodec struct {
// contains filtered or unexported fields
}
TcpCodec TODO: 不支持压缩
func NewTcpCodec ¶
func (TcpCodec) BlockDecode ¶
type TcpServer ¶
type TcpServer struct {
// contains filtered or unexported fields
}
func NewTcpServer ¶
func (*TcpServer) CloseStream ¶
func (*TcpServer) HandleData ¶
func (*TcpServer) HandleLoop ¶
func (ts *TcpServer) HandleLoop()
func (*TcpServer) SendData ¶
SendData implicitly call body.Return coding: size<int32> | gzipped<bool> | body<bytes>
Click to show internal directories.
Click to hide internal directories.