history

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2019 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reverse

func Reverse(results []Item)

Reverse reverses an []Item, in-place.

Types

type Buffer

type Buffer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Buffer is a ring buffer holding message/event history for a channel or user

func NewHistoryBuffer

func NewHistoryBuffer(size int) (result *Buffer)

func (*Buffer) Add

func (list *Buffer) Add(item Item)

Add adds a history item to the buffer

func (*Buffer) Between

func (list *Buffer) Between(after, before time.Time, ascending bool, limit int) (results []Item, complete bool)

Between returns all history items with a time `after` <= time <= `before`, with an indication of whether the results are complete or are missing items because some of that period was discarded. A zero value of `before` is considered higher than all other times.

func (*Buffer) Enabled

func (list *Buffer) Enabled() bool

Enabled returns whether the buffer is currently storing messages (a disabled buffer blackholes everything it sees)

func (*Buffer) Initialize

func (hist *Buffer) Initialize(size int)

func (*Buffer) LastDiscarded

func (list *Buffer) LastDiscarded() time.Time

LastDiscarded returns the latest time of any entry that was evicted from the ring buffer.

func (*Buffer) Latest

func (list *Buffer) Latest(limit int) (results []Item)

Latest returns the items most recently added, up to `limit`. If `limit` is 0, it returns all items.

func (*Buffer) Match

func (list *Buffer) Match(predicate Predicate, ascending bool, limit int) (results []Item)

Match returns all history items such that `predicate` returns true for them. Items are considered in reverse insertion order if `ascending` is false, or in insertion order if `ascending` is true, up to a total of `limit` matches if `limit` > 0 (unlimited otherwise). `predicate` MAY be a closure that maintains its own state across invocations; it MUST NOT acquire any locks or otherwise do anything weird. Results are always returned in insertion order.

func (*Buffer) Resize

func (list *Buffer) Resize(size int)

Resize shrinks or expands the buffer

type Item

type Item struct {
	Type ItemType

	Nick string
	// this is the uncasefolded account name, if there's no account it should be set to "*"
	AccountName string
	// for non-privmsg items, we may stuff some other data in here
	Message utils.SplitMessage
	Tags    map[string]string
	Params  [1]string
}

Item represents an event (e.g., a PRIVMSG or a JOIN) and its associated data

func (*Item) HasMsgid

func (item *Item) HasMsgid(msgid string) bool

HasMsgid tests whether a message has the message id `msgid`.

type ItemType

type ItemType uint
const (
	Privmsg ItemType
	Notice
	Join
	Part
	Kick
	Quit
	Mode
	Tagmsg
	Nick
)

type Predicate

type Predicate func(item Item) (matches bool)

Jump to

Keyboard shortcuts

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