kafkaproducer

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: 15 Imported by: 0

Documentation

Overview

Package kafkaproducer is a generated GoMock package.

Package kafkaproducer contains helpers for running Kafka in tests and checking outbound messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Harness

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

Harness implements outbound checks and publishing via Kafka for a single case.

func NewHarness

func NewHarness(brokers []string, caseNamespace string) (*Harness, error)

NewHarness creates a case-level helper with producer and consumer for outbound scenarios.

func (*Harness) AwaitOutbound

func (harness *Harness) AwaitOutbound(ctx context.Context) (probe.CheckResult, error)

AwaitOutbound performs intermediate checks on published messages.

func (*Harness) CleanupBroker

func (harness *Harness) CleanupBroker(_ context.Context) error

CleanupBroker releases the consumer/producer harness resources.

func (*Harness) PlanOutbound

func (harness *Harness) PlanOutbound(ctx context.Context, expectation probe.OutboundExpectation) error

PlanOutbound saves the wait and activates the reader with a "from now" boundary.

func (*Harness) PublishJSON

func (harness *Harness) PublishJSON(
	ctx context.Context,
	topic string,
	key *string,
	headers map[string]string,
	payload any,
) error

PublishJSON serializes the payload and sends the message to Kafka.

func (*Harness) PublishRaw

func (harness *Harness) PublishRaw(ctx context.Context, message PublishMessage) error

PublishRaw sends the already serialized payload to Kafka.

func (*Harness) ResolveTopic

func (harness *Harness) ResolveTopic(baseTopic string) string

ResolveTopic adds a namespace prefix to the base topic to isolate cases.

func (*Harness) VerifyOutbound

func (harness *Harness) VerifyOutbound(ctx context.Context) (probe.CheckResult, error)

VerifyOutbound performs final verification of published messages.

type MockmessageReader

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

MockmessageReader is a mock of messageReader interface.

func NewMockmessageReader

func NewMockmessageReader(ctrl *gomock.Controller) *MockmessageReader

NewMockmessageReader creates a new mock instance.

func (*MockmessageReader) Close

func (m *MockmessageReader) Close() error

Close mocks base method.

func (*MockmessageReader) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockmessageReader) FetchMessage

func (m *MockmessageReader) FetchMessage(ctx context.Context) (harnessMessage, error)

FetchMessage mocks base method.

type MockmessageReaderMockRecorder

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

MockmessageReaderMockRecorder is the mock recorder for MockmessageReader.

func (*MockmessageReaderMockRecorder) Close

Close indicates an expected call of Close.

func (*MockmessageReaderMockRecorder) FetchMessage

func (mr *MockmessageReaderMockRecorder) FetchMessage(ctx any) *gomock.Call

FetchMessage indicates an expected call of FetchMessage.

type MockmessageWriter

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

MockmessageWriter is a mock of messageWriter interface.

func NewMockmessageWriter

func NewMockmessageWriter(ctrl *gomock.Controller) *MockmessageWriter

NewMockmessageWriter creates a new mock instance.

func (*MockmessageWriter) Close

func (m *MockmessageWriter) Close() error

Close mocks base method.

func (*MockmessageWriter) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockmessageWriter) WriteMessages

func (m *MockmessageWriter) WriteMessages(ctx context.Context, msgs ...harnessMessage) error

WriteMessages mocks base method.

type MockmessageWriterMockRecorder

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

MockmessageWriterMockRecorder is the mock recorder for MockmessageWriter.

func (*MockmessageWriterMockRecorder) Close

Close indicates an expected call of Close.

func (*MockmessageWriterMockRecorder) WriteMessages

func (mr *MockmessageWriterMockRecorder) WriteMessages(ctx any, msgs ...any) *gomock.Call

WriteMessages indicates an expected call of WriteMessages.

type PublishMessage

type PublishMessage struct {
	Topic   string
	Key     *string
	Headers map[string]string
	Payload []byte
}

PublishMessage describes the message data to be sent to Kafka.

type Suite

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

Suite manages the lifecycle of a Kafka container at the test suite level.

func StartSuite

func StartSuite(ctx context.Context) (*Suite, error)

StartSuite picks up a Kafka container and returns a suite helper.

func (*Suite) Brokers

func (suite *Suite) Brokers() []string

Brokers returns a copy of the bootstrap brokers list.

func (*Suite) Close

func (suite *Suite) Close(ctx context.Context) error

Close terminates the Kafka container and releases resources.

func (*Suite) NewHarness

func (suite *Suite) NewHarness(caseNamespace string) (*Harness, error)

NewHarness creates a case-level harness with namespace-isolated topics.

Jump to

Keyboard shortcuts

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