mux

package
v3.32.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

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

func New(c workerpool.Component, ps events.PubSub, opts ...Option) events.PubSub

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

type Matcher interface {
	Matches(name string) bool
}

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

func MatchNames(names ...string) Matcher

MatchNames is a matcher that matches specific event names.

func MatchPatterns

func MatchPatterns(patterns ...string) (Matcher, error)

MatchPatterns is a matcher that matches event names based on patterns.

type MatcherFunc

type MatcherFunc func(name string) bool

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.

Jump to

Keyboard shortcuts

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