Skip to content

Vearch

Since v0.32.0

Introduction

The Testcontainers module for Vearch.

Adding this module to your project dependencies

Please run the following command to add the Vearch module to your Go dependencies:

go get github.com/testcontainers/testcontainers-go/modules/vearch

Usage example

ctx := context.Background()

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

Module Reference

Run function

Info

The RunContainer(ctx, opts...) function is deprecated and will be removed in the next major release of Testcontainers for Go.

The Vearch module exposes one entrypoint function to create the Vearch container, and this function receives three parameters:

func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*VearchContainer, error)
  • context.Context, the Go context.
  • string, the Docker image to use.
  • testcontainers.ContainerCustomizer, a variadic argument for passing options.

Image

Use the second argument in the Run function to set a valid Docker image. In example: Run(context.Background(), "vearch/vearch:3.5.1").

Container Options

When starting the Vearch container, you can pass options in a variadic way to configure it.

The following options are exposed by the testcontainers package.

Basic Options

Lifecycle Options

Files & Mounts Options

Build Options

Logging Options

Image Options

Networking Options

Advanced Options

Experimental Options

Container Methods

The Vearch container exposes the following methods:

REST Endpoint

This method returns the REST endpoint of the Vearch container, using the default 9001 port.

restEndpoint, err := ctr.RESTEndpoint(ctx)