forked from didapinchegit/go_rocket_mq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
message_queue.go
48 lines (39 loc) · 823 Bytes
/
message_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
39
40
41
42
43
44
45
46
47
48
package rocketmq
type MessageQueue struct {
topic string
brokerName string
queueId int32
}
func (self *MessageQueue) clone() *MessageQueue {
no := new(MessageQueue)
no.topic = self.topic
no.queueId = self.queueId
no.brokerName = self.brokerName
return no
}
type MessageQueues []*MessageQueue
func (self MessageQueues) Less(i, j int) bool {
imq := self[i]
jmq := self[j]
if imq.topic < jmq.topic {
return true
} else if imq.topic < jmq.topic {
return false
}
if imq.brokerName < jmq.brokerName {
return true
} else if imq.brokerName < jmq.brokerName {
return false
}
if imq.queueId < jmq.queueId {
return true
} else {
return false
}
}
func (self MessageQueues) Swap(i, j int) {
self[i], self[j] = self[j], self[i]
}
func (self MessageQueues) Len() int {
return len(self)
}