mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-28 01:44:47 +08:00
新增自定义持久化的消息队列
This commit is contained in:
36
sysservice/messagequeueservice/MemoryQueue_test.go
Normal file
36
sysservice/messagequeueservice/MemoryQueue_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package messagequeueservice
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type In int
|
||||
|
||||
func (i In) GetValue() int {
|
||||
return int(i)
|
||||
}
|
||||
|
||||
func Test_BiSearch(t *testing.T) {
|
||||
var memQueue MemoryQueue
|
||||
memQueue.Init(5)
|
||||
|
||||
for i := 1; i <= 8; i++ {
|
||||
memQueue.Push(&TopicData{Seq: uint64(i)})
|
||||
}
|
||||
|
||||
startindex := uint64(0)
|
||||
for {
|
||||
retData, ret := memQueue.FindData(startindex+1, 10)
|
||||
fmt.Println(retData, ret)
|
||||
for _, d := range retData {
|
||||
if d.Seq > startindex {
|
||||
startindex = d.Seq
|
||||
}
|
||||
}
|
||||
if ret == false {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user