Documentation ¶
Overview ¶
Package kafkatest provides a package intended for running tests that require a Kafka backend.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDisabled = fmt.Errorf("kafka tests are disabled")
Functions ¶
This section is empty.
Types ¶
type Kafka ¶
type Kafka struct {
// contains filtered or unexported fields
}
Kafka represents a connection to a Kafka cluster.
func New ¶
New connects to a Kafka instance and returns a Kafka instance that uses it.
The following environment variables can be used to configure the connection parameters:
$KAFKA_DISABLE A boolean as parsed by strconv.ParseBool. If this is true, New will return ErrDisabled.
$KAFKA_ADDRS A comma-separate list of Kafka broker addresses in host:port form. If this is empty, localhost:9092 will be used. The list of address can be discovered by calling Client.Addrs.
$KAFKA_USERNAME, $KAFKA_PASWORD The username and password to use for SASL authentication. When $KAFKA_USERNAME is non-empty, SASL will be enabled.
$KAFKA_USE_TLS A boolean as parsed by strconv.ParseBool. If this is true, a secure TLS connection will be used.
$KAFKA_TIMEOUT The maximum duration to wait when trying to connect to Kakfa. Defaults to "30s".
The returned Kafka instance must be closed after use.
func (*Kafka) Close ¶
Close closes the client connection and removes any topics created by Topic. This method may be called more than once.
func (*Kafka) Config ¶
Config returns a sarama configuration that will use connection parameters defined in the environment variables described in New.
func (*Kafka) InitConfig ¶
InitConfig is similar to Config, except that instead of returning a new configuration, it configures an existing one.