eventbustest

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package eventbustest provides shared test helpers for modulex.EventBus adapter implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBenchPayloadJSON added in v0.8.0

func NewBenchPayloadJSON(tb testing.TB) []byte

NewBenchPayloadJSON marshals NewBenchPayload, for benchmarks that publish or decode raw bytes.

func RunHandlerErrorLoggingTests

func RunHandlerErrorLoggingTests(t *testing.T, newBus func(logger *slog.Logger) modulex.EventBus, topic string, timeout, logWait time.Duration)

func RunPublishSubscribeTests

func RunPublishSubscribeTests(t *testing.T, newBus func() modulex.EventBus, topic string, timeout time.Duration)

Types

type BenchPayload added in v0.8.0

type BenchPayload struct {
	ID        string            `json:"id"`
	Type      string            `json:"type"`
	Timestamp int64             `json:"timestamp"`
	Attempt   int               `json:"attempt"`
	Metadata  map[string]string `json:"metadata"`
}

BenchPayload is representative of a small event/message body: a handful of scalar fields plus one nested object, comparable in size to typical modulex EventBus payloads (~150-250 bytes encoded). It is shared by every adapter's benchmarks so cross-package throughput and JSON decode comparisons (see ADR-0034) measure the same fixed cost.

func NewBenchPayload added in v0.8.0

func NewBenchPayload() BenchPayload

NewBenchPayload returns the canonical BenchPayload value used across benchmarks.

type SyncBuffer

type SyncBuffer struct {
	// contains filtered or unexported fields
}

SyncBuffer is a concurrency-safe io.Writer wrapping a bytes.Buffer. It is useful for capturing log output written by adapter goroutines while the test polls the buffer from the main goroutine.

func (*SyncBuffer) String

func (b *SyncBuffer) String() string

func (*SyncBuffer) Write

func (b *SyncBuffer) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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