redpanda

package module
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminAPIClient

type AdminAPIClient struct {
	BaseURL string
	// contains filtered or unexported fields
}

func NewAdminAPIClient

func NewAdminAPIClient(baseURL string) *AdminAPIClient

func (*AdminAPIClient) CreateUser

func (cl *AdminAPIClient) CreateUser(ctx context.Context, username, password string) error

func (*AdminAPIClient) WithHTTPClient added in v0.28.0

func (cl *AdminAPIClient) WithHTTPClient(c *http.Client) *AdminAPIClient

type Container

type Container struct {
	testcontainers.Container
	// contains filtered or unexported fields
}

Container represents the Redpanda container type used in the module.

func RunContainer

func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*Container, error)

RunContainer creates an instance of the Redpanda container type.

Example
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/testcontainers/testcontainers-go/modules/redpanda"
)

func main() {
	// runRedpandaContainer {
	ctx := context.Background()

	redpandaContainer, err := redpanda.RunContainer(ctx,
		redpanda.WithEnableSASL(),
		redpanda.WithEnableKafkaAuthorization(),
		redpanda.WithEnableWasmTransform(),
		redpanda.WithNewServiceAccount("superuser-1", "test"),
		redpanda.WithNewServiceAccount("superuser-2", "test"),
		redpanda.WithNewServiceAccount("no-superuser", "test"),
		redpanda.WithSuperusers("superuser-1", "superuser-2"),
		redpanda.WithEnableSchemaRegistryHTTPBasicAuth(),
	)
	if err != nil {
		log.Fatalf("failed to start container: %s", err)
	}

	// Clean up the container
	defer func() {
		if err := redpandaContainer.Terminate(ctx); err != nil {
			log.Fatalf("failed to terminate container: %s", err)
		}
	}()
	// }

	state, err := redpandaContainer.State(ctx)
	if err != nil {
		log.Fatalf("failed to get container state: %s", err) // nolint:gocritic
	}

	fmt.Println(state.Running)

}
Output:

true

func (*Container) AdminAPIAddress

func (c *Container) AdminAPIAddress(ctx context.Context) (string, error)

AdminAPIAddress returns the address to the Redpanda Admin API. This is an HTTP-based API and thus the returned format will be: http://host:port.

func (*Container) KafkaSeedBroker

func (c *Container) KafkaSeedBroker(ctx context.Context) (string, error)

KafkaSeedBroker returns the seed broker that should be used for connecting to the Kafka API with your Kafka client. It'll be returned in the format: "host:port" - for example: "localhost:55687".

func (*Container) SchemaRegistryAddress

func (c *Container) SchemaRegistryAddress(ctx context.Context) (string, error)

SchemaRegistryAddress returns the address to the schema registry API. This is an HTTP-based API and thus the returned format will be: http://host:port.

type Option

type Option func(*options)

Option is an option for the Redpanda container.

func WithAutoCreateTopics added in v0.22.0

func WithAutoCreateTopics() Option

WithAutoCreateTopics enables topic auto creation.

func WithEnableKafkaAuthorization

func WithEnableKafkaAuthorization() Option

WithEnableKafkaAuthorization enables authorization for connections on the Kafka API.

func WithEnableSASL

func WithEnableSASL() Option

WithEnableSASL enables SASL scram sha authentication. By default, no authentication (plaintext) is used. When setting an authentication method, make sure to add users as well as authorize them using the WithSuperusers() option.

func WithEnableSchemaRegistryHTTPBasicAuth

func WithEnableSchemaRegistryHTTPBasicAuth() Option

WithEnableSchemaRegistryHTTPBasicAuth enables HTTP basic authentication for Schema Registry.

func WithEnableWasmTransform added in v0.28.0

func WithEnableWasmTransform() Option

WithEnableWasmTransform enables wasm transform. Should not be used with RP versions before 23.3

func WithListener added in v0.28.0

func WithListener(lis string) Option

WithListener adds a custom listener to the Redpanda containers. Listener will be aliases to all networks, so they can be accessed from within docker networks. At leas one network must be attached to the container, if not an error will be thrown when starting the container.

func WithNewServiceAccount

func WithNewServiceAccount(username, password string) Option

func WithSuperusers

func WithSuperusers(superusers ...string) Option

WithSuperusers defines the superusers added to the redpanda config. By default, there are no superusers.

func WithTLS added in v0.24.0

func WithTLS(cert, key []byte) Option

func (Option) Customize

func (o Option) Customize(*testcontainers.GenericContainerRequest)

Customize is a NOOP. It's defined to satisfy the testcontainers.ContainerCustomizer interface.

Jump to

Keyboard shortcuts

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