pubsubcontracts

package
v0.128.7 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DrainTimeout = 256 * time.Millisecond

Functions

This section is empty.

Types

type Blocking

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

	RollbackOnPublishCancellation bool
}

func (Blocking[Data]) Benchmark

func (c Blocking[Data]) Benchmark(b *testing.B)

func (Blocking[Data]) Spec

func (c Blocking[Data]) Spec(s *testcase.Spec)

func (Blocking[Data]) Test

func (c Blocking[Data]) Test(t *testing.T)

type Buffered

type Buffered[Data any] struct {
	MakeSubject func(testing.TB) PubSub[Data]
	MakeContext func(testing.TB) context.Context
	MakeData    func(testing.TB) Data
}

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

func (Buffered[Data]) Benchmark

func (c Buffered[Data]) Benchmark(b *testing.B)

func (Buffered[Data]) Spec

func (c Buffered[Data]) Spec(s *testcase.Spec)

func (Buffered[Data]) Test

func (c Buffered[Data]) Test(t *testing.T)

type CreatorPublisher

type CreatorPublisher[Entity, ID any] struct {
	MakeSubject func(testing.TB) CreatorPublisherSubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	MakeEntity  func(testing.TB) Entity
}

func (CreatorPublisher[Entity, ID]) Benchmark

func (c CreatorPublisher[Entity, ID]) Benchmark(b *testing.B)

func (CreatorPublisher[Entity, ID]) Spec

func (c CreatorPublisher[Entity, ID]) Spec(s *testcase.Spec)

func (CreatorPublisher[Entity, ID]) String

func (c CreatorPublisher[Entity, ID]) String() string

func (CreatorPublisher[Entity, ID]) Test

func (c CreatorPublisher[Entity, ID]) Test(t *testing.T)

type CreatorPublisherSubject

type CreatorPublisherSubject[Entity, ID any] interface {
	spechelper.CRD[Entity, ID]
	pubsub.CreatorPublisher[Entity]
}

type DeleterPublisher

type DeleterPublisher[Entity, ID any] struct {
	MakeSubject func(testing.TB) DeleterPublisherSubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	MakeEntity  func(testing.TB) Entity
}

func (DeleterPublisher[Entity, ID]) Benchmark

func (c DeleterPublisher[Entity, ID]) Benchmark(b *testing.B)

func (DeleterPublisher[Entity, ID]) HasDeleteEntity

func (c DeleterPublisher[Entity, ID]) HasDeleteEntity(tb testing.TB, getList func() []interface{}, e interface{})

func (DeleterPublisher[Entity, ID]) Spec

func (c DeleterPublisher[Entity, ID]) Spec(s *testcase.Spec)

func (DeleterPublisher[Entity, ID]) String

func (c DeleterPublisher[Entity, ID]) String() string

func (DeleterPublisher[Entity, ID]) Test

func (c DeleterPublisher[Entity, ID]) Test(t *testing.T)

type DeleterPublisherSubject

type DeleterPublisherSubject[Entity, ID any] interface {
	spechelper.CRD[Entity, ID]
	pubsub.DeleterPublisher[ID]
}

type FIFO

type FIFO[Data any] struct {
	MakeSubject func(testing.TB) PubSub[Data]
	MakeContext func(testing.TB) context.Context
	MakeData    func(testing.TB) Data
}

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 (FIFO[Data]) Benchmark

func (c FIFO[Data]) Benchmark(b *testing.B)

func (FIFO[Data]) Spec

func (c FIFO[Data]) Spec(s *testcase.Spec)

func (FIFO[Data]) Test

func (c FIFO[Data]) Test(t *testing.T)

type FanOut added in v0.128.0

type FanOut[Data any] struct {
	MakeSubject func(testing.TB) FanOutSubject[Data]
	MakeContext func(testing.TB) context.Context
	MakeData    func(testing.TB) Data
}

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

func (FanOut[Data]) Benchmark added in v0.128.0

func (c FanOut[Data]) Benchmark(b *testing.B)

func (FanOut[Data]) Spec added in v0.128.0

func (c FanOut[Data]) Spec(s *testcase.Spec)

func (FanOut[Data]) Test added in v0.128.0

func (c FanOut[Data]) Test(t *testing.T)

type FanOutSubject added in v0.128.0

type FanOutSubject[Data any] struct {
	// Exchange is the publisher that suppose to publish to all queue made with MakeQueue.
	Exchange pubsub.Publisher[Data]
	// MakeQueue creates a queue and binds it to the Exchange to receive events.
	// Queues made with MakeQueue suppose to be cleaned up after the test.
	// For the cleanup purpose, use the testing.TB received as part of FanOut.MakeSubject.
	MakeQueue func() pubsub.Subscriber[Data]
}

type LIFO

type LIFO[Data any] struct {
	MakeSubject func(testing.TB) PubSub[Data]
	MakeContext func(testing.TB) context.Context
	MakeData    func(testing.TB) Data
}

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 (LIFO[Data]) Benchmark

func (c LIFO[Data]) Benchmark(b *testing.B)

func (LIFO[Data]) Spec

func (c LIFO[Data]) Spec(s *testcase.Spec)

func (LIFO[Data]) Test

func (c LIFO[Data]) Test(t *testing.T)

type PubSub

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

type Publisher

type Publisher[Entity, ID any] struct {
	MakeSubject func(testing.TB) PublisherSubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	MakeEntity  func(testing.TB) Entity
}

func (Publisher[Entity, ID]) Benchmark

func (c Publisher[Entity, ID]) Benchmark(b *testing.B)

func (Publisher[Entity, ID]) Spec

func (c Publisher[Entity, ID]) Spec(s *testcase.Spec)

func (Publisher[Entity, ID]) String

func (c Publisher[Entity, ID]) String() string

func (Publisher[Entity, ID]) Test

func (c Publisher[Entity, ID]) Test(t *testing.T)

type PublisherSubject

type PublisherSubject[Entity, ID any] interface {
	spechelper.CRD[Entity, ID]
	pubsub.CreatorPublisher[Entity]
	pubsub.UpdaterPublisher[Entity]
	pubsub.DeleterPublisher[ID]
}

type Queue

type Queue[Data any] struct {
	MakeSubject func(testing.TB) PubSub[Data]
	MakeContext func(testing.TB) context.Context
	MakeData    func(testing.TB) Data
}

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 (Queue[Data]) Benchmark

func (c Queue[Data]) Benchmark(b *testing.B)

func (Queue[Data]) Spec

func (c Queue[Data]) Spec(s *testcase.Spec)

func (Queue[Data]) Test

func (c Queue[Data]) Test(t *testing.T)

type UpdaterPublisher

type UpdaterPublisher[Entity, ID any] struct {
	MakeSubject func(testing.TB) UpdaterPublisherSubject[Entity, ID]
	MakeContext func(testing.TB) context.Context
	MakeEntity  func(testing.TB) Entity
}

func (UpdaterPublisher[Entity, ID]) Benchmark

func (c UpdaterPublisher[Entity, ID]) Benchmark(b *testing.B)

func (UpdaterPublisher[Entity, ID]) Spec

func (c UpdaterPublisher[Entity, ID]) Spec(s *testcase.Spec)

func (UpdaterPublisher[Entity, ID]) String

func (c UpdaterPublisher[Entity, ID]) String() string

func (UpdaterPublisher[Entity, ID]) Test

func (c UpdaterPublisher[Entity, ID]) Test(t *testing.T)

type UpdaterPublisherSubject

type UpdaterPublisherSubject[Entity, ID any] interface {
	spechelper.CRD[Entity, ID]
	crud.Updater[Entity]
	pubsub.UpdaterPublisher[Entity]
}

type Volatile

type Volatile[Data any] struct {
	MakeSubject func(testing.TB) PubSub[Data]
	MakeContext func(testing.TB) context.Context
	MakeData    func(testing.TB) Data
}

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.

func (Volatile[Data]) Benchmark

func (c Volatile[Data]) Benchmark(b *testing.B)

func (Volatile[Data]) Spec

func (c Volatile[Data]) Spec(s *testcase.Spec)

func (Volatile[Data]) Test

func (c Volatile[Data]) Test(t *testing.T)

Jump to

Keyboard shortcuts

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