gsl

package
v2.10.26-RC.3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSubject    = errors.New("gsl: invalid subject")
	ErrNotFound          = errors.New("gsl: no matches found")
	ErrNilChan           = errors.New("gsl: nil channel")
	ErrAlreadyRegistered = errors.New("gsl: notification already registered")
)

Sublist related errors

Functions

func IntersectStree

func IntersectStree[T1 any, T2 comparable](st *stree.SubjectTree[T1], sl *GenericSublist[T2], cb func(subj []byte, entry *T1))

IntersectStree will match all items in the given subject tree that have interest expressed in the given sublist. The callback will only be called once for each subject, regardless of overlapping subscriptions in the sublist.

Types

type GenericSublist

type GenericSublist[T comparable] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

A GenericSublist stores and efficiently retrieves subscriptions.

func NewSublist

func NewSublist[T comparable]() *GenericSublist[T]

NewSublist will create a default sublist with caching enabled per the flag.

func (*GenericSublist[T]) Count

func (s *GenericSublist[T]) Count() uint32

Count returns the number of subscriptions.

func (*GenericSublist[T]) HasInterest

func (s *GenericSublist[T]) HasInterest(subject string) bool

HasInterest will return whether or not there is any interest in the subject. In cases where more detail is not required, this may be faster than Match.

func (*GenericSublist[T]) Insert

func (s *GenericSublist[T]) Insert(subject string, value T) error

Insert adds a subscription into the sublist

func (*GenericSublist[T]) Match

func (s *GenericSublist[T]) Match(subject string, cb func(T))

Match will match all entries to the literal subject. It will return a set of results for both normal and queue subscribers.

func (*GenericSublist[T]) MatchBytes

func (s *GenericSublist[T]) MatchBytes(subject []byte, cb func(T))

MatchBytes will match all entries to the literal subject. It will return a set of results for both normal and queue subscribers.

func (*GenericSublist[T]) NumInterest

func (s *GenericSublist[T]) NumInterest(subject string) (np int)

NumInterest will return the number of subs interested in the subject. In cases where more detail is not required, this may be faster than Match.

func (*GenericSublist[T]) Remove

func (s *GenericSublist[T]) Remove(subject string, value T) error

Remove will remove a subscription.

Jump to

Keyboard shortcuts

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