Documentation ¶
Index ¶
Constants ¶
const MaxBlockSize = 32 * 1024 * 1024
MaxBlockSize is the maximum size of the block persistent queue can work with.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FastQueue ¶
type FastQueue struct {
// contains filtered or unexported fields
}
FastQueue is a wrapper around Queue, which prefers sending data via memory.
It falls back to sending data via file when readers don't catch up with writers.
func MustOpenFastQueue ¶
MustOpenFastQueue opens persistent queue at the given path.
It holds up to maxInmemoryBlocks in memory before falling back to file-based persistence.
if maxPendingBytes is 0, then the queue size is unlimited. Otherwise its size is limited by maxPendingBytes. The oldest data is dropped when the queue reaches maxPendingSize.
func (*FastQueue) GetInmemoryQueueLen ¶
GetInmemoryQueueLen returns the length of inmemory queue.
func (*FastQueue) GetPendingBytes ¶
GetPendingBytes returns the number of pending bytes in the fq.
func (*FastQueue) MustClose ¶
func (fq *FastQueue) MustClose()
MustClose unblocks all the readers.
It is expected no new writers during and after the call.
func (*FastQueue) MustReadBlock ¶
MustReadBlock reads the next block from fq to dst and returns it.
func (*FastQueue) MustWriteBlock ¶
MustWriteBlock writes block to fq.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue represents persistent queue.
func MustOpen ¶
MustOpen opens persistent queue from the given path.
If maxPendingBytes is greater than 0, then the max queue size is limited by this value. The oldest data is deleted when queue size exceeds maxPendingBytes.
func (*Queue) GetPendingBytes ¶
GetPendingBytes returns the number of pending bytes in the queue.
func (*Queue) MustClose ¶
func (q *Queue) MustClose()
MustClose closes q.
It unblocks all the MustReadBlock calls.
MustWriteBlock mustn't be called during and after the call to MustClose.
func (*Queue) MustReadBlock ¶
MustReadBlock appends the next block from q to dst and returns the result.
false is returned after MustClose call.
It is safe calling this function from concurrent goroutines.
func (*Queue) MustWriteBlock ¶
MustWriteBlock writes block to q.
The block size cannot exceed MaxBlockSize.
It is safe calling this function from concurrent goroutines.
func (*Queue) ResetIfEmpty ¶ added in v1.34.2
func (q *Queue) ResetIfEmpty()
ResetIfEmpty resets q if it is empty.
This is needed in order to remove chunk file associated with empty q.