gocbconnstr

package module
v2.0.0-...-fb38552 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 7 Imported by: 3

README

Couchbase Connection Strings for Go

This library allows you to parse and resolve Couchbase Connection Strings in Go. This is used by the Couchbase Go SDK, as well as various tools throughout the Couchbase infrastructure.

Using the Library

To parse a connection string, simply call Parse with your connection string. You will receive a ConnSpec structure representing the connection string`:

type Address struct {
	Host string
	Port int
}

type ConnSpec struct {
	Scheme string
	Addresses []Address
	Bucket string
	Options map[string][]string
}

One you have a parsed connection string, you can also use our resolver to take the ConnSpec and resolve any DNS SRV records as well as generate a list of endpoints for the Couchbase server. You will receive a ResolvedConnSpec structure in return:

type ResolvedConnSpec struct {
	UseSsl bool
	MemdHosts []Address
	HttpHosts []Address
	Bucket string
	Options map[string][]string
}

License

Copyright 2016 Couchbase Inc.

Licensed under the Apache License, Version 2.0.

See LICENSE for further details.

Documentation

Index

Constants

View Source
const (
	// DefaultHttpPort is the default HTTP port to use to connect to Couchbase Server.
	DefaultHttpPort = 8091

	// DefaultSslHttpPort is the default HTTPS port to use to connect to Couchbase Server.
	DefaultSslHttpPort = 18091

	// DefaultMemdPort is the default memd port to use to connect to Couchbase Server.
	DefaultMemdPort = 11210

	// DefaultSslMemdPort is the default memd SSL port to use to connect to Couchbase Server.
	DefaultSslMemdPort = 11207

	// DefaultCouchbase2Port is the default (SSL) port to use to connect with Couchbase2.
	DefaultCouchbase2Port = 18098
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Host string
	Port int
}

Address represents a host:port pair.

type ConnSpec

type ConnSpec struct {
	Scheme    string
	Addresses []Address
	Bucket    string
	Options   map[string][]string
}

ConnSpec describes a connection specification.

func Parse

func Parse(connStr string) (out ConnSpec, err error)

Parse parses the connection string into a ConnSpec.

func (ConnSpec) GetOption

func (spec ConnSpec) GetOption(name string) []string

GetOption returns the specified option value for the ConnSpec.

func (ConnSpec) GetOptionString

func (spec ConnSpec) GetOptionString(name string) string

GetOptionString returns the specified option value for the ConnSpec.

func (ConnSpec) SrvRecordName

func (spec ConnSpec) SrvRecordName() (recordName string)

SrvRecordName returns the record name for the ConnSpec.

func (ConnSpec) String

func (spec ConnSpec) String() string

type ResolvedConnSpec

type ResolvedConnSpec struct {
	UseSsl         bool
	MemdHosts      []Address
	HttpHosts      []Address
	NSServerHost   *Address
	Couchbase2Host *Address
	Bucket         string
	SrvRecord      *SrvRecord
	Options        map[string][]string
}

ResolvedConnSpec is the result of resolving a ConnSpec.

func Resolve

func Resolve(connSpec ConnSpec) (ResolvedConnSpec, error)

Resolve parses a ConnSpec into a ResolvedConnSpec.

type SrvRecord

type SrvRecord struct {
	Proto  string
	Scheme string
	Host   string
}

SrvRecord contains the information about the srv record used to extract addresses.

Jump to

Keyboard shortcuts

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