qcache

package module
v0.0.0-...-c749427 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2021 License: MIT Imports: 11 Imported by: 0

README

qcache

qcache

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTooSmallArenaSize is returned when arena size is smaller than OS page size.
	ErrTooSmallArenaSize = errors.New("too small arena size")
	// ErrTooFewInMemArenas is returned when number of arenas allowed in memory < 3.
	ErrTooFewInMemArenas = errors.New("too few in memory arenas")
)
View Source
var (
	// ErrInvalidArenaSize is returned when persisted arena size
	// doesn't match with desired arena size.
	ErrInvalidArenaSize = errors.New("mismatch in arena size")
	// ErrDifferentQueues is returned when caller wants to copy
	// offsets from a consumer from a different queue.
	ErrDifferentQueues = errors.New("consumers from different queues")
)
View Source
var (
	// ErrEmptyQueue is returned when dequeue is performed on an empty queue.
	ErrEmptyQueue = errors.New("queue is empty")
)
View Source
var (
	// ErrIncompatibleVersion is returned when file format is older/newer.
	ErrIncompatibleVersion = errors.New("incompatible format of the code and data")
)

Functions

This section is empty.

Types

type Consumer

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

Consumer is a bigqueue consumer that allows reading data from bigqueue. A consumer is represented using just a base offset into the metadata

func (*Consumer) Dequeue

func (c *Consumer) Dequeue() ([]byte, error)

Dequeue removes an element from the queue and returns it.

func (*Consumer) DequeueString

func (c *Consumer) DequeueString() (string, error)

DequeueString removes a string element from the queue and returns it.

func (*Consumer) IsEmpty

func (c *Consumer) IsEmpty() bool

IsEmpty returns true when queue is empty for the consumer.

type MmapQueue

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

MmapQueue implements Queue interface.

func NewMmapQueue

func NewMmapQueue(dir string, opts ...Option) (*MmapQueue, error)

NewMmapQueue constructs a new persistent queue.

func (*MmapQueue) Close

func (q *MmapQueue) Close() error

Close will close metadata and arena manager.

func (*MmapQueue) Dequeue

func (q *MmapQueue) Dequeue() ([]byte, error)

Dequeue removes an element from the queue and returns it. This function uses the default consumer to consume from the queue.

func (*MmapQueue) DequeueString

func (q *MmapQueue) DequeueString() (string, error)

DequeueString removes a string element from the queue and returns it. This function uses the default consumer to consume from the queue.

func (*MmapQueue) Enqueue

func (q *MmapQueue) Enqueue(message []byte) error

Enqueue adds a new slice of byte element to the tail of the queue.

func (*MmapQueue) EnqueueString

func (q *MmapQueue) EnqueueString(message string) error

EnqueueString adds a new string element to the tail of the queue.

func (*MmapQueue) Flush

func (q *MmapQueue) Flush() error

Flush syncs the in memory content of bigqueue to disk.

func (*MmapQueue) FromConsumer

func (q *MmapQueue) FromConsumer(name string, from *Consumer) (*Consumer, error)

FromConsumer creates a new consumer or finds an existing one with same name. It also copies the offsets from the given consumer to this consumer.

func (*MmapQueue) IsEmpty

func (q *MmapQueue) IsEmpty() bool

IsEmpty returns true when queue is empty for the default consumer.

func (*MmapQueue) NewConsumer

func (q *MmapQueue) NewConsumer(name string) (*Consumer, error)

NewConsumer creates a new consumer or finds an existing one with same name.

type Option

type Option func(*bqConfig) error

Option is function type that takes a bqConfig object and sets various config parameters in the object.

func SetArenaSize

func SetArenaSize(arenaSize int) Option

SetArenaSize returns an Option closure that sets the arena size.

func SetMaxInMemArenas

func SetMaxInMemArenas(maxInMemArenas int) Option

SetMaxInMemArenas returns an Option closure that sets maximum number of Arenas that could reside in memory (RAM) at any time. By default, all the arenas reside in memory and Operating System takes care of memory by paging in and out the pages from disk. A recommended value of maximum arenas that should be in memory should be chosen such that:

maxInMemArenas > (# of consumers) * 2 + 1

func SetPeriodicFlushDuration

func SetPeriodicFlushDuration(flushPeriod time.Duration) Option

SetPeriodicFlushDuration returns an Option that sets a periodic flush every given duration after which the queue's in-memory changes will be flushed to disk. This is a best effort flush and elapsed time is checked upon an enqueue/dequeue only. If the value is set to <= 0, no periodic flush will be performed.

For durability this value should be low. For performance this value should be high.

func SetPeriodicFlushOps

func SetPeriodicFlushOps(flushMutOps int64) Option

SetPeriodicFlushOps returns an Option that sets the number of mutate operations (enqueue/dequeue) after which the queue's in-memory changes will be flushed to disk. This is a best effort flush and number of mutate operations is checked upon an enqueue/dequeue. If the value is set to <= 0, no periodic flush will be performed.

For durability this value should be low. For performance this value should be high.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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