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 ¶
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Container, error)
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 ¶
HTTPEndpoint returns the HTTP endpoint of the CrateDB container, for the Admin UI and REST API on port 4200.
func (*Container) PGConnectionString ¶
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".