-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathqueue.go
More file actions
29 lines (23 loc) · 767 Bytes
/
queue.go
File metadata and controls
29 lines (23 loc) · 767 Bytes
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
package queue
// Backend defines interface to manage queues. ChannelBackend is default.
type Backend interface {
Put(queueName string, value interface{}) error
Get(queueName string, value interface{}) error
RemoveQueue(queueName string) error
}
var b Backend = NewChannelBackend()
// Use sets backend to manage queues. ChannelBackend is default.
func Use(value Backend) {
b = value
}
// Put adds value to the end of a queue.
func Put(queueName string, value interface{}) error {
return b.Put(queueName, value)
}
// Get removes the first element from a queue and put it in the value pointed to by v
func Get(queueName string, v interface{}) error {
return b.Get(queueName, v)
}
func RemoveQueue(queueName string) error {
return b.RemoveQueue(queueName)
}