typesense

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: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDataDir

WithDataDir sets the data directory for the Typesense container.

Types

type Container

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

Container represents the Typesense container type used in the module

func Run

Run creates an instance of the Typesense container type

Example
package main

import (
	"context"
	"fmt"
	"log"

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

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

	typesenseContainer, err := typesense.Run(
		ctx,
		"typesense/typesense:26.0",
		typesense.WithAPIKey("my-api-key"),
	)
	defer func() {
		if err := testcontainers.TerminateContainer(typesenseContainer); err != nil {
			log.Printf("failed to terminate container: %s", err)
		}
	}()
	if err != nil {
		log.Printf("failed to start container: %s", err)
		return
	}
	// }

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

	fmt.Println(state.Running)
	fmt.Println(typesenseContainer.APIKey())

}
Output:
true
my-api-key

func (*Container) APIKey

func (c *Container) APIKey() string

APIKey returns the API key configured for the Typesense container. The API key is required for all Typesense API calls.

func (*Container) Address

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

Address retrieves the HTTP address of the Typesense container.

type Option

type Option func(*options)

Option is a function that configures the Typesense container.

func WithAPIKey

func WithAPIKey(key string) Option

WithAPIKey sets the API key for the Typesense container. The API key is required for all Typesense API calls.

func (Option) Customize

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