conveyor

package
v0.0.0-...-be6f5f5 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ShiftDaily roll filter every day
	ShiftDaily = clock.Unit("d")
	// ShiftWeekly roll filter every week
	ShiftWeekly = clock.Unit("w")
	// ShiftMonthly roll filter every month
	ShiftMonthly = clock.Unit("m")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

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

Filter provides fuctionality of working with multiple sequential filters through time

func NewFilter

func NewFilter(namer Namer, unit clock.Unit, period clock.UnitNum) (*Filter, error)

NewFilter creates a new Filter unit - unit of time, e.g. Week, Day or Month. All keys being set during period with a same unit will be stored in a single filter. period - period in specified time units to consider in set operations namer - provides algorithm to name filters according to specified unit of time

func (*Filter) BulkSet

func (rf *Filter) BulkSet(ctx context.Context, cli *bloomd.Client, rr input.KeyReaderReseter) (results bloomd.ResultReader, err error)

BulkSet sets keys to all filters within the configured period it returns result for oldest filter note that it does not check if filter exists

func (*Filter) Check

func (rf *Filter) Check(ctx context.Context, cli *bloomd.Client, k bloomd.Key) (bool, error)

Check sequentially checks filters through period note that it does not check if filters exist

func (*Filter) Clear

func (rf *Filter) Clear(ctx context.Context, cli *bloomd.Client) error

Clear clears all filters through period

func (*Filter) Close

func (rf *Filter) Close(ctx context.Context, cli *bloomd.Client) error

Close closes all filters through period

func (*Filter) CreateFilters

func (rf *Filter) CreateFilters(ctx context.Context, cli *bloomd.Client, advance clock.UnitNum, capacity int, prob float64, inMemory bool) error

CreateFilters creates all filters through a specified period if advance is greater than 0 that it will preallocate filters

func (*Filter) Drop

func (rf *Filter) Drop(ctx context.Context, cli *bloomd.Client) error

Drop drops all filters through period

func (*Filter) DropOlderFilters

func (rf *Filter) DropOlderFilters(ctx context.Context, cli *bloomd.Client, tail clock.UnitNum) error

DropOlderFilters drops all filters that correspond to units older that period if tail is greater that 0 that it will preserve some old filters

func (*Filter) Flush

func (rf *Filter) Flush(ctx context.Context, cli *bloomd.Client) error

Flush flushes all filters through period

func (*Filter) MultiCheck

func (rf *Filter) MultiCheck(ctx context.Context, cli *bloomd.Client, reader bloomd.KeyReader) (resultReader bloomd.ResultReader, err error)

MultiCheck checks keys in the oldest filter note that it does not check if filters exist

func (*Filter) Set

func (rf *Filter) Set(ctx context.Context, cli *bloomd.Client, k bloomd.Key) (result bool, err error)

Set sets key to all filters within the configured period returns result for set into oldest filter note that it does not check if filter exists

type Namer

type Namer interface {
	NameFor(unit clock.UnitNum) string
	ParseUnit(name string) (clock.UnitNum, error)
}

Namer maps filter names to units

Jump to

Keyboard shortcuts

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