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

solr

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

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithCollection

func WithCollection(name string) testcontainers.CustomizeRequestOption

WithCollection returns a testcontainers.CustomizeRequestOption that creates a named Solr collection after the container is ready. It returns an error if the collection creation command exits with a non-zero status, so callers can be sure the collection exists once Run returns without error.

Types

type Container

type Container struct {
	testcontainers.Container
}

Container represents the Solr container type used in the module.

func Run

Run creates an instance of the Solr container type.

Example
package main

import (
	"context"
	"fmt"
	"log"

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

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

	solrContainer, err := solr.Run(ctx, "solr:9",
		solr.WithCollection("myCollection"),
	)
	defer func() {
		if err := testcontainers.TerminateContainer(solrContainer); err != nil {
			log.Printf("failed to terminate container: %s", err)
		}
	}()
	if err != nil {
		log.Printf("failed to start container: %s", err)
		return
	}
	// }

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

	fmt.Println(state.Running)

}
Output:
true

func (*Container) Address

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

Address returns the HTTP address of the Solr container in the form "http://<host>:<port>/solr".

func (*Container) CollectionURL

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

CollectionURL returns the HTTP URL of a specific Solr collection in the form "http://<host>:<port>/solr/<collection>".

Jump to

Keyboard shortcuts

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