queue

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2019 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	Key string
	Val interface{}
}

Item represents an entry for the queue

type Options

type Options struct {
	Rate      time.Duration
	BatchSize int
}

Options declares queue mangement options

type Queue

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

Queue handles document indexing

func New

func New(
	logger *zap.SugaredLogger,
	flushFunc func([]*Item) error,
	closeFunc func() error,
	opts Options,
) *Queue

New instantiates a new queue. flushFunc is is used for periodic index flusing, and closeFunc will be used when closing. flushFunc should add items with values, and delete items without values. Nil items are possible.

The goal is to batch index updates on a single thread.

func (*Queue) Close

func (q *Queue) Close()

Close stops the queue runner and releases queue assets

func (*Queue) IsStopped

func (q *Queue) IsStopped() bool

IsStopped checks if the queue is still running and active

func (*Queue) Queue

func (q *Queue) Queue(item *Item) error

Queue indicates that a new item is pending insertion. A nil value indicates the item should be deleted.

func (*Queue) Run

func (q *Queue) Run()

Run maintains the queue and executes flushes as necessary

Jump to

Keyboard shortcuts

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