本文整理汇总了Golang中github.com/bogdanovich/siberite/queue.Queue类的典型用法代码示例。如果您正苦于以下问题:Golang Queue类的具体用法?Golang Queue怎么用?Golang Queue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Queue类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: CloseAllQueues
// CloseAllQueues closes all queues
func (repo *QueueRepository) CloseAllQueues() error {
var err error
var q *queue.Queue
for pair := range repo.storage.IterBuffered() {
q, err = repo.GetQueue(pair.Key)
if err != nil {
return err
}
q.Close()
}
return nil
}
开发者ID:holys,项目名称:siberite,代码行数:13,代码来源:repository.go
示例2: CloseAllQueues
func (self *QueueRepository) CloseAllQueues() error {
var err error
var q *queue.Queue
for pair := range self.storage.Iter() {
q, err = self.GetQueue(pair.Key)
if err != nil {
return err
}
q.Close()
}
return nil
}
开发者ID:gitter-badger,项目名称:siberite,代码行数:12,代码来源:repository.go
示例3: FullStats
// FullStats gets repository stats
func (repo *QueueRepository) FullStats() []StatItem {
stats := []StatItem{}
currentTime := time.Now().Unix()
stats = append(stats, StatItem{"uptime", fmt.Sprintf("%d", currentTime-repo.Stats.StartTime)})
stats = append(stats, StatItem{"time", fmt.Sprintf("%d", currentTime)})
stats = append(stats, StatItem{"version", fmt.Sprintf("%s", repo.Stats.Version)})
stats = append(stats, StatItem{"curr_connections", fmt.Sprintf("%d", repo.Stats.CurrentConnections)})
stats = append(stats, StatItem{"total_connections", fmt.Sprintf("%d", repo.Stats.TotalConnections)})
stats = append(stats, StatItem{"cmd_get", fmt.Sprintf("%d", repo.Stats.CmdGet)})
stats = append(stats, StatItem{"cmd_set", fmt.Sprintf("%d", repo.Stats.CmdSet)})
var q *queue.Queue
for pair := range repo.storage.IterBuffered() {
q = pair.Val.(*queue.Queue)
stats = append(stats, StatItem{"queue_" + q.Name + "_items", fmt.Sprintf("%d", q.Length())})
stats = append(stats, StatItem{"queue_" + q.Name + "_open_transactions", fmt.Sprintf("%d", q.Stats.OpenTransactions)})
}
return stats
}
开发者ID:holys,项目名称:siberite,代码行数:19,代码来源:repository.go
示例4: Test_Initialize
func Test_Initialize(t *testing.T) {
repo, err := Initialize(dir)
assert.Nil(t, err)
// Create 3 queues and push some data
queueNames := []string{"test1", "test2", "test3"}
var q *queue.Queue
totalItems := 3
for i := 0; i < len(queueNames); i++ {
q, _ = repo.GetQueue(queueNames[i])
for j := 0; j < totalItems; j++ {
q.Enqueue([]byte("value"))
}
// Get one element out
_, _ = q.Dequeue()
}
// Close all queues and destroy repo
repo.CloseAllQueues()
repo = nil
// Initialize repo again and check loaded queues
repo, err = Initialize(dir)
assert.Nil(t, err)
assert.Equal(t, repo.Count(), 3, "Invalid repo count after initialization")
for i := 0; i < len(queueNames); i++ {
q, _ = repo.GetQueue(queueNames[i])
assert.Equal(t, q.Head(), uint64(1), "Invalid queue initialization")
assert.Equal(t, q.Tail(), uint64(totalItems), "Invalid queue initialization")
assert.Equal(t, q.Length(), uint64(totalItems-1), "Invalid queue initialization")
}
repo.DeleteAllQueues()
}
开发者ID:gitter-badger,项目名称:siberite,代码行数:35,代码来源:repository_test.go
注:本文中的github.com/bogdanovich/siberite/queue.Queue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论