Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateTheNumberOfPackages(size int64) int64
- func GetDataMaxSize() int
- func SetLogFlag(f uint32)
- func SetLogMask(mask uint32)
- func SetLogProd(isProd bool)
- type Protocol
- func (p *Protocol) Connect(activeHeartbeatSignalSender bool)
- func (p *Protocol) GetHeartbeatInterval() uint8
- func (p *Protocol) GetHeartbeatLastReceived() int64
- func (p *Protocol) GetHeartbeatLastSend() int64
- func (p *Protocol) GetHeartbeatTimeout() uint8
- func (p *Protocol) GetRunningRoutine() int32
- func (p *Protocol) GetTag() string
- func (p *Protocol) Kill()
- func (p *Protocol) SetHeartbeatInterval(interval uint8)
- func (p *Protocol) SetHeartbeatTimeout(timeout uint8)
- func (p *Protocol) SetTag(tag string)
- func (p *Protocol) WaitKilled(timeout int) error
- func (p *Protocol) Write(data []byte) error
Constants ¶
View Source
const ( MaskUNKNOWN = glog.MaskUNKNOWN MaskDEBUG = glog.MaskDEBUG MaskTRACE = glog.MaskTRACE MaskINFO = glog.MaskINFO MaskWARNING = glog.MaskWARNING MaskERROR = glog.MaskERROR MaskFATAL = glog.MaskFATAL MaskStd = glog.MaskStd MaskAll = glog.MaskAll MaskDev = MaskFATAL | MaskERROR | MaskWARNING | MaskINFO | MaskTRACE | MaskDEBUG | MaskUNKNOWN MaskProd = MaskFATAL | MaskERROR | MaskWARNING )
View Source
const ( FlagDate = glog.FlagDate FlagTime = glog.FlagTime FlagLongFile = glog.FlagLongFile FlagShortFile = glog.FlagShortFile FlagFunc = glog.FlagFunc FlagPrefix = glog.FlagPrefix FlagSuffix = glog.FlagSuffix FlagStd = glog.FlagStd FlagAll = glog.FlagAll FlagDev = FlagDate | FlagTime | FlagShortFile | FlagFunc | FlagPrefix | FlagSuffix FlagProd = FlagDate | FlagTime | FlagPrefix )
View Source
const VERSION uint8 = 1
Variables ¶
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 ErrorTimeout = errors.New("timeout")
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")
Functions ¶
func GetDataMaxSize ¶
func GetDataMaxSize() int
func SetLogFlag ¶
func SetLogFlag(f uint32)
func SetLogMask ¶
func SetLogMask(mask uint32)
func SetLogProd ¶
func SetLogProd(isProd bool)
Types ¶
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
func New ¶
func New(tag string, r io.Reader, w io.Writer, writeQueueSize int, readCallback func(data []byte), heartbeatTimeoutCallback func(p *Protocol) bool, setFuncBeforeRead func(), setFuncAfterRead func(error), setFuncBeforeWrite func(), setFuncAfterWrite func(error), killCallback func()) *Protocol
New 返回一个protocol实例
tag: 标签,用于区分protocol实例 r: 数据流的reader w: 数据流的writer writeQueueSize: 发送等待队列长度 readCallback: 用于处理获取到的数据,每个package中的数据都会完整的保存在data中 heartbeatTimeoutCallback: 心跳请求超时后的处理函数 setFuncBeforeRead: 在reader读取数据前,设置reader的读取截止时间 setFuncBeforeWrite: 在writer发送数据前,设置writer的发送截止时间 killCallback: status被标记为statusKilled时执行,可以用于关闭reader和writer
func (*Protocol) GetHeartbeatInterval ¶
func (*Protocol) GetHeartbeatLastReceived ¶
func (*Protocol) GetHeartbeatLastSend ¶
func (*Protocol) GetHeartbeatTimeout ¶
func (*Protocol) GetRunningRoutine ¶
func (*Protocol) SetHeartbeatInterval ¶
func (*Protocol) SetHeartbeatTimeout ¶
func (*Protocol) WaitKilled ¶
Click to show internal directories.
Click to hide internal directories.