gocbconnstr

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: Apache-2.0 Imports: 7 Imported by: 39

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    = 8091
	DefaultSslHttpPort = 18091
	DefaultMemdPort    = 11210
	DefaultSslMemdPort = 11207
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Host string
	Port int
}

type ConnSpec

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

func Parse

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

func (ConnSpec) GetOption

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

func (ConnSpec) GetOptionString

func (spec ConnSpec) GetOptionString(name string) string

func (ConnSpec) SrvRecordName added in v1.0.2

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

func (ConnSpec) String

func (spec ConnSpec) String() string

type ResolvedConnSpec

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

func Resolve

func Resolve(connSpec ConnSpec) (out ResolvedConnSpec, err error)

Jump to

Keyboard shortcuts

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