persistentqueue

package
v1.34.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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

func MustOpenFastQueue(path, name string, maxInmemoryBlocks int) *FastQueue

MustOpenFastQueue opens persistent queue at the given path.

It holds up to maxInmemoryBlocks in memory before falling back to file-based persistence.

func (*FastQueue) GetInmemoryQueueLen

func (fq *FastQueue) GetInmemoryQueueLen() int

GetInmemoryQueueLen returns the length of inmemory queue.

func (*FastQueue) GetPendingBytes

func (fq *FastQueue) GetPendingBytes() uint64

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

func (fq *FastQueue) MustReadBlock(dst []byte) ([]byte, bool)

MustReadBlock reads the next block from fq to dst and returns it.

func (*FastQueue) MustWriteBlock

func (fq *FastQueue) MustWriteBlock(block []byte)

MustWriteBlock writes block to fq.

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue represents persistent queue.

func MustOpen

func MustOpen(path, name string) *Queue

MustOpen opens persistent queue from the given path.

func (*Queue) GetPendingBytes

func (q *Queue) GetPendingBytes() uint64

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

func (q *Queue) MustReadBlock(dst []byte) ([]byte, bool)

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

func (q *Queue) MustWriteBlock(block []byte)

MustWriteBlock writes block to q.

The block size cannot exceed MaxBlockSize.

It is safe calling this function from concurrent goroutines.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL