forked from go-stomp/stomp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage.go
34 lines (28 loc) · 1.02 KB
/
storage.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
package queue
import (
"github.com/go-stomp/stomp/frame"
)
// Interface for queue storage. The intent is that
// different queue storage implementations can be
// used, depending on preference. Queue storage
// mechanisms could include in-memory, and various
// persistent storage mechanisms (eg file system, DB, etc)
type Storage interface {
// Pushes a MESSAGE frame to the end of the queue. Sets
// the "message-id" header of the frame before adding to
// the queue.
Enqueue(queue string, frame *frame.Frame) error
// Pushes a MESSAGE frame to the head of the queue. Sets
// the "message-id" header of the frame if it is not
// already set.
Requeue(queue string, frame *frame.Frame) error
// Removes a frame from the head of the queue.
// Returns nil if no frame is available.
Dequeue(queue string) (*frame.Frame, error)
// Called at server startup. Allows the queue storage
// to perform any initialization.
Start()
// Called prior to server shutdown. Allows the queue storage
// to perform any cleanup.
Stop()
}