Documentation ¶
Index ¶
Constants ¶
const MaxErrorInARow = 3
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chunk ¶
type Chunk struct {
// contains filtered or unexported fields
}
Chunk Format:
bytes[0..3] : seqID, 32 bits (int32) bytes[4..7] : payloadSize, 32 bits (int32) bytes[8] : isEOF, 8 bits bytes[9..15] : reserved bytes[16..payloadSize+15]: the actual payload Chunk Bit Map
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | seqID (32 bits) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | payloadSize (32 bits) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | isEOF | reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | reserved | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | | payload | | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
func NewChunk ¶
NewChunk will create a chunk from the given "content" byte slice. It extracts the subslice content[startIdx:startIdx+payloadSize] as the payload of the chunk, and adds the meta data (isEOF, seqID) after the payload
func NewChunkFromRawBytes ¶
func NewEmptyChunk ¶
func NewUninitializedChunk ¶
type RecvBuffer ¶
type RecvBuffer struct {
// contains filtered or unexported fields
}
func NewRecvBuffer ¶
func NewRecvBuffer(config RecvBufferConfig, rawStream cmn.ReadWriteCloser, onError cmn.ErrorHandler) RecvBuffer
NewRecvBuffer creates a RecvBuffer instance for the given config
func (*RecvBuffer) GetSize ¶
func (rb *RecvBuffer) GetSize() int
GetSize returns the size of the SendBuffer. It is goroutine safe
func (*RecvBuffer) Read ¶
func (rb *RecvBuffer) Read() ([]byte, error)
Read blocks until a message can be retrived from the queue
type RecvBufferConfig ¶
type RecvBufferConfig struct { RecvRate int64 // contains filtered or unexported fields }
func GetDefaultRecvBufferConfig ¶
func GetDefaultRecvBufferConfig() RecvBufferConfig
GetDefaultRecvBufferConfig returns the default config for the RecvBuffer
type SendBuffer ¶
type SendBuffer struct {
// contains filtered or unexported fields
}
func NewSendBuffer ¶
func NewSendBuffer(config SendBufferConfig, rawStream cmn.ReadWriteCloser, onError cmn.ErrorHandler) SendBuffer
NewSendBuffer creates a SendBuffer instance for the given config
func (*SendBuffer) CanInsert ¶
func (sb *SendBuffer) CanInsert() bool
CanInsert return whether more bytes can be inserted into the send buffer. It is goroutine safe
func (*SendBuffer) GetSize ¶
func (sb *SendBuffer) GetSize() int
GetSize returns the size of the SendBuffer. It is goroutine safe
func (*SendBuffer) IsEmpty ¶
func (sb *SendBuffer) IsEmpty() bool
IsEmpty indicates whether the SendBuffer is empty
func (*SendBuffer) Write ¶
func (sb *SendBuffer) Write(bytes []byte) bool
Write insert the bytes to queue, and times out after the configured timeout. It is goroutine safe
type SendBufferConfig ¶
type SendBufferConfig struct { SendRate int64 ChunkBatchSize int64 // contains filtered or unexported fields }
func GetDefaultSendBufferConfig ¶
func GetDefaultSendBufferConfig() SendBufferConfig
GetDefaultSendBufferConfig returns the default config for the SendBuffer