go-vitess.v1: gopkg.in/src-d/go-vitess.v1/history Index | Files

package history

import "gopkg.in/src-d/go-vitess.v1/history"

Package history implements a circular buffer with adjacent-item deduplication.

Index

Package Files

history.go

type Deduplicable Uses

type Deduplicable interface {
    // IsDuplicate returns true if other is considered to be a
    // duplicate of the calling instance.
    IsDuplicate(interface{}) bool
}

Deduplicable is an interface that records should implement if the history should perform their deduplication. An example would be deduplicating records whose only difference is their timestamp.

type History Uses

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

History is a data structure that allows you to keep some number of records.

func New Uses

func New(length int) *History

New returns a History with the specified maximum length.

func (*History) Add Uses

func (history *History) Add(record interface{})

Add a new record in a threadsafe manner. If record implements Deduplicable, and IsDuplicate returns true when called on the last previously added record, it will not be added.

func (*History) Latest Uses

func (history *History) Latest() interface{}

Latest returns the record most recently passed to Add(), regardless of whether it was actually added or dropped as a duplicate.

func (*History) Records Uses

func (history *History) Records() []interface{}

Records returns the kept records in reverse chronological order in a threadsafe manner.

Package history imports 1 packages (graph) and is imported by 4 packages. Updated 2019-06-13. Refresh now. Tools for package owners.