Documentation ¶
Overview ¶
Package mux implements an events.PubSub implementation that uses multiplexing for subscriptions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates a multiplexer. Events are always published to the given PubSub; streams are additional, read-only subscribers. If the given PubSub implements events.Store, a store implementation is returned. If the given streams are also stores, the store implementation will be used for fetching history. However, if a stream is not a store, SubscribeWithHistory will call Subscribe for that stream.
Types ¶
type Matcher ¶
Matcher matches event names.
var ( // MatchAll is a matcher that matches all event names. MatchAll Matcher = MatcherFunc(func(string) bool { return true }) // MatchNone is a matcher that matches no event names. MatchNone Matcher = MatcherFunc(func(string) bool { return false }) )
func MatchNames ¶
MatchNames is a matcher that matches specific event names.
func MatchPatterns ¶
MatchPatterns is a matcher that matches event names based on patterns.
type MatcherFunc ¶
MatcherFunc is a function that implements the Matcher interface.
func (MatcherFunc) Matches ¶
func (f MatcherFunc) Matches(name string) bool
Matches implements Matcher.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is an option for the multiplexer.
func WithStream ¶
func WithStream(ps events.Subscriber, matcher Matcher) Option
WithStream creates a new stream with the given matcher and subscriber.