Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateTheNumberOfPackages(size int64) int64
- func GetDataMaxSize() int
- type Protocol
- func (p *Protocol) GetHeartbeatLastReceived() int64
- func (p *Protocol) GetHeartbeatLastSend() int64
- func (p *Protocol) Heartbeat(sendInterval int, receiveTimeout int, failedCallback func() bool) error
- func (p *Protocol) Kill()
- func (p *Protocol) Reader(callback func(data []byte)) error
- func (p *Protocol) Write(data []byte) error
- func (p *Protocol) Writer(writeQueueSize int) error
Constants ¶
View Source
const VERSION uint8 = 1
Variables ¶
View Source
var ErrorBrokenData = errors.New("data crc32 checksum does not match")
View Source
var ErrorBrokenHead = errors.New("head crc32 checksum does not match")
View Source
var ErrorDataSizeExceedsLimit = errors.New("data size exceeds limit")
View Source
var ErrorHeartbeatCallbackIsNil = errors.New("heartbeat callback is nil")
View Source
var ErrorHeartbeatIsKilled = errors.New("heartbeat is killed")
View Source
var ErrorPackageIncomplete = errors.New("package incomplete")
View Source
var ErrorReadCallbackIsNil = errors.New("read callback is nil")
View Source
var ErrorReaderIsKilled = errors.New("reader is killed")
View Source
var ErrorReaderIsNil = errors.New("reader is nil")
View Source
var ErrorUnsupportedVersion = errors.New("unsupported version")
View Source
var ErrorWriterIsKilled = errors.New("writer is killed")
View Source
var ErrorWriterIsNil = errors.New("writer is nil")
View Source
var ErrorWriterQueueIsNil = errors.New("writer queue is nil")
View Source
var ErrorWrongPrefix = errors.New("prefix does not match")
Functions ¶
func GetDataMaxSize ¶
func GetDataMaxSize() int
Types ¶
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
func (*Protocol) GetHeartbeatLastReceived ¶
func (*Protocol) GetHeartbeatLastSend ¶
func (*Protocol) Heartbeat ¶
func (p *Protocol) Heartbeat(sendInterval int, receiveTimeout int, failedCallback func() bool) error
Heartbeat 心跳服务
sendInterval: 主动发送心跳信号的间隔时间(s),最小为3s,,传入参数小于3时使用默认值3 receiveTimeout: 被动接收心跳信号的超时时间(s),最小为3s,传入参数小于3时使用默认值3 failedCallback: 没有按时收到心跳信号时调用,返回true继续等待,返回false退出
Click to show internal directories.
Click to hide internal directories.