-
Notifications
You must be signed in to change notification settings - Fork 24
/
queue.go
56 lines (41 loc) · 1.21 KB
/
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
49
50
51
52
53
54
55
56
/*
* @Author: Malin Xie
* @Description:
* @Date: 2020-08-28 20:06:46
*/
package bigqueue
// Queue inteface to define the all necessary functions
type Queue interface {
// Determines whether a queue is empty
// return ture if empty, false otherwise
IsEmpty() bool
// return avaiable queue size
Size() int64
// Append an item to the queue and return index no
// if any error ocurres a non-nil error returned
Enqueue(data []byte) (int64, error)
EnqueueAsync(data []byte, fn func(int64, error))
Dequeue() (int64, []byte, error)
Peek() (int64, []byte, error)
// To skip deqeue target number of items
Skip(count int64) error
Close() error
// Delete all used data files to free disk space.
Gc() error
// Set to asynchous subscribe
Subscribe(fn func(int64, []byte, error)) error
// to free asynchous subscribe
FreeSubscribe()
}
// I/O queue inteface to define the all necessary functions
type IOQueue interface {
Queue
// Open queue from file io info
Open(dir string, queueName string, options *Options) error
}
// RemoteQueue remote server queue inteface to define the all necessary functions
type RemoteQueue interface {
Queue
// Open queue from remote server
Open(serverUrl string, queueName string)
}