Help us shape the future of Go! Take the 2026 Go Developer Survey

cratedb

package module
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cratedb provides a Testcontainers module for CrateDB.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithHeapSize

func WithHeapSize(size string) testcontainers.CustomizeRequestOption

WithHeapSize sets the CRATE_HEAP_SIZE environment variable to configure the JVM heap size for the CrateDB container.

Types

type Container

type Container struct {
	testcontainers.Container
}

Container represents the CrateDB container type used in the module.

func Run

Run creates an instance of the CrateDB container type. By default, the container is started in single-node discovery mode (-Cdiscovery.type=single-node) so it starts reliably without requiring a cluster bootstrap quorum.

Example
package main

import (
	"context"
	"fmt"
	"log"

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

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

	cratedbContainer, err := cratedb.Run(ctx,
		"crate:5.7",
	)
	defer func() {
		if err := testcontainers.TerminateContainer(cratedbContainer); err != nil {
			log.Printf("failed to terminate container: %s", err)
		}
	}()
	if err != nil {
		log.Printf("failed to start container: %s", err)
		return
	}
	// }

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

	fmt.Println(state.Running)

}
Output:
true

func (*Container) HTTPEndpoint

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

HTTPEndpoint returns the HTTP endpoint of the CrateDB container, for the Admin UI and REST API on port 4200.

func (*Container) PGConnectionString

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

PGConnectionString returns the PostgreSQL wire-protocol connection string for the CrateDB container. CrateDB's default user is "crate" with no password, and the default schema/database is "doc". It also accepts a variadic list of extra arguments which will be appended to the connection string as query parameters, e.g. "sslmode=disable" or "connect_timeout=10".

Jump to

Keyboard shortcuts

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