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 RunContainer ¶
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*KafkaContainer, error)
RunContainer creates an instance of the Kafka container type
Example ¶
// runKafkaContainer { ctx := context.Background() kafkaContainer, err := kafka.RunContainer(ctx, kafka.WithClusterID("test-cluster"), testcontainers.WithImage("confluentinc/confluent-local:7.5.0"), ) if err != nil { log.Fatalf("failed to start container: %s", err) } // Clean up the container after defer func() { if err := kafkaContainer.Terminate(ctx); err != nil { log.Fatalf("failed to terminate container: %s", err) } }() // } state, err := kafkaContainer.State(ctx) if err != nil { log.Fatalf("failed to get container state: %s", err) // nolint:gocritic } fmt.Println(kafkaContainer.ClusterID) fmt.Println(state.Running)
Output: test-cluster true
Click to show internal directories.
Click to hide internal directories.