Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithClusterID ¶
func WithClusterID(clusterID string) testcontainers.CustomizeRequestOption
Types ¶
type KafkaContainer ¶
type KafkaContainer struct {
testcontainers.Container
ClusterID string
}
KafkaContainer represents the Kafka container type used in the module
func Run ¶ added in v0.32.0
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*KafkaContainer, error)
Run creates an instance of the Kafka container type
Example ¶
// runKafkaContainer {
ctx := context.Background()
kafkaContainer, err := kafka.Run(ctx,
"confluentinc/confluent-local:7.5.0",
kafka.WithClusterID("test-cluster"),
)
defer func() {
if err := testcontainers.TerminateContainer(kafkaContainer); err != nil {
log.Printf("failed to terminate container: %s", err)
}
}()
if err != nil {
log.Printf("failed to start container: %s", err)
return
}
// }
state, err := kafkaContainer.State(ctx)
if err != nil {
log.Printf("failed to get container state: %s", err)
return
}
fmt.Println(kafkaContainer.ClusterID)
fmt.Println(state.Running)
Output: test-cluster true
func RunContainer
deprecated
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*KafkaContainer, error)
Deprecated: use Run instead RunContainer creates an instance of the Kafka container type
Click to show internal directories.
Click to hide internal directories.