pubsubcontract

package
v0.300.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DrainTimeout = 256 * time.Millisecond

Functions

func Blocking

func Blocking[Data any](publisher pubsub.Publisher[Data], subscriber pubsub.Subscriber[Data], opts ...Option[Data]) contract.Contract

func Buffered

func Buffered[Data any](publisher pubsub.Publisher[Data], subscriber pubsub.Subscriber[Data], opts ...Option[Data]) contract.Contract

Buffered defines a publisher behaviour where if the subscription is canceled, the publisher messages can be still consumed after resubscribing.

func FIFO

func FIFO[Data any](publisher pubsub.Publisher[Data], subscriber pubsub.Subscriber[Data], opts ...Option[Data]) contract.Contract

FIFO

It stands for First-In-First-Out approach. In this, the new element is inserted below the existing element, So that the oldest element can be at the top and taken out first. Therefore, the first element to be entered in this approach, gets out First. In computing, FIFO approach is used as an operating system algorithm, which gives every process CPU time in the order they arrive. The data structure that implements FIFO is Queue.

func FanOut

func FanOut[Data any](

	Exchange pubsub.Publisher[Data],

	MakeQueue func(testing.TB) pubsub.Subscriber[Data],
	opts ...Option[Data]) contract.Contract

FanOut defines an exchange behaviour where messages are published to all the associated pubsub.Queue.

func LIFO

func LIFO[Data any](publisher pubsub.Publisher[Data], subscriber pubsub.Subscriber[Data], opts ...Option[Data]) contract.Contract

LIFO

It stands for Last-In-First-Out approach in programming. In this, the new element is inserted above the existing element, So that the newest element can be at the top and taken out first. Therefore, the first element to be entered in this approach, gets out Last. In computing, LIFO approach is used as a queuing theory that refers to the way items are stored in types of data structures. The data structure that implements LIFO is Stack.

func Ordering

func Ordering[Data any](
	publisher pubsub.Publisher[Data],
	subscriber pubsub.Subscriber[Data],

	Sort func([]Data),
	opts ...Option[Data],
) contract.Contract

Ordering is a contract that describes how the ordering should happen with a given

func Queue

func Queue[Data any](publisher pubsub.Publisher[Data], subscriber pubsub.Subscriber[Data], opts ...Option[Data]) contract.Contract

Queue defines a publisher behaviour where each message is only delivered to a single subscriber, and not to all registered subscribers. If a message is ack-ed, the message will be permanently removed from the Queue.

func Volatile

func Volatile[Data any](publisher pubsub.Publisher[Data], subscriber pubsub.Subscriber[Data], opts ...Option[Data]) contract.Contract

Volatile defines a publisher behaviour where if the subscription is canceled, published messages won't be delivered. In certain scenarios, you may want to send a volatile message with no assurances over a publisher, when timely delivery is more important than losing messages.

Types

type Config

type Config[Data any] struct {
	MakeContext func(testing.TB) context.Context
	MakeData    func(testing.TB) Data

	SupportPublishContextCancellation bool
}

func (Config[Data]) Configure

func (c Config[Data]) Configure(t *Config[Data])

func (*Config[Data]) Init

func (c *Config[Data]) Init()

type Option

type Option[Data any] interface {
	option.Option[Config[Data]]
}

type PubSub

type PubSub[Data any] struct {
	pubsub.Publisher[Data]
	pubsub.Subscriber[Data]
}

Jump to

Keyboard shortcuts

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