-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
69 lines (56 loc) · 1.53 KB
/
types.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package rabbitmq
import "time"
// Message captures the fields for a message received from queue.
type Message struct {
Body interface{}
}
// Acknowledge is an action that occurs after processed this message.
type Acknowledge int
const (
// Ack default ack this msg after you have successfully processed this message.
Ack Acknowledge = iota
// NackDiscard the message will be dropped or delivered to a server configured dead-letter queue.
NackDiscard
// NackRequeue deliver this message to a different consumer.
NackRequeue
// None for auto ack option.
None
)
// WorkerHandler defines the worker function with Data message param.
type WorkerHandler func(message Message) (interface{}, Acknowledge)
// SubscribeHandler defines the subscribe function.
type SubscribeHandler func(message Message)
type Worker struct {
handler WorkerHandler
options *WorkerOptions
}
type Subscriber struct {
handler SubscribeHandler
options *SubscribeOptions
}
// WorkerOptions defines options of worker.
type WorkerOptions struct {
AutoAck bool
Durable bool
QOSPrefetch int
QOSGlobal bool
Concurrency int
}
// SubscribeOptions defines options of subscribe.
type SubscribeOptions struct {
Durable bool
Concurrency int
}
// PublishOptions defines options of publish.
type PublishOptions struct {
Durable bool
}
// PushOptions defines options of worker.
type PushOptions struct {
Persistent bool
}
// MessagingOptions defines options of messaging.
type MessagingOptions struct {
Logger Logger
ReconnectInterval time.Duration
}