probe

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package probe contains a transport-agnostic contract and a matcher for checking outbound messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckResult

type CheckResult struct {
	MatchedCount       int       `json:"matched_count"`
	ObservedMessages   []Message `json:"observed_messages"`
	LastMismatchReason string    `json:"last_mismatch_reason"`
}

CheckResult contains the result of comparing the observed messages with the expectations contract.

func EvaluateAwait

func EvaluateAwait(expectation OutboundExpectation, observed []Message, windowExpired bool) (CheckResult, error)

EvaluateAwait checks the intermediate state of the await step.

func EvaluateVerify

func EvaluateVerify(expectation OutboundExpectation, observed []Message) (CheckResult, error)

EvaluateVerify checks the final state of the verify step.

type HeadersMode

type HeadersMode string

HeadersMode defines the message header comparison strategy.

const (
	// HeadersModeExact requires a complete match of the set of headers.
	HeadersModeExact HeadersMode = "exact"
	// HeadersModeSubset requires only the expected subset of headers to match.
	HeadersModeSubset HeadersMode = "subset"
)

type Message

type Message struct {
	Topic   string            `json:"topic"`
	Key     *string           `json:"key,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
	Payload json.RawMessage   `json:"payload,omitempty"`
	Offset  int64             `json:"offset"`
}

Message represents the broker's observable message in transport-agnostic form.

type Ordering

type Ordering string

Ordering defines the message order checking mode.

const (
	// OrderingStrict requires strict order and the absence of unnecessary messages in the topic.
	OrderingStrict Ordering = "strict"
	// OrderingAny ignores the order of messages and only considers the number of matches.
	OrderingAny Ordering = "any"
)

type OutboundExpectation

type OutboundExpectation struct {
	Topic         string            `json:"topic"`
	Key           *string           `json:"key,omitempty"`
	Headers       map[string]string `json:"headers,omitempty"`
	HeadersMode   HeadersMode       `json:"headers_mode,omitempty"`
	ExpectedCount int               `json:"expected_count"`
	Payload       json.RawMessage   `json:"payload,omitempty"`
	PayloadSubset json.RawMessage   `json:"payload_subset,omitempty"`
	Ordering      Ordering          `json:"ordering,omitempty"`
}

OutboundExpectation describes the expectations contract for checking an outgoing publication.

func NormalizeExpectation

func NormalizeExpectation(expectation OutboundExpectation) (OutboundExpectation, error)

NormalizeExpectation validates the contract and applies default values.

Jump to

Keyboard shortcuts

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