sublist

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2014 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Sublist is a subject distribution data structure that can match subjects to interested subscribers. Subscribers can have wildcard subjects to match multiple published subjects.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSubject = errors.New("Invalid Subject")
	ErrNotFound       = errors.New("No Matches Found")
)

Functions

func IsValidLiteralSubject

func IsValidLiteralSubject(subject []byte) bool

Types

type Stats

type Stats struct {
	NumSubs      uint32
	NumCache     uint32
	NumInserts   uint64
	NumRemoves   uint64
	NumMatches   uint64
	CacheHitRate float64
	MaxFanout    uint32
	AvgFanout    float64
	StatsTime    time.Time
}

Stats for the sublist

type Sublist

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

A Sublist stores and efficiently retrieves subscriptions. It uses a tree structure and an efficient RR cache to achieve quick lookups.

func New

func New() *Sublist

New will create a default sublist

func (*Sublist) Count

func (s *Sublist) Count() uint32

Count return the number of stored items in the HashMap.

func (*Sublist) Insert

func (s *Sublist) Insert(subject []byte, sub interface{}) error

func (*Sublist) Match

func (s *Sublist) Match(subject []byte) []interface{}

Match will match all entries to the literal subject. It will return a slice of results.

func (*Sublist) Remove

func (s *Sublist) Remove(subject []byte, sub interface{}) error

Remove will remove any item associated with key. It will track descent into the trie and prune upon successful removal.

func (*Sublist) ResetStats

func (s *Sublist) ResetStats()

ResetStats will clear stats and update StatsTime to time.Now()

func (*Sublist) Stats

func (s *Sublist) Stats() *Stats

Stats will return a stats structure for the current state.

Jump to

Keyboard shortcuts

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