Documentation ¶
Index ¶
- func Reverse(results []Item)
- type Buffer
- func (list *Buffer) Add(item Item)
- func (list *Buffer) Between(after, before time.Time, ascending bool, limit int) (results []Item, complete bool)
- func (list *Buffer) Enabled() bool
- func (hist *Buffer) Initialize(size int, window time.Duration)
- func (list *Buffer) LastDiscarded() time.Time
- func (list *Buffer) Latest(limit int) (results []Item)
- func (list *Buffer) Match(predicate Predicate, ascending bool, limit int) (results []Item)
- func (list *Buffer) Resize(maximumSize int, window time.Duration)
- type Item
- type ItemType
- type Predicate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Buffer ¶
Buffer is a ring buffer holding message/event history for a channel or user
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 ¶
Enabled returns whether the buffer is currently storing messages (a disabled buffer blackholes everything it sees)
func (*Buffer) LastDiscarded ¶
LastDiscarded returns the latest time of any entry that was evicted from the ring buffer.
func (*Buffer) Latest ¶
Latest returns the items most recently added, up to `limit`. If `limit` is 0, it returns all items.
func (*Buffer) Match ¶
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.
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