Documentation ¶
Overview ¶
Package kafka provides a Gnomock Preset for Kafka.
Index ¶
Constants ¶
const ( BrokerPort = "broker" ZooKeeperPort = "zookeeper" WebPort = "web" )
The following ports are exposed by this preset:.
Variables ¶
This section is empty.
Functions ¶
func Preset ¶
Preset creates a new Gmomock Kafka preset. This preset includes a Kafka specific healthcheck function and default Kafka image and ports.
Kafka preset uses a constant broker port number (49092) instead of allocating a random unoccupied port on every run. Please make sure this port is available when using this preset.
By default, this preset uses `lensesio/fast-data-dev` docker image with version `2.5.1-L0` (version can be changed using `WithVersion`).
Types ¶
type Message ¶
type Message struct { Topic string `json:"topic"` Key string `json:"key"` Value string `json:"value"` Time int64 `json:"time"` }
Message is a single message sent to Kafka.
type Option ¶
type Option func(*P)
Option is an optional configuration of this Gnomock preset. Use available Options to configure the container.
func WithMessages ¶
WithMessages makes sure that these messages can be consumed during the test once the container is ready.
func WithMessagesFile ¶
WithMessagesFile allows to load messages to be sent into Kafka from one or multiple files.
func WithTopics ¶
WithTopics makes sure that the provided topics are available when Kafka is up and running.
type P ¶
type P struct { Version string `json:"version"` Topics []string `json:"topics"` Messages []Message `json:"messages"` MessagesFiles []string `json:"messages_files"` ImageName string `json:"image_name"` }
P is a Gnomock Preset implementation of Kafka.
func (*P) Ports ¶
func (p *P) Ports() gnomock.NamedPorts
Ports returns ports that should be used to access this container.