kafkatest

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KafkaContainer

type KafkaContainer struct {
	Topic string
	Addr  string
	// contains filtered or unexported fields
}

KafkaContainer is a reference to the docker kafka running Kafka (or RedPanda).

func RequireKafka

func RequireKafka(t *testing.T, opts KafkaOpts) *KafkaContainer

RequireKafka starts a Kafka-compatible API in a docker container, serving on port 9092, and creates the requested topic. If the Kafka API is already healthy on 9092, no new containers will be started, but the topic will still be created.

By default, the Kafka API is served by RedPanda as it starts significantly faster, but real Kafka can be used by setting the Provider option to KafkaProviderKafka.

func (*KafkaContainer) Stop

func (c *KafkaContainer) Stop()

Stop the container.

type KafkaOpts

type KafkaOpts struct {
	Topic         string        // Create topic
	NumPartitions int           // Number of partitions to create for topic
	Provider      KafkaProvider // The Kafka provider, RedPanda or Kafka. If not set, RedPanda is used.
}

KafkaOpts configures options for starting the test Kafka API.

type KafkaProvider

type KafkaProvider string
const (
	KafkaProviderRedPanda KafkaProvider = "redpanda"
	KafkaProviderKafka    KafkaProvider = "kafka"
)

func NewKafkaProviderFlag

func NewKafkaProviderFlag() *KafkaProvider

NewKafkaProviderFlag initializes the -kafka-provider flag and returns a pointer to the parsed value. This must be called before flag.Parse().

Jump to

Keyboard shortcuts

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