minibus

package
v0.2024.5 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package minibus implements a minimalist many-to-many event bus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DropExcess

func DropExcess[T any](in <-chan T) <-chan T

DropExcess will wrap a channel to break backpressure between its input and output. It will drop incoming messages when the consumer can't process them fast enough. When the consumer receives, it will always get the most recent message sent by the producer.

Types

type Bus

type Bus[T any] struct {
	// contains filtered or unexported fields
}

func (*Bus[T]) Listen

func (b *Bus[T]) Listen(ctx context.Context) <-chan T

func (*Bus[T]) Send

func (b *Bus[T]) Send(ctx context.Context, event T) int

Send sends a message to all active listeners and returns how many listeners accepted the event.

Jump to

Keyboard shortcuts

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