Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InMemoryQueueStorage ¶
type InMemoryQueueStorage struct {
// MaxSize defines the capacity of the queue.
// New requests are discarded if the queue size reaches MaxSize
MaxSize int
// contains filtered or unexported fields
}
InMemoryQueueStorage is the default implementation of the Storage interface. InMemoryQueueStorage holds the request queue in memory.
func (*InMemoryQueueStorage) AddRequest ¶
func (q *InMemoryQueueStorage) AddRequest(r []byte) error
AddRequest implements Storage.AddRequest() function
func (*InMemoryQueueStorage) GetRequest ¶
func (q *InMemoryQueueStorage) GetRequest() ([]byte, error)
GetRequest implements Storage.GetRequest() function
func (*InMemoryQueueStorage) Init ¶
func (q *InMemoryQueueStorage) Init() error
Init implements Storage.Init() function
func (*InMemoryQueueStorage) QueueSize ¶
func (q *InMemoryQueueStorage) QueueSize() (int, error)
QueueSize implements Storage.QueueSize() function
type Queue ¶
type Queue struct {
// Threads defines the number of consumer threads
Threads int
// contains filtered or unexported fields
}
Queue is a request queue which uses a Collector to consume requests in multiple threads
func New ¶
New creates a new queue with a Storage specified in argument A standard InMemoryQueueStorage is used if Storage argument is nil.
func (*Queue) AddRequest ¶
AddRequest adds a new Request to the queue
type Storage ¶
type Storage interface {
// Init initializes the storage
Init() error
// AddRequest adds a serialized request to the queue
AddRequest([]byte) error
// GetRequest pops the next request from the queue
// or returns error if the queue is empty
GetRequest() ([]byte, error)
// QueueSize returns with the size of the queue
QueueSize() (int, error)
}
Storage is the interface of the queue's storage backend