sublist

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2015 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    `json:"num_subscriptions"`
	NumCache     uint32    `json:"num_cache"`
	NumInserts   uint64    `json:"num_inserts"`
	NumRemoves   uint64    `json:"num_removes"`
	NumMatches   uint64    `json:"num_matches"`
	CacheHitRate float64   `json:"cache_hit_rate"`
	MaxFanout    uint32    `json:"max_fanout"`
	AvgFanout    float64   `json:"avg_fanout"`
	StatsTime    time.Time `json:"stats_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