redpanda

package module
v0.0.0-...-d518686 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 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

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 Run

func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)

Run creates an instance of the Redpanda container type

Example
// runRedpandaContainer {
ctx := context.Background()

redpandaContainer, err := redpanda.Run(ctx,
	"docker.redpanda.com/redpandadata/redpanda:v23.3.3",
	redpanda.WithEnableSASL(),
	redpanda.WithEnableKafkaAuthorization(),
	redpanda.WithEnableWasmTransform(),
	redpanda.WithBootstrapConfig("data_transforms_per_core_memory_reservation", 33554432),
	redpanda.WithBootstrapConfig("data_transforms_per_function_memory_limit", 16777216),
	redpanda.WithNewServiceAccount("superuser-1", "test"),
	redpanda.WithNewServiceAccount("superuser-2", "test"),
	redpanda.WithNewServiceAccount("no-superuser", "test"),
	redpanda.WithSuperusers("superuser-1", "superuser-2"),
	redpanda.WithEnableSchemaRegistryHTTPBasicAuth(),
)
defer func() {
	if err := testcontainers.TerminateContainer(redpandaContainer); err != nil {
		log.Printf("failed to terminate container: %s", err)
	}
}()
if err != nil {
	log.Printf("failed to start container: %s", err)
	return
}
// }

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

fmt.Println(state.Running)
Output:

true

func RunContainer deprecated

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

Deprecated: use Run instead RunContainer creates an instance of the Redpanda container type

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

func WithAutoCreateTopics() Option

WithAutoCreateTopics enables topic auto creation.

func WithBootstrapConfig

func WithBootstrapConfig(cfg string, val any) Option

WithBootstrapConfig adds an arbitrary config kvp to the Redpanda container. Per the name, this config will be interpolated into the generated bootstrap config file, which is particularly useful for configs requiring a restart when otherwise applied to a running Redpanda instance.

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

func WithEnableWasmTransform() Option

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

func WithListener

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 least 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

func WithTLS(cert, key []byte) Option

func (Option) Customize

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

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