2013-08-30 12:36:57 +08:00
|
|
|
package worker
|
|
|
|
|
|
|
|
const (
|
2013-12-26 12:32:27 +08:00
|
|
|
Network = "tcp"
|
2013-08-30 12:36:57 +08:00
|
|
|
// queue size
|
2013-12-26 12:32:27 +08:00
|
|
|
queueSize = 8
|
2013-08-30 12:36:57 +08:00
|
|
|
// read buffer size
|
2013-12-26 12:32:27 +08:00
|
|
|
bufferSize = 1024
|
2013-08-30 12:36:57 +08:00
|
|
|
// min packet length
|
2013-12-26 12:32:27 +08:00
|
|
|
minPacketLength = 12
|
2013-08-30 12:36:57 +08:00
|
|
|
|
|
|
|
// \x00REQ
|
2013-12-26 15:55:16 +08:00
|
|
|
req = 5391697
|
2013-12-26 12:32:27 +08:00
|
|
|
reqStr = "\x00REQ"
|
2013-08-30 12:36:57 +08:00
|
|
|
// \x00RES
|
2013-12-26 15:55:16 +08:00
|
|
|
res = 5391699
|
2013-12-26 12:32:27 +08:00
|
|
|
resStr = "\x00RES"
|
2013-08-30 12:36:57 +08:00
|
|
|
|
|
|
|
// package data type
|
2013-12-26 12:32:27 +08:00
|
|
|
dtCanDo = 1
|
|
|
|
dtCantDo = 2
|
|
|
|
dtResetAbilities = 3
|
|
|
|
dtPreSleep = 4
|
2013-12-26 15:55:16 +08:00
|
|
|
dtNoop = 6
|
2013-12-26 12:32:27 +08:00
|
|
|
dtJobCreated = 8
|
|
|
|
dtGrabJob = 9
|
|
|
|
dtNoJob = 10
|
|
|
|
dtJobAssign = 11
|
|
|
|
dtWorkStatus = 12
|
|
|
|
dtWorkComplete = 13
|
|
|
|
dtWorkFail = 14
|
|
|
|
dtGetStatus = 15
|
|
|
|
dtEchoReq = 16
|
|
|
|
dtEchoRes = 17
|
2013-12-26 15:55:16 +08:00
|
|
|
dtError = 19
|
2013-12-26 12:32:27 +08:00
|
|
|
dtStatusRes = 20
|
2013-12-26 15:55:16 +08:00
|
|
|
dtSetClientId = 22
|
|
|
|
dtCanDoTimeout = 23
|
2013-12-26 12:32:27 +08:00
|
|
|
dtAllYours = 24
|
|
|
|
dtWorkException = 25
|
|
|
|
dtWorkData = 28
|
|
|
|
dtWorkWarning = 29
|
2013-12-26 15:55:16 +08:00
|
|
|
dtGrabJobUniq = 30
|
|
|
|
dtJobAssignUniq = 31
|
2013-08-30 12:36:57 +08:00
|
|
|
)
|
2013-08-30 18:01:10 +08:00
|
|
|
|
|
|
|
func getBuffer(l int) (buf []byte) {
|
|
|
|
// TODO add byte buffer pool
|
|
|
|
buf = make([]byte, l)
|
|
|
|
return
|
|
|
|
}
|