-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqueue.go
38 lines (29 loc) · 944 Bytes
/
queue.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package xqueue
import (
"time"
)
type ResultCode int
func (r ResultCode) String() string {
return resultStr[r]
}
const (
ResultFailed ResultCode = iota + 1 // 消费失败, 需要重传, 不进行ACK
ResultInvalidMessage // 消费负载异常, 不需要重传, 进行ACK
ResultRetryOverLimit // 重传消费超过限制次数, 不再重传, 进行ACK
ResultSuccess // 消费成功, 不再重传, 进行ACK
)
var resultStr = map[ResultCode]string{
ResultInvalidMessage: "invalid message",
ResultFailed: "fail",
ResultRetryOverLimit: "retry over limit",
ResultSuccess: "success",
}
const (
DefaultWorkersPoolSize = 1 << 2 // 默认工作池大小.
ExpiryDuration = 10 * time.Second // 清理回收周期.
Nonblocking = false // 阻塞, 无可用协程则等待.
)
type Provider interface {
ConsumerProvider
ProducerProvider
}