inmem

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package inmem is an in-memory, "dummy" implementation of the broker API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchSpawnIterator

type BatchSpawnIterator struct {
	Messages       []broker.Message
	AmountToReturn int
	BatchSize      int
	Timeout        time.Duration
	ErrorToReturn  error
}

BatchSpawnIterator is a batched variant of MessageSpawnIterator.

func (*BatchSpawnIterator) NextBatch

func (it *BatchSpawnIterator) NextBatch(ctx context.Context) ([]broker.Message, error)

type MessageSpawnIterator

type MessageSpawnIterator struct {
	Messages       []broker.Message
	AmountToReturn int
	Timeout        time.Duration
	ErrorToReturn  error
}

MessageSpawnIterator returns messages with incrementing IDs starting 0 and going to AmountToReturn-1. The messages are also stored in an internal slice.

func (*MessageSpawnIterator) NextMessage

func (it *MessageSpawnIterator) NextMessage(ctx context.Context) (broker.Message, error)

NextMessage returns a message and can block for Timeout to simulate some delay. When the IDs are exhausted, it returns a predefined error (for example, context.Canceled).

type Publisher

type Publisher struct {
	Spawned []*Topic
	// contains filtered or unexported fields
}

func (*Publisher) GetAllPublished

func (p *Publisher) GetAllPublished() []broker.OutboundMessage

func (*Publisher) MatchesPublished

func (p *Publisher) MatchesPublished(expected ...broker.Message) bool

func (*Publisher) Topic

func (p *Publisher) Topic(topicID string) (broker.Topic, error)

type Topic

type Topic struct {
	TopicID   string
	Published []broker.OutboundMessage
	// contains filtered or unexported fields
}

func (*Topic) BatchPublish

func (m *Topic) BatchPublish(_ context.Context, messages ...broker.OutboundMessage) error

func (*Topic) Publish

func (m *Topic) Publish(_ context.Context, message broker.OutboundMessage) error

Jump to

Keyboard shortcuts

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