fake

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
}

Clock abstracts the time package

type EntryStorage

type EntryStorage struct {
	// Clock abstracts the time package
	Clock Clock
	// contains filtered or unexported fields
}

EntryStorage is a simple fake implementation of two outbox interfaces:

  • outbox.ProcessorStorage: for use directly by the outbox.Outbox to process Outbox ClaimedEntry objects
  • outbox.Publisher: for applications to treat as the outbox.Outbox that records their messages during a transaction

func (*EntryStorage) ClaimEntries

func (e *EntryStorage) ClaimEntries(_ context.Context, processorID string, claimDeadline time.Time) error

ClaimEntries implements outbox.ProcessorStorage interface

func (*EntryStorage) CountEntries

func (e *EntryStorage) CountEntries() int

CountEntries is a test function for counting the number of entries currently in storage

func (*EntryStorage) DeleteEntries

func (e *EntryStorage) DeleteEntries(_ context.Context, entryIDs ...string) error

DeleteEntries implements outbox.ProcessorStorage interface

func (*EntryStorage) GetClaimedEntries

func (e *EntryStorage) GetClaimedEntries(_ context.Context, processorID string, batchSize int) ([]outbox.ClaimedEntry, error)

GetClaimedEntries implements outbox.ProcessorStorage interface

func (*EntryStorage) Publish

func (e *EntryStorage) Publish(ctx context.Context, _ interface{}, messages ...outbox.Message) error

Publish records the provided messages to the outbox.ProcessorStorage

type PublishedMessage

type PublishedMessage struct {
	outbox.Message

	Namespace string
}

type Publisher

type Publisher struct {
	// Logger can be provided to receive log output
	Logger logr.Logger
	// contains filtered or unexported fields
}

Publisher is a simple in-memory fake for publishing messages. As it doesn't actually deliver messages anywhere, even in-memory particularly, it's almost a mock instead of a fake, but it does function without configuration from the caller's point of view.

func (*Publisher) Clear

func (p *Publisher) Clear() []PublishedMessage

Clear wipes the internal state of the Publisher as if nothing had ever been published. It returns the previously published Message objects for convenience.

func (*Publisher) GetPublished

func (p *Publisher) GetPublished() []PublishedMessage

GetPublished retrieves a copy of the published messages

func (*Publisher) GetPublishedCount

func (p *Publisher) GetPublishedCount() int

GetPublishedCount retrieves a count of published messages

func (*Publisher) Publish

func (p *Publisher) Publish(ctx context.Context, messages ...outbox.Message) error

Publish implements the outbox.Publisher interface

Jump to

Keyboard shortcuts

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