singlechannel

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrChannelFull = errors.Wrap(ErrSendFailed, "channel is full")
View Source
var ErrSendFailed = errors.New("send failed")

Functions

This section is empty.

Types

type ChannelStream

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

func (ChannelStream[T]) Channel

func (c ChannelStream[T]) Channel() <-chan T

func (ChannelStream[T]) Next

func (c ChannelStream[T]) Next(ctx context.Context) (message T, hasNext bool, err error)

func (ChannelStream[T]) Unsubscribe

func (c ChannelStream[T]) Unsubscribe()

type Topic

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

func NewTopic

func NewTopic[T any]() *Topic[T]

NewTopic returns a new instance of Topic WARNING: This is intended for testing only This Topic does not support multiple subscribers

func (*Topic[T]) Publish

func (c *Topic[T]) Publish(ctx context.Context, message T) (err error)

Publish sends a message to the given topic. If the topic doesn't exist it and a matching channel will be created.

func (*Topic[T]) Subscribe

func (c *Topic[T]) Subscribe(_ context.Context) (messaging.Stream[T], error)

Subscribe returns a channel that will receive messages published to the given topic. WARNING: This is intended for testing only This Topic does not support multiple subscribers Messages will be consumed by the first subscriber If multiple subscribers receive the stream messages will be load balanced by Go channel consumption semantics

Jump to

Keyboard shortcuts

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