couchbase

package module
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	MGMT_PORT     = "8091"
	MGMT_SSL_PORT = "18091"

	VIEW_PORT     = "8092"
	VIEW_SSL_PORT = "18092"

	QUERY_PORT     = "8093"
	QUERY_SSL_PORT = "18093"

	SEARCH_PORT     = "8094"
	SEARCH_SSL_PORT = "18094"

	ANALYTICS_PORT     = "8095"
	ANALYTICS_SSL_PORT = "18095"

	EVENTING_PORT     = "8096"
	EVENTING_SSL_PORT = "18096"

	KV_PORT     = "11210"
	KV_SSL_PORT = "11207"
)
View Source
const (
	// MemoryOptimized sets the cluster-wide index storage mode to use memory optimized global
	// secondary indexes which can perform index maintenance and index scan faster at in-memory speeds.
	// This is the default value for the testcontainers couchbase implementation.
	MemoryOptimized indexStorageMode = "memory_optimized"

	// Plasma sets the cluster-wide index storage mode to use the Plasma storage engine,
	// which can utilize both memory and persistent storage for index maintenance and index scans.
	Plasma indexStorageMode = "plasma"

	// ForestDB sets the cluster-wide index storage mode to use the forestdb storage engine,
	// which only utilizes persistent storage for index maintenance and scans. It is the only option available
	// for the community edition.
	ForestDB indexStorageMode = "forestdb"
)

Variables

This section is empty.

Functions

func NewBucket

func NewBucket(name string) bucket

NewBucket creates a new bucket with the given name, using default values for all other fields.

func WithAdminCredentials

func WithAdminCredentials(username, password string) credentialsCustomizer

WithAdminCredentials sets the username and password for the administrator user.

func WithBuckets

func WithBuckets(bucket ...bucket) bucketCustomizer

WithBucket adds buckets to the couchbase container

func WithIndexStorage

func WithIndexStorage(indexStorageMode indexStorageMode) indexStorageCustomizer

WithBucket adds buckets to the couchbase container

func WithServiceAnalytics

func WithServiceAnalytics() serviceCustomizer

WithServiceAnalytics enables the Analytics service.

func WithServiceEventing

func WithServiceEventing() serviceCustomizer

WithServiceEventing enables the Eventing service.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config is the configuration for the Couchbase container, that will be stored in the container itself.

type CouchbaseContainer

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

CouchbaseContainer represents the Couchbase container type used in the module

func RunContainer

func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*CouchbaseContainer, error)

RunContainer creates an instance of the Couchbase container type

Example
// runCouchbaseContainer {
ctx := context.Background()

bucketName := "testBucket"
bucket := couchbase.NewBucket(bucketName)

bucket = bucket.WithQuota(100).
	WithReplicas(0).
	WithFlushEnabled(false).
	WithPrimaryIndex(true)

couchbaseContainer, err := couchbase.RunContainer(ctx,
	testcontainers.WithImage("couchbase:community-7.1.1"),
	couchbase.WithAdminCredentials("testcontainers", "testcontainers.IS.cool!"),
	couchbase.WithBuckets(bucket),
)
if err != nil {
	log.Fatalf("failed to start container: %s", err)
}
defer func() {
	if err := couchbaseContainer.Terminate(ctx); err != nil {
		log.Fatalf("failed to terminate container: %s", err)
	}
}()
// }

state, err := couchbaseContainer.State(ctx)
if err != nil {
	log.Fatalf("failed to get container state: %s", err) // nolint:gocritic
}

fmt.Println(state.Running)

connectionString, err := couchbaseContainer.ConnectionString(ctx)
if err != nil {
	log.Fatalf("failed to get connection string: %s", err)
}

cluster, err := gocb.Connect(connectionString, gocb.ClusterOptions{
	Username: couchbaseContainer.Username(),
	Password: couchbaseContainer.Password(),
})
if err != nil {
	log.Fatalf("failed to connect to cluster: %s", err)
}

buckets, err := cluster.Buckets().GetAllBuckets(nil)
if err != nil {
	log.Fatalf("failed to get buckets: %s", err)
}

fmt.Println(len(buckets))
fmt.Println(buckets[bucketName].Name)
Output:

true
1
testBucket

func StartContainer

func StartContainer(ctx context.Context, opts ...Option) (*CouchbaseContainer, error)

StartContainer creates an instance of the Couchbase container type Deprecated: use RunContainer instead

func (*CouchbaseContainer) ConnectionString

func (c *CouchbaseContainer) ConnectionString(ctx context.Context) (string, error)

ConnectionString returns the connection string to connect to the Couchbase container instance. It returns a string with the format couchbase://<host>:<port>

func (*CouchbaseContainer) Password

func (c *CouchbaseContainer) Password() string

Password returns the password of the Couchbase administrator.

func (*CouchbaseContainer) Username

func (c *CouchbaseContainer) Username() string

Username returns the username of the Couchbase administrator.

type Option

type Option func(*Config)

Option is a function that configures the Couchbase container. Deprecated: Use the With* functions instead.

func WithAnalyticsService

func WithAnalyticsService() Option

WithAnalyticsService enables the analytics service in the container. Only available in the Enterprise Edition of Couchbase Server. Deprecated: Use WithServiceAnalytics instead.

func WithBucket

func WithBucket(bucket bucket) Option

WithBucket adds a bucket to the container. Deprecated: Use WithBuckets instead.

func WithCredentials

func WithCredentials(username, password string) Option

WithCredentials sets the username and password for the administrator user. Deprecated: Use WithAdminCredentials instead.

func WithEventingService

func WithEventingService() Option

WithEnterpriseService enables the eventing service in the container. Only available in the Enterprise Edition of Couchbase Server. Deprecated: Use WithServiceEventing instead.

func WithImageName

func WithImageName(imageName string) Option

WithImageName allows to override the default image name. Deprecated: Use testcontainers.WithImage instead.

func WithIndexStorageMode

func WithIndexStorageMode(indexStorageMode indexStorageMode) Option

WithIndexStorageMode sets the storage mode to be used in the cluster. Deprecated: Use WithIndexStorage instead.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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