multiplex

package
v0.0.0-...-12a582f Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMarshallingMessage is returned when an error occurs marshalling a message to JSON
	ErrMarshallingMessage = errors.New("error marshalling message to JSON")

	// ErrSendingMessage is returned when an error occurs sending a message to the destination
	ErrSendingMessage = errors.New("error sending message to destination")
)

Functions

func WithBehavior

func WithBehavior(behavior Behavior) func(*Multiplexer) *Multiplexer

func WithConfig

func WithConfig(cfg *Config) func(*Multiplexer) *Multiplexer

func WithDestination

func WithDestination(destination publishers.Publisher) func(*Multiplexer) *Multiplexer

func WithLimit

func WithLimit(limit int) func(*Multiplexer) *Multiplexer

func WithReadOnly

func WithReadOnly() func(*Multiplexer) *Multiplexer

func WithReadWrite

func WithReadWrite() func(*Multiplexer) *Multiplexer

func WithSource

func WithSource(source subscribers.Subscriber) func(*Multiplexer) *Multiplexer

func WithWriteOnly

func WithWriteOnly() func(*Multiplexer) *Multiplexer

Types

type Behavior

type Behavior int
const (
	Unknown Behavior = iota
	ReadWrite
	Read
	Write
)

func BehaviorFromString

func BehaviorFromString(s string) (Behavior, error)

func (Behavior) String

func (b Behavior) String() string

type Config

type Config struct {
	// Limit is the maximum number of messages to send
	// to the destination publisher before ending
	Limit int `json:"limit"`

	// Behavior is the behavior to use when sending messages
	Behavior Behavior `json:"behavior"`
}

func NewConfig

func NewConfig() *Config

func NewDefaultConfig

func NewDefaultConfig() *Config

type Multiplexer

type Multiplexer struct {

	// config settings
	Behavior Behavior
	Limit    int
	// contains filtered or unexported fields
}

func NewMultiplexer

func NewMultiplexer(
	source subscribers.Subscriber,
	destination publishers.Publisher,
) *Multiplexer

func (*Multiplexer) Apply

func (m *Multiplexer) Apply(cfg *Config)

func (*Multiplexer) Run

func (m *Multiplexer) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

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