pinecone

package module
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	testcontainers.Container
}

Container represents the Pinecone container type used in the module

func Run

Run creates an instance of the Pinecone container type

Example
ctx := context.Background()

pineconeContainer, err := tcpinecone.Run(ctx, "ghcr.io/pinecone-io/pinecone-local:v0.7.0")
defer func() {
	if err := testcontainers.TerminateContainer(pineconeContainer); err != nil {
		log.Printf("failed to terminate container: %s", err)
	}
}()
if err != nil {
	log.Printf("failed to start container: %s", err)
	return
}

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

fmt.Println(state.Running)

// httpConnection {
host, err := pineconeContainer.HttpEndpoint()
if err != nil {
	log.Printf("failed to get container state: %s", err)
	return
}
// }

pc, err := pinecone.NewClient(pinecone.NewClientParams{
	ApiKey: "testcontainers-go", // API key is required, else use headers
	Host:   host,
})
if err != nil {
	log.Printf("failed to create pinecone client: %s", err)
	return
}

indexName := "my-serverless-index"

idx, err := pc.CreateServerlessIndex(ctx, &pinecone.CreateServerlessIndexRequest{
	Name:      indexName,
	Dimension: 3,
	Metric:    pinecone.Cosine,
	Cloud:     pinecone.Aws,
	Region:    "us-east-1",
	Tags:      &pinecone.IndexTags{"environment": "development"},
})
if err != nil {
	log.Printf("failed to create serverless index: %s", err)
	return
}

fmt.Println(idx.Name)
Output:

true
my-serverless-index

func (*Container) HttpEndpoint

func (c *Container) HttpEndpoint() (string, error)

HttpEndpoint returns the http endpoint for the pinecone container

Jump to

Keyboard shortcuts

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