gocb

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

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

Go to latest
Published: May 23, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

README

GoDoc

Couchbase Go Client

This is the official Couchbase Go SDK. If you are looking for our previous unofficial prototype Go client library, please see: http://www.github.com/couchbase/go-couchbase.

The Go SDK library allows you to connect to a Couchbase cluster from Go. It is written in pure Go, and uses the included gocbcore library to handle communicating to the cluster over the Couchbase binary protocol.

Source

The project source is hosted at http://github.com/couchbase/gocb.

Documentation

You can explore our API reference through godoc at https://godoc.org/github.com/couchbase/gocb.

You can also find documentation for the Go SDK at the Couchbase Developer Portal.

Bug Tracker

Issues are tracked on Couchbase's public issues.couchbase.com. Contact the site admins regarding login or other problems at issues.couchbase.com (officially) or ask around in couchbase/discuss on gitter.im (unofficially).

Installing

To install the latest stable version, run:

go get gopkg.in/couchbase/gocb.v1

To install the latest developer version, run:

go get github.com/couchbase/gocb

License

Copyright 2016 Couchbase Inc.

Licensed under the Apache License, Version 2.0.

See LICENSE for further details.

Documentation

Index

Constants

View Source
const (
	// Couchbase indicates a Couchbase bucket type.
	Couchbase = BucketType(0)

	// Memcached indicates a Memcached bucket type.
	Memcached = BucketType(1)

	// Ephemeral indicates an Ephemeral bucket type.
	Ephemeral = BucketType(2)
)
View Source
const (
	// IndexTypeN1ql indicates that GSI was used to build the index.
	IndexTypeN1ql = IndexType("gsi")

	// IndexTypeView indicates that views were used to build the index.
	IndexTypeView = IndexType("views")
)
View Source
const (
	// SubdocFlagNone indicates no special behaviours
	SubdocFlagNone = SubdocFlag(gocbcore.SubdocFlagNone)

	// SubdocFlagCreatePath indicates you wish to recursively create the tree of paths
	// if it does not already exist within the document.
	SubdocFlagCreatePath = SubdocFlag(gocbcore.SubdocFlagMkDirP)

	// SubdocFlagXattr indicates your path refers to an extended attribute rather than the document.
	SubdocFlagXattr = SubdocFlag(gocbcore.SubdocFlagXattrPath)

	// SubdocFlagUseMacros indicates that you wish macro substitution to occur on the value
	SubdocFlagUseMacros = SubdocFlag(gocbcore.SubdocFlagExpandMacros)
)
View Source
const (
	// SubdocDocFlagNone indicates no special behaviours
	SubdocDocFlagNone = SubdocDocFlag(gocbcore.SubdocDocFlagNone)

	// SubdocDocFlagMkDoc indicates that the document should be created if it does not already exist.
	SubdocDocFlagMkDoc = SubdocDocFlag(gocbcore.SubdocDocFlagMkDoc)

	// SubdocDocFlagReplaceDoc indices that this operation should be a replace rather than upsert.
	SubdocDocFlagReplaceDoc = SubdocDocFlag(gocbcore.SubdocDocFlagReplaceDoc)

	// SubdocDocFlagAccessDeleted indicates that you wish to receive soft-deleted documents.
	SubdocDocFlagAccessDeleted = SubdocDocFlag(gocbcore.SubdocDocFlagAccessDeleted)
)
View Source
const (
	LogError        = LogLevel(gocbcore.LogError)
	LogWarn         = LogLevel(gocbcore.LogWarn)
	LogInfo         = LogLevel(gocbcore.LogInfo)
	LogDebug        = LogLevel(gocbcore.LogDebug)
	LogTrace        = LogLevel(gocbcore.LogTrace)
	LogSched        = LogLevel(gocbcore.LogSched)
	LogMaxVerbosity = LogLevel(gocbcore.LogMaxVerbosity)
)

Various logging levels (or subsystems) which can categorize the message. Currently these are ordered in decreasing severity.

View Source
const (
	// NotBounded indicates no data consistency is required.
	NotBounded = ConsistencyMode(1)
	// RequestPlus indicates that request-level data consistency is required.
	RequestPlus = ConsistencyMode(2)
	// StatementPlus inidcates that statement-level data consistency is required.
	StatementPlus = ConsistencyMode(3)
)
View Source
const (
	// DefaultHighlightStyle specifies to use the default to highlight search result hits.
	DefaultHighlightStyle = SearchHighlightStyle("")

	// HtmlHighlightStyle specifies to use HTML tags to highlight search result hits.
	HtmlHighlightStyle = SearchHighlightStyle("html")

	// AnsiHightlightStyle specifies to use ANSI tags to highlight search result hits.
	AnsiHightlightStyle = SearchHighlightStyle("ansi")
)
View Source
const (
	// Before indicates to update the index before querying it.
	Before = StaleMode(1)
	// None indicates that no special behaviour should be used.
	None = StaleMode(2)
	// After indicates to update the index asynchronously after querying.
	After = StaleMode(3)
)
View Source
const (
	// Ascending indicates the query results should be sorted from lowest to highest.
	Ascending = SortOrder(1)
	// Descending indicates the query results should be sorted from highest to lowest.
	Descending = SortOrder(2)
)

Variables

View Source
var (
	// ErrNotEnoughReplicas occurs when not enough replicas exist to match the specified durability requirements.
	ErrNotEnoughReplicas = errors.New("Not enough replicas to match durability requirements.")
	// ErrDurabilityTimeout occurs when the server took too long to meet the specified durability requirements.
	ErrDurabilityTimeout = errors.New("Failed to meet durability requirements in time.")
	// ErrNoResults occurs when no results are available to a query.
	ErrNoResults = errors.New("No results returned.")
	// ErrNoOpenBuckets occurs when a cluster-level operation is performed before any buckets are opened.
	ErrNoOpenBuckets = errors.New("You must open a bucket before you can perform cluster level operations.")
	// ErrIndexInvalidName occurs when an invalid name was specified for an index.
	ErrIndexInvalidName = errors.New("An invalid index name was specified.")
	// ErrIndexNoFields occurs when an index with no fields is created.
	ErrIndexNoFields = errors.New("You must specify at least one field to index.")
	// ErrIndexNotFound occurs when an operation expects an index but it was not found.
	ErrIndexNotFound = errors.New("The index specified does not exist.")
	// ErrIndexAlreadyExists occurs when an operation expects an index not to exist, but it was found.
	ErrIndexAlreadyExists = errors.New("The index specified already exists.")
	// ErrFacetNoRanges occurs when a range-based facet is specified but no ranges were indicated.
	ErrFacetNoRanges = errors.New("At least one range must be specified on a facet.")

	// ErrDispatchFail occurs when we failed to execute an operation due to internal routing issues.
	ErrDispatchFail = gocbcore.ErrDispatchFail
	// ErrBadHosts occurs when an invalid list of hosts is specified for bootstrapping.
	ErrBadHosts = gocbcore.ErrBadHosts
	// ErrProtocol occurs when an invalid protocol is specified for bootstrapping.
	ErrProtocol = gocbcore.ErrProtocol
	// ErrNoReplicas occurs when an operation expecting replicas is performed, but no replicas are available.
	ErrNoReplicas = gocbcore.ErrNoReplicas
	// ErrInvalidServer occurs when a specified server index is invalid.
	ErrInvalidServer = gocbcore.ErrInvalidServer
	// ErrInvalidVBucket occurs when a specified vbucket index is invalid.
	ErrInvalidVBucket = gocbcore.ErrInvalidVBucket
	// ErrInvalidReplica occurs when a specified replica index is invalid.
	ErrInvalidReplica = gocbcore.ErrInvalidReplica

	// ErrInvalidCert occurs when the specified certificate is not valid.
	ErrInvalidCert = gocbcore.ErrInvalidCert

	// ErrShutdown occurs when an operation is performed on a bucket that has been closed.
	ErrShutdown = gocbcore.ErrShutdown
	// ErrOverload occurs when more operations were dispatched than the client is capable of writing.
	ErrOverload = gocbcore.ErrOverload
	// ErrNetwork occurs when various generic network errors occur.
	ErrNetwork = gocbcore.ErrNetwork
	// ErrTimeout occurs when an operation times out.
	ErrTimeout = gocbcore.ErrTimeout

	// ErrStreamClosed occurs when an error is related to a stream closing.
	ErrStreamClosed = gocbcore.ErrStreamClosed
	// ErrStreamStateChanged occurs when an error is related to a cluster rebalance.
	ErrStreamStateChanged = gocbcore.ErrStreamStateChanged
	// ErrStreamDisconnected occurs when a stream is closed due to a connection dropping.
	ErrStreamDisconnected = gocbcore.ErrStreamDisconnected
	// ErrStreamTooSlow occurs when a stream is closed due to being too slow at consuming data.
	ErrStreamTooSlow = gocbcore.ErrStreamTooSlow

	// ErrKeyNotFound occurs when the key is not found on the server.
	ErrKeyNotFound = gocbcore.ErrKeyNotFound
	// ErrKeyExists occurs when the key already exists on the server.
	ErrKeyExists = gocbcore.ErrKeyExists
	// ErrTooBig occurs when the document is too big to be stored.
	ErrTooBig = gocbcore.ErrTooBig
	// ErrNotStored occurs when an item fails to be stored.  Usually an append/prepend to missing key.
	ErrNotStored = gocbcore.ErrNotStored
	// ErrAuthError occurs when there is an issue with authentication (bad password?).
	ErrAuthError = gocbcore.ErrAuthError
	// ErrRangeError occurs when an invalid range is specified.
	ErrRangeError = gocbcore.ErrRangeError
	// ErrRollback occurs when a server rollback has occurred making the operation no longer valid.
	ErrRollback = gocbcore.ErrRollback
	// ErrAccessError occurs when you do not have access to the specified resource.
	ErrAccessError = gocbcore.ErrAccessError
	// ErrOutOfMemory occurs when the server has run out of memory to process requests.
	ErrOutOfMemory = gocbcore.ErrOutOfMemory
	// ErrNotSupported occurs when an operation is performed which is not supported.
	ErrNotSupported = gocbcore.ErrNotSupported
	// ErrInternalError occurs when an internal error has prevented an operation from succeeding.
	ErrInternalError = gocbcore.ErrInternalError
	// ErrBusy occurs when the server is too busy to handle your operation.
	ErrBusy = gocbcore.ErrBusy
	// ErrTmpFail occurs when the server is not immediately able to handle your request.
	ErrTmpFail = gocbcore.ErrTmpFail

	// ErrSubDocPathNotFound occurs when a sub-document operation targets a path
	// which does not exist in the specifie document.
	ErrSubDocPathNotFound = gocbcore.ErrSubDocPathNotFound
	// ErrSubDocPathMismatch occurs when a sub-document operation specifies a path
	// which does not match the document structure (field access on an array).
	ErrSubDocPathMismatch = gocbcore.ErrSubDocPathMismatch
	// ErrSubDocPathInvalid occurs when a sub-document path could not be parsed.
	ErrSubDocPathInvalid = gocbcore.ErrSubDocPathInvalid
	// ErrSubDocPathTooBig occurs when a sub-document path is too big.
	ErrSubDocPathTooBig = gocbcore.ErrSubDocPathTooBig
	// ErrSubDocDocTooDeep occurs when an operation would cause a document to be
	// nested beyond the depth limits allowed by the sub-document specification.
	ErrSubDocDocTooDeep = gocbcore.ErrSubDocDocTooDeep
	// ErrSubDocCantInsert occurs when a sub-document operation could not insert.
	ErrSubDocCantInsert = gocbcore.ErrSubDocCantInsert
	// ErrSubDocNotJson occurs when a sub-document operation is performed on a
	// document which is not JSON.
	ErrSubDocNotJson = gocbcore.ErrSubDocNotJson
	// ErrSubDocBadRange occurs when a sub-document operation is performed with
	// a bad range.
	ErrSubDocBadRange = gocbcore.ErrSubDocBadRange
	// ErrSubDocBadDelta occurs when a sub-document counter operation is performed
	// and the specified delta is not valid.
	ErrSubDocBadDelta = gocbcore.ErrSubDocBadDelta
	// ErrSubDocPathExists occurs when a sub-document operation expects a path not
	// to exists, but the path was found in the document.
	ErrSubDocPathExists = gocbcore.ErrSubDocPathExists
	// ErrSubDocValueTooDeep occurs when a sub-document operation specifies a value
	// which is deeper than the depth limits of the sub-document specification.
	ErrSubDocValueTooDeep = gocbcore.ErrSubDocValueTooDeep
	// ErrSubDocBadCombo occurs when a multi-operation sub-document operation is
	// performed and operations within the package of ops conflict with each other.
	ErrSubDocBadCombo = gocbcore.ErrSubDocBadCombo
	// ErrSubDocBadMulti occurs when a multi-operation sub-document operation is
	// performed and operations within the package of ops conflict with each other.
	ErrSubDocBadMulti = gocbcore.ErrSubDocBadMulti
	// ErrSubDocSuccessDeleted occurs when a multi-operation sub-document operation
	// is performed on a soft-deleted document.
	ErrSubDocSuccessDeleted = gocbcore.ErrSubDocSuccessDeleted

	// ErrSubDocXattrInvalidFlagCombo occurs when an invalid set of
	// extended-attribute flags is passed to a sub-document operation.
	ErrSubDocXattrInvalidFlagCombo = gocbcore.ErrSubDocXattrInvalidFlagCombo
	// ErrSubDocXattrInvalidKeyCombo occurs when an invalid set of key operations
	// are specified for a extended-attribute sub-document operation.
	ErrSubDocXattrInvalidKeyCombo = gocbcore.ErrSubDocXattrInvalidKeyCombo
	// ErrSubDocXattrUnknownMacro occurs when an invalid macro value is specified.
	ErrSubDocXattrUnknownMacro = gocbcore.ErrSubDocXattrUnknownMacro
	// ErrSubDocXattrUnknownVAttr occurs when an invalid virtual attribute is specified.
	ErrSubDocXattrUnknownVAttr = gocbcore.ErrSubDocXattrUnknownVAttr
	// ErrSubDocXattrCannotModifyVAttr occurs when a mutation is attempted upon
	// a virtual attribute (which are immutable by definition).
	ErrSubDocXattrCannotModifyVAttr = gocbcore.ErrSubDocXattrCannotModifyVAttr
	// ErrSubDocMultiPathFailureDeleted occurs when a Multi Path Failure occurs on
	// a soft-deleted document.
	ErrSubDocMultiPathFailureDeleted = gocbcore.ErrSubDocMultiPathFailureDeleted
)

Functions

func SetLogger

func SetLogger(logger Logger)

SetLogger sets a logger to be used by the library. A logger can be obtained via the DefaultStdioLogger() or VerboseStdioLogger() functions. You can also implement your own logger using the Logger interface.

Types

type AnalyticsQuery

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

AnalyticsQuery represents a pending Analytics query.

func NewAnalyticsQuery

func NewAnalyticsQuery(statement string) *AnalyticsQuery

NewAnalyticsQuery creates a new N1qlQuery object from a query string.

type AnalyticsResults

type AnalyticsResults interface {
	One(valuePtr interface{}) error
	Next(valuePtr interface{}) bool
	NextBytes() []byte
	Close() error

	RequestId() string
	ClientContextId() string
}

AnalyticsResults allows access to the results of a Analytics query.

type AppendOp

type AppendOp struct {
	Key   string
	Value string
	Cas   Cas
	Err   error
	// contains filtered or unexported fields
}

AppendOp represents a type of `BulkOp` used for Append operations. See BulkOp.

type Authenticator

type Authenticator interface {
	// contains filtered or unexported methods
}

Authenticator provides an interface to authenticate to each service.

type Bucket

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

Bucket is an interface representing a single bucket within a cluster.

func (*Bucket) Append

func (b *Bucket) Append(key, value string) (Cas, error)

Append appends a string value to a document.

func (*Bucket) AppendDura

func (b *Bucket) AppendDura(key, value string, replicateTo, persistTo uint) (Cas, error)

AppendDura appends a string value to a document. Additionally checks document durability.

func (*Bucket) AppendMt

func (b *Bucket) AppendMt(key, value string) (Cas, MutationToken, error)

AppendMt performs a Append operation and includes MutationToken in the results.

func (*Bucket) BulkOperationTimeout

func (b *Bucket) BulkOperationTimeout() time.Duration

BulkOperationTimeout returns the maximum amount of time to wait for a bulk op to succeed.

func (*Bucket) Close

func (b *Bucket) Close() error

Close the instance’s underlying socket resources. Note that operations pending on the connection may fail.

func (*Bucket) Counter

func (b *Bucket) Counter(key string, delta, initial int64, expiry uint32) (uint64, Cas, error)

Counter performs an atomic addition or subtraction for an integer document. Passing a non-negative `initial` value will cause the document to be created if it did not already exist.

func (*Bucket) CounterDura

func (b *Bucket) CounterDura(key string, delta, initial int64, expiry uint32, replicateTo, persistTo uint) (uint64, Cas, error)

CounterDura performs an atomic addition or subtraction for an integer document. Additionally checks document durability.

func (*Bucket) CounterMt

func (b *Bucket) CounterMt(key string, delta, initial int64, expiry uint32) (uint64, Cas, MutationToken, error)

CounterMt performs a Counter operation and includes MutationToken in the results.

func (*Bucket) Do

func (b *Bucket) Do(ops []BulkOp) error

Do execute one or more `BulkOp` items in parallel.

func (*Bucket) DurabilityPollTimeout

func (b *Bucket) DurabilityPollTimeout() time.Duration

DurabilityPollTimeout returns the amount of time waiting between durability polls.

func (*Bucket) DurabilityTimeout

func (b *Bucket) DurabilityTimeout() time.Duration

DurabilityTimeout returns the maximum amount of time to wait for durability to succeed.

func (*Bucket) ExecuteN1qlQuery

func (b *Bucket) ExecuteN1qlQuery(q *N1qlQuery, params interface{}) (QueryResults, error)

ExecuteN1qlQuery performs a n1ql query and returns a list of rows or an error.

func (*Bucket) ExecuteSearchQuery

func (b *Bucket) ExecuteSearchQuery(q *SearchQuery) (SearchResults, error)

ExecuteSearchQuery performs a view query and returns a list of rows or an error.

Experimental: This API is subject to change at any time.

func (*Bucket) ExecuteSpatialQuery

func (b *Bucket) ExecuteSpatialQuery(q *SpatialQuery) (ViewResults, error)

ExecuteSpatialQuery performs a spatial query and returns a list of rows or an error.

func (*Bucket) ExecuteViewQuery

func (b *Bucket) ExecuteViewQuery(q *ViewQuery) (ViewResults, error)

ExecuteViewQuery performs a view query and returns a list of rows or an error.

func (*Bucket) Get

func (b *Bucket) Get(key string, valuePtr interface{}) (Cas, error)

Get retrieves a document from the bucket

func (*Bucket) GetAndLock

func (b *Bucket) GetAndLock(key string, lockTime uint32, valuePtr interface{}) (Cas, error)

GetAndLock locks a document for a period of time, providing exclusive RW access to it.

func (*Bucket) GetAndTouch

func (b *Bucket) GetAndTouch(key string, expiry uint32, valuePtr interface{}) (Cas, error)

GetAndTouch retrieves a document and simultaneously updates its expiry time.

func (*Bucket) GetReplica

func (b *Bucket) GetReplica(key string, valuePtr interface{}, replicaIdx int) (Cas, error)

GetReplica returns the value of a particular document from a replica server.

func (*Bucket) Insert

func (b *Bucket) Insert(key string, value interface{}, expiry uint32) (Cas, error)

Insert inserts a new document to the bucket.

func (*Bucket) InsertDura

func (b *Bucket) InsertDura(key string, value interface{}, expiry uint32, replicateTo, persistTo uint) (Cas, error)

InsertDura inserts a new document to the bucket. Additionally checks document durability.

func (*Bucket) InsertMt

func (b *Bucket) InsertMt(key string, value interface{}, expiry uint32) (Cas, MutationToken, error)

InsertMt performs a Insert operation and includes MutationToken in the results.

func (*Bucket) Internal

func (b *Bucket) Internal() *BucketInternal

Internal methods, not safe to be consumed by third parties.

func (*Bucket) InvalidateQueryCache

func (b *Bucket) InvalidateQueryCache()

InvalidateQueryCache forces the internal cache of prepared queries to be cleared.

Queries to be cached are controlled by the Adhoc() method of N1qlQuery.

func (*Bucket) IoRouter

func (b *Bucket) IoRouter() *gocbcore.Agent

IoRouter returns the underlying gocb agent managing connections.

func (*Bucket) ListAppend

func (b *Bucket) ListAppend(key string, value interface{}, createList bool) (Cas, error)

ListAppend inserts an item to the end of a list document.

func (*Bucket) ListGet

func (b *Bucket) ListGet(key string, index uint, valuePtr interface{}) (Cas, error)

ListGet retrieves an item from a list document by index.

func (*Bucket) ListPrepend

func (b *Bucket) ListPrepend(key string, value interface{}, createList bool) (Cas, error)

ListPrepend inserts an item to the beginning of a list document.

func (*Bucket) ListRemove

func (b *Bucket) ListRemove(key string, index uint) (Cas, error)

ListRemove removes an item from a list document by its index.

func (*Bucket) ListSet

func (b *Bucket) ListSet(key string, index uint, value interface{}) (Cas, error)

ListSet replaces the item at a particular index of a list document.

func (*Bucket) ListSize

func (b *Bucket) ListSize(key string) (uint, Cas, error)

ListSize returns the current number of items in a list. PERFORMANCE NOTICE: This currently performs a full document fetch...

func (*Bucket) LookupIn

func (b *Bucket) LookupIn(key string) *LookupInBuilder

LookupIn creates a sub-document lookup operation builder.

func (*Bucket) LookupInEx

func (b *Bucket) LookupInEx(key string, flags SubdocDocFlag) *LookupInBuilder

LookupInEx creates a sub-document lookup operation builder.

func (*Bucket) Manager

func (b *Bucket) Manager(username, password string) *BucketManager

Manager returns a BucketManager for performing management operations on this bucket.

func (*Bucket) MapAdd

func (b *Bucket) MapAdd(key, path string, value interface{}, createMap bool) (Cas, error)

MapAdd inserts an item to a map document.

func (*Bucket) MapGet

func (b *Bucket) MapGet(key, path string, valuePtr interface{}) (Cas, error)

MapGet retrieves a single item from a map document by its key.

func (*Bucket) MapRemove

func (b *Bucket) MapRemove(key, path string) (Cas, error)

MapRemove removes a specified key from the specified map document.

func (*Bucket) MapSize

func (b *Bucket) MapSize(key string) (uint, Cas, error)

MapSize returns the current number of items in a map document. PERFORMANCE NOTICE: This currently performs a full document fetch...

func (*Bucket) MutateIn

func (b *Bucket) MutateIn(key string, cas Cas, expiry uint32) *MutateInBuilder

MutateIn creates a sub-document mutation operation builder.

func (*Bucket) MutateInEx

func (b *Bucket) MutateInEx(key string, flags SubdocDocFlag, cas Cas, expiry uint32) *MutateInBuilder

MutateInEx creates a sub-document mutation operation builder.

func (*Bucket) N1qlTimeout

func (b *Bucket) N1qlTimeout() time.Duration

N1qlTimeout returns the maximum amount of time to wait for a N1QL query to complete.

func (*Bucket) Name

func (b *Bucket) Name() string

Name returns the name of the bucket we are connected to.

func (*Bucket) OperationTimeout

func (b *Bucket) OperationTimeout() time.Duration

OperationTimeout returns the maximum amount of time to wait for an operation to succeed.

func (*Bucket) Prepend

func (b *Bucket) Prepend(key, value string) (Cas, error)

Prepend prepends a string value to a document.

func (*Bucket) PrependDura

func (b *Bucket) PrependDura(key, value string, replicateTo, persistTo uint) (Cas, error)

PrependDura prepends a string value to a document. Additionally checks document durability.

func (*Bucket) PrependMt

func (b *Bucket) PrependMt(key, value string) (Cas, MutationToken, error)

PrependMt performs a Prepend operation and includes MutationToken in the results.

func (*Bucket) QueuePop

func (b *Bucket) QueuePop(key string, valuePtr interface{}) (Cas, error)

QueuePop pops the oldest item from a queue and returns it.

func (*Bucket) QueuePush

func (b *Bucket) QueuePush(key string, value interface{}, createQueue bool) (Cas, error)

QueuePush adds a new item to the end of a queue.

func (*Bucket) QueueSize

func (b *Bucket) QueueSize(key string) (uint, Cas, error)

QueueSize returns the current size of a queue.

func (*Bucket) Remove

func (b *Bucket) Remove(key string, cas Cas) (Cas, error)

Remove removes a document from the bucket.

func (*Bucket) RemoveDura

func (b *Bucket) RemoveDura(key string, cas Cas, replicateTo, persistTo uint) (Cas, error)

RemoveDura removes a document from the bucket. Additionally checks document durability.

func (*Bucket) RemoveMt

func (b *Bucket) RemoveMt(key string, cas Cas) (Cas, MutationToken, error)

RemoveMt performs a Remove operation and includes MutationToken in the results.

func (*Bucket) Replace

func (b *Bucket) Replace(key string, value interface{}, cas Cas, expiry uint32) (Cas, error)

Replace replaces a document in the bucket.

func (*Bucket) ReplaceDura

func (b *Bucket) ReplaceDura(key string, value interface{}, cas Cas, expiry uint32, replicateTo, persistTo uint) (Cas, error)

ReplaceDura replaces a document in the bucket. Additionally checks document durability.

func (*Bucket) ReplaceMt

func (b *Bucket) ReplaceMt(key string, value interface{}, cas Cas, expiry uint32) (Cas, MutationToken, error)

ReplaceMt performs a Replace operation and includes MutationToken in the results.

func (*Bucket) SetAdd

func (b *Bucket) SetAdd(key string, value interface{}, createSet bool) (Cas, error)

SetAdd adds a new value to a set document.

func (*Bucket) SetBulkOperationTimeout

func (b *Bucket) SetBulkOperationTimeout(timeout time.Duration)

SetBulkOperationTimeout sets the maxium amount of time to wait for a bulk op to succeed.

func (*Bucket) SetDurabilityPollTimeout

func (b *Bucket) SetDurabilityPollTimeout(timeout time.Duration)

SetDurabilityPollTimeout sets the amount of time waiting between durability polls.

func (*Bucket) SetDurabilityTimeout

func (b *Bucket) SetDurabilityTimeout(timeout time.Duration)

SetDurabilityTimeout sets the maximum amount of time to wait for durability to succeed.

func (*Bucket) SetExists

func (b *Bucket) SetExists(key string, value interface{}) (bool, Cas, error)

SetExists checks if a particular value exists within the specified set document. PERFORMANCE WARNING: This performs a full set fetch and compare.

func (*Bucket) SetN1qlTimeout

func (b *Bucket) SetN1qlTimeout(timeout time.Duration)

SetN1qlTimeout sets the maximum amount of time to wait for a N1QL query to complete.

func (*Bucket) SetOperationTimeout

func (b *Bucket) SetOperationTimeout(timeout time.Duration)

SetOperationTimeout sets the maximum amount of time to wait for an operation to succeed.

func (*Bucket) SetRemove

func (b *Bucket) SetRemove(key string, value interface{}) (Cas, error)

SetRemove removes a specified value from the specified set document. WARNING: This relies on Go's interface{} comparison behaviour! PERFORMANCE WARNING: This performs full set fetch, modify, store cycles.

func (*Bucket) SetSize

func (b *Bucket) SetSize(key string) (uint, Cas, error)

SetSize returns the current number of values in a set. PERFORMANCE NOTICE: This currently performs a full document fetch...

func (*Bucket) SetTranscoder

func (b *Bucket) SetTranscoder(transcoder Transcoder)

SetTranscoder specifies a Transcoder to use when translating documents from their

raw byte format to Go types and back.

func (*Bucket) SetViewTimeout

func (b *Bucket) SetViewTimeout(timeout time.Duration)

SetViewTimeout sets the maximum amount of time to wait for a view query to complete.

func (*Bucket) Stats

func (b *Bucket) Stats(key string) (statsOut ServerStats, errOut error)

Stats returns various server statistics from the cluster.

func (*Bucket) Touch

func (b *Bucket) Touch(key string, cas Cas, expiry uint32) (Cas, error)

Touch touches a document, specifying a new expiry time for it.

func (*Bucket) TouchDura

func (b *Bucket) TouchDura(key string, cas Cas, expiry uint32, replicateTo, persistTo uint) (Cas, error)

TouchDura touches a document, specifying a new expiry time for it. Additionally checks document durability.

func (*Bucket) UUID

func (b *Bucket) UUID() string

UUID returns the uuid of the bucket we are connected to.

func (*Bucket) Unlock

func (b *Bucket) Unlock(key string, cas Cas) (Cas, error)

Unlock unlocks a document which was locked with GetAndLock.

func (*Bucket) Upsert

func (b *Bucket) Upsert(key string, value interface{}, expiry uint32) (Cas, error)

Upsert inserts or replaces a document in the bucket.

func (*Bucket) UpsertDura

func (b *Bucket) UpsertDura(key string, value interface{}, expiry uint32, replicateTo, persistTo uint) (Cas, error)

UpsertDura inserts or replaces a document in the bucket. Additionally checks document durability.

func (*Bucket) UpsertMt

func (b *Bucket) UpsertMt(key string, value interface{}, expiry uint32) (Cas, MutationToken, error)

UpsertMt performs a Upsert operation and includes MutationToken in the results.

func (*Bucket) ViewTimeout

func (b *Bucket) ViewTimeout() time.Duration

ViewTimeout returns the maximum amount of time to wait for a view query to complete.

type BucketAuthenticator

type BucketAuthenticator struct {
	Password string
}

BucketAuthenticator provides a password for a single bucket.

type BucketAuthenticatorMap

type BucketAuthenticatorMap map[string]BucketAuthenticator

BucketAuthenticatorMap is a map of bucket name to BucketAuthenticator.

type BucketInternal

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

BucketInternal holds various internally used bucket extension methods.

Internal: This should never be used and is not supported.

func (*BucketInternal) GetRandom

func (bi *BucketInternal) GetRandom(valuePtr interface{}) (string, Cas, error)

GetRandom retrieves a document from the bucket

func (*BucketInternal) RemoveMeta

func (bi *BucketInternal) RemoveMeta(key string, value, extra []byte, datatype uint8, options, flags, expiry uint32, cas, revseqno uint64) (Cas, error)

RemoveMeta removes a document (with metadata) from the bucket.

func (*BucketInternal) UpsertMeta

func (bi *BucketInternal) UpsertMeta(key string, value, extra []byte, datatype uint8, options, flags, expiry uint32, cas, revseqno uint64) (Cas, error)

UpsertMeta inserts or replaces (with metadata) a document in a bucket.

type BucketManager

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

BucketManager provides methods for performing bucket management operations. See ClusterManager for methods that allow creating and removing buckets themselves.

func (*BucketManager) BuildDeferredIndexes

func (bm *BucketManager) BuildDeferredIndexes() ([]string, error)

BuildDeferredIndexes builds all indexes which are currently in deferred state.

func (*BucketManager) CreateIndex

func (bm *BucketManager) CreateIndex(indexName string, fields []string, ignoreIfExists, deferred bool) error

CreateIndex creates an index over the specified fields.

func (*BucketManager) CreatePrimaryIndex

func (bm *BucketManager) CreatePrimaryIndex(customName string, ignoreIfExists, deferred bool) error

CreatePrimaryIndex creates a primary index. An empty customName uses the default naming.

func (*BucketManager) DropIndex

func (bm *BucketManager) DropIndex(indexName string, ignoreIfNotExists bool) error

DropIndex drops a specific index by name.

func (*BucketManager) DropPrimaryIndex

func (bm *BucketManager) DropPrimaryIndex(customName string, ignoreIfNotExists bool) error

DropPrimaryIndex drops the primary index. Pass an empty customName for unnamed primary indexes.

func (*BucketManager) Flush

func (bm *BucketManager) Flush() error

Flush will delete all the of the data from a bucket. Keep in mind that you must have flushing enabled in the buckets configuration.

func (*BucketManager) GetDesignDocument

func (bm *BucketManager) GetDesignDocument(name string) (*DesignDocument, error)

GetDesignDocument retrieves a single design document for the given bucket..

func (*BucketManager) GetDesignDocuments

func (bm *BucketManager) GetDesignDocuments() ([]*DesignDocument, error)

GetDesignDocuments will retrieve all design documents for the given bucket.

func (*BucketManager) GetIndexes

func (bm *BucketManager) GetIndexes() ([]IndexInfo, error)

GetIndexes returns a list of all currently registered indexes.

func (*BucketManager) InsertDesignDocument

func (bm *BucketManager) InsertDesignDocument(ddoc *DesignDocument) error

InsertDesignDocument inserts a design document to the given bucket.

func (*BucketManager) RemoveDesignDocument

func (bm *BucketManager) RemoveDesignDocument(name string) error

RemoveDesignDocument will remove a design document from the given bucket.

func (*BucketManager) UpsertDesignDocument

func (bm *BucketManager) UpsertDesignDocument(ddoc *DesignDocument) error

UpsertDesignDocument will insert a design document to the given bucket, or update an existing design document with the same name.

func (*BucketManager) WatchIndexes

func (bm *BucketManager) WatchIndexes(watchList []string, watchPrimary bool, timeout time.Duration) error

WatchIndexes waits for a set of indexes to come online

type BucketSettings

type BucketSettings struct {
	FlushEnabled  bool
	IndexReplicas bool
	Name          string
	Password      string
	Quota         int
	Replicas      int
	Type          BucketType
}

BucketSettings holds information about the settings for a bucket.

type BucketType

type BucketType int

BucketType specifies the kind of bucket

type BulkOp

type BulkOp interface {
	// contains filtered or unexported methods
}

BulkOp represents a single operation that can be submitted (within a list of more operations) to .Do() You can create a bulk operation by instantiating one of the implementations of BulkOp, such as GetOp, UpsertOp, ReplaceOp, and more.

type Cas

type Cas gocbcore.Cas

Cas represents the specific state of a document on the cluster.

type Cluster

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

Cluster represents a connection to a specific Couchbase cluster.

func Connect

func Connect(connSpecStr string) (*Cluster, error)

Connect creates a new Cluster object for a specific cluster.

func (*Cluster) AnalyticsTimeout

func (c *Cluster) AnalyticsTimeout() time.Duration

AnalyticsTimeout returns the maximum time to wait for a cluster-level Analytics query to complete.

func (*Cluster) Authenticate

func (c *Cluster) Authenticate(auth Authenticator) error

Authenticate specifies an Authenticator interface to use to authenticate with cluster services.

func (*Cluster) ConnectTimeout

func (c *Cluster) ConnectTimeout() time.Duration

ConnectTimeout returns the maximum time to wait when attempting to connect to a bucket.

func (*Cluster) EnableAnalytics

func (c *Cluster) EnableAnalytics(hosts []string)

EnableAnalytics allows you to specify Analytics hosts to perform queries against.

Experimental: This API is only needed temporarily until full integration of the Analytics service into Couchbase Server has been completed.

func (*Cluster) ExecuteAnalyticsQuery

func (c *Cluster) ExecuteAnalyticsQuery(q *AnalyticsQuery) (AnalyticsResults, error)

ExecuteAnalyticsQuery performs an analytics query and returns a list of rows or an error.

Experimental: This API is subject to change at any time.

func (*Cluster) ExecuteN1qlQuery

func (c *Cluster) ExecuteN1qlQuery(q *N1qlQuery, params interface{}) (QueryResults, error)

ExecuteN1qlQuery performs a n1ql query and returns a list of rows or an error.

func (*Cluster) ExecuteSearchQuery

func (c *Cluster) ExecuteSearchQuery(q *SearchQuery) (SearchResults, error)

ExecuteSearchQuery performs a n1ql query and returns a list of rows or an error.

Experimental: This API is subject to change at any time.

func (*Cluster) FtsTimeout

func (c *Cluster) FtsTimeout() time.Duration

FtsTimeout returns the maximum time to wait for a cluster-level FTS query to complete.

func (*Cluster) InvalidateQueryCache

func (c *Cluster) InvalidateQueryCache()

InvalidateQueryCache forces the internal cache of prepared queries to be cleared.

func (*Cluster) Manager

func (c *Cluster) Manager(username, password string) *ClusterManager

Manager returns a ClusterManager object for performing cluster management operations on this cluster.

func (*Cluster) N1qlTimeout

func (c *Cluster) N1qlTimeout() time.Duration

N1qlTimeout returns the maximum time to wait for a cluster-level N1QL query to complete.

func (*Cluster) NmvRetryDelay

func (c *Cluster) NmvRetryDelay() time.Duration

NmvRetryDelay returns the time to wait between retrying an operation due to not my vbucket.

func (*Cluster) OpenBucket

func (c *Cluster) OpenBucket(bucket, password string) (*Bucket, error)

OpenBucket opens a new connection to the specified bucket.

func (*Cluster) OpenBucketWithMt

func (c *Cluster) OpenBucketWithMt(bucket, password string) (*Bucket, error)

OpenBucketWithMt opens a new connection to the specified bucket and enables mutation tokens. MutationTokens allow you to execute queries and durability requirements with very specific operation-level consistency.

func (*Cluster) OpenStreamingBucket

func (c *Cluster) OpenStreamingBucket(streamName, bucket, password string) (*StreamingBucket, error)

OpenStreamingBucket opens a new connection to the specified bucket for the purpose of streaming data.

func (*Cluster) ServerConnectTimeout

func (c *Cluster) ServerConnectTimeout() time.Duration

ServerConnectTimeout returns the maximum time to attempt to connect to a single node.

func (*Cluster) SetAnalyticsTimeout

func (c *Cluster) SetAnalyticsTimeout(timeout time.Duration)

SetAnalyticsTimeout sets the maximum time to wait for a cluster-level Analytics query to complete.

func (*Cluster) SetConnectTimeout

func (c *Cluster) SetConnectTimeout(timeout time.Duration)

SetConnectTimeout sets the maximum time to wait when attempting to connect to a bucket.

func (*Cluster) SetFtsTimeout

func (c *Cluster) SetFtsTimeout(timeout time.Duration)

SetFtsTimeout sets the maximum time to wait for a cluster-level FTS query to complete.

func (*Cluster) SetN1qlTimeout

func (c *Cluster) SetN1qlTimeout(timeout time.Duration)

SetN1qlTimeout sets the maximum time to wait for a cluster-level N1QL query to complete.

func (*Cluster) SetNmvRetryDelay

func (c *Cluster) SetNmvRetryDelay(delay time.Duration)

SetNmvRetryDelay sets the time to wait between retrying an operation due to not my vbucket.

func (*Cluster) SetServerConnectTimeout

func (c *Cluster) SetServerConnectTimeout(timeout time.Duration)

SetServerConnectTimeout sets the maximum time to attempt to connect to a single node.

type ClusterAuthenticator

type ClusterAuthenticator struct {
	Buckets  BucketAuthenticatorMap
	Username string
	Password string
}

ClusterAuthenticator implements an Authenticator which uses a list of buckets and passwords.

type ClusterManager

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

ClusterManager provides methods for performing cluster management operations.

func (*ClusterManager) GetBuckets

func (cm *ClusterManager) GetBuckets() ([]*BucketSettings, error)

GetBuckets returns a list of all active buckets on the cluster.

func (*ClusterManager) GetUsers

func (cm *ClusterManager) GetUsers() ([]*User, error)

GetUsers returns a list of all users on the cluster.

func (*ClusterManager) InsertBucket

func (cm *ClusterManager) InsertBucket(settings *BucketSettings) error

InsertBucket creates a new bucket on the cluster.

func (*ClusterManager) RemoveBucket

func (cm *ClusterManager) RemoveBucket(name string) error

RemoveBucket will delete a bucket from the cluster by name.

func (*ClusterManager) RemoveUser

func (cm *ClusterManager) RemoveUser(name string) error

RemoveUser removes a built-in RBAC user on the cluster.

func (*ClusterManager) UpdateBucket

func (cm *ClusterManager) UpdateBucket(settings *BucketSettings) error

UpdateBucket will update the settings for a specific bucket on the cluster.

func (*ClusterManager) UpsertUser

func (cm *ClusterManager) UpsertUser(name string, settings *UserSettings) error

UpsertUser updates a built-in RBAC user on the cluster.

type ConsistencyMode

type ConsistencyMode int

ConsistencyMode indicates the level of data consistency desired for a query.

type CounterOp

type CounterOp struct {
	Key     string
	Delta   int64
	Initial int64
	Expiry  uint32
	Cas     Cas
	Value   uint64
	Err     error
	// contains filtered or unexported fields
}

CounterOp represents a type of `BulkOp` used for Counter operations. See BulkOp.

type DefaultTranscoder

type DefaultTranscoder struct {
}

DefaultTranscoder implements the default transcoding behaviour of all Couchbase SDKs.

func (DefaultTranscoder) Decode

func (t DefaultTranscoder) Decode(bytes []byte, flags uint32, out interface{}) error

Decode applies the default Couchbase transcoding behaviour to decode into a Go type.

func (DefaultTranscoder) Encode

func (t DefaultTranscoder) Encode(value interface{}) ([]byte, uint32, error)

Encode applies the default Couchbase transcoding behaviour to encode a Go type.

type DesignDocument

type DesignDocument struct {
	Name         string          `json:"-"`
	Views        map[string]View `json:"views,omitempty"`
	SpatialViews map[string]View `json:"spatial,omitempty"`
}

DesignDocument represents a Couchbase design document containing multiple views.

type DocumentFragment

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

DocumentFragment represents multiple chunks of a full Document.

func (*DocumentFragment) Cas

func (frag *DocumentFragment) Cas() Cas

Cas returns the Cas of the Document

func (*DocumentFragment) Content

func (frag *DocumentFragment) Content(path string, valuePtr interface{}) error

Content retrieves the value of the operation by its path. The path is the path provided to the operation

func (*DocumentFragment) ContentByIndex

func (frag *DocumentFragment) ContentByIndex(idx int, valuePtr interface{}) error

ContentByIndex retrieves the value of the operation by its index. The index is the position of the operation as it was added to the builder.

func (*DocumentFragment) Exists

func (frag *DocumentFragment) Exists(path string) bool

Exists checks whether the indicated path exists in this DocumentFragment and no errors were returned from the server.

func (*DocumentFragment) MutationToken

func (frag *DocumentFragment) MutationToken() MutationToken

MutationToken returns the MutationToken for the change represented by this DocumentFragment.

type GetAndTouchOp

type GetAndTouchOp struct {
	Key    string
	Value  interface{}
	Expiry uint32
	Cas    Cas
	Err    error
	// contains filtered or unexported fields
}

GetAndTouchOp represents a type of `BulkOp` used for GetAndTouch operations. See BulkOp.

type GetOp

type GetOp struct {
	Key   string
	Value interface{}
	Cas   Cas
	Err   error
	// contains filtered or unexported fields
}

GetOp represents a type of `BulkOp` used for Get operations. See BulkOp.

type IndexInfo

type IndexInfo struct {
	Name      string    `json:"name"`
	IsPrimary bool      `json:"is_primary"`
	Type      IndexType `json:"using"`
	State     string    `json:"state"`
	Keyspace  string    `json:"keyspace_id"`
	Namespace string    `json:"namespace_id"`
	IndexKey  []string  `json:"index_key"`
}

IndexInfo represents a Couchbase GSI index.

type IndexType

type IndexType string

IndexType provides information on the type of indexer used for an index.

type InsertOp

type InsertOp struct {
	Key    string
	Value  interface{}
	Expiry uint32
	Cas    Cas
	Err    error
	// contains filtered or unexported fields
}

InsertOp represents a type of `BulkOp` used for Insert operations. See BulkOp.

type LogLevel

type LogLevel gocbcore.LogLevel

LogLevel specifies the severity of a log message.

type Logger

type Logger interface {
	// Outputs logging information:
	// level is the verbosity level
	// offset is the position within the calling stack from which the message
	// originated. This is useful for contextual loggers which retrieve file/line
	// information.
	Log(level LogLevel, offset int, format string, v ...interface{}) error
}

Logger defines a logging interface. You can either use one of the default loggers (DefaultStdioLogger(), VerboseStdioLogger()) or implement your own.

func DefaultStdioLogger

func DefaultStdioLogger() Logger

DefaultStdioLogger gets the default standard I/O logger.

gocb.SetLogger(gocb.DefaultStdioLogger())

func VerboseStdioLogger

func VerboseStdioLogger() Logger

VerboseStdioLogger is a more verbose level of DefaultStdioLogger(). Messages pertaining to the scheduling of ordinary commands (and their responses) will also be emitted.

gocb.SetLogger(gocb.VerboseStdioLogger())

type LookupInBuilder

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

LookupInBuilder is a builder used to create a set of sub-document lookup operations.

func (*LookupInBuilder) Execute

func (set *LookupInBuilder) Execute() (*DocumentFragment, error)

Execute executes this set of lookup operations on the bucket.

func (*LookupInBuilder) Exists

func (set *LookupInBuilder) Exists(path string) *LookupInBuilder

Exists is similar to Get(), but does not actually retrieve the value from the server. This may save bandwidth if you only need to check for the existence of a path (without caring for its content). You can check the status of this operation by using .Content (and ignoring the value) or .Exists()

func (*LookupInBuilder) ExistsEx

func (set *LookupInBuilder) ExistsEx(path string, flags SubdocFlag) *LookupInBuilder

ExistsEx allows you to perform a sub-document Exists operation with flags

Experimental: This API is subject to change at any time.

func (*LookupInBuilder) Get

func (set *LookupInBuilder) Get(path string) *LookupInBuilder

Get indicates a path to be retrieved from the document. The value of the path can later be retrieved (after .Execute()) using the Content or ContentByIndex method. The path syntax follows N1QL's path syntax (e.g. `foo.bar.baz`).

func (*LookupInBuilder) GetCount

func (set *LookupInBuilder) GetCount(path string) *LookupInBuilder

GetCount allows you to retrieve the number of items in an array or keys within an dictionary within an element of a document.

func (*LookupInBuilder) GetCountEx

func (set *LookupInBuilder) GetCountEx(path string, flags SubdocFlag) *LookupInBuilder

GetCountEx allows you to perform a sub-document GetCount operation with flags

func (*LookupInBuilder) GetEx

func (set *LookupInBuilder) GetEx(path string, flags SubdocFlag) *LookupInBuilder

GetEx allows you to perform a sub-document Get operation with flags

Experimental: This API is subject to change at any time.

type MultiError

type MultiError struct {
	Errors []error
}

MultiError encapsulates multiple errors that may be returned by one method.

func (*MultiError) Error

func (e *MultiError) Error() string

type MutateInBuilder

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

MutateInBuilder is a builder used to create a set of sub-document mutation operations.

func (*MutateInBuilder) ArrayAddUnique

func (set *MutateInBuilder) ArrayAddUnique(path string, value interface{}, createParents bool) *MutateInBuilder

ArrayAddUnique adds an dictionary add unique operation to this mutation operation set.

func (*MutateInBuilder) ArrayAddUniqueEx

func (set *MutateInBuilder) ArrayAddUniqueEx(path string, value interface{}, flags SubdocFlag) *MutateInBuilder

ArrayAddUniqueEx allows you to perform a sub-document ArrayAddUnique operation with flags

Experimental: This API is subject to change at any time.

func (*MutateInBuilder) ArrayAppend

func (set *MutateInBuilder) ArrayAppend(path string, value interface{}, createParents bool) *MutateInBuilder

ArrayAppend adds an element to the end (i.e. right) of an array

func (*MutateInBuilder) ArrayAppendEx

func (set *MutateInBuilder) ArrayAppendEx(path string, value interface{}, flags SubdocFlag) *MutateInBuilder

ArrayAppendEx allows you to perform a sub-document ArrayAppend operation with flags

Experimental: This API is subject to change at any time.

func (*MutateInBuilder) ArrayAppendMulti

func (set *MutateInBuilder) ArrayAppendMulti(path string, values interface{}, createParents bool) *MutateInBuilder

ArrayAppendMulti adds multiple values as elements to an array. `values` must be an array type ArrayAppendMulti("path", []int{1,2,3,4}, true) =>

"path" [..., 1,2,3,4]

This is a more efficient version (at both the network and server levels) of doing ArrayAppend("path", 1, true).ArrayAppend("path", 2, true).ArrayAppend("path", 3, true)

See ArrayAppend() for more information

func (*MutateInBuilder) ArrayAppendMultiEx

func (set *MutateInBuilder) ArrayAppendMultiEx(path string, values interface{}, flags SubdocFlag) *MutateInBuilder

ArrayAppendMultiEx allows you to perform a sub-document ArrayAppendMulti operation with flags

Experimental: This API is subject to change at any time.

func (*MutateInBuilder) ArrayInsert

func (set *MutateInBuilder) ArrayInsert(path string, value interface{}) *MutateInBuilder

ArrayInsert inserts an element at a given position within an array. The position should be specified as part of the path, e.g. path.to.array[3]

func (*MutateInBuilder) ArrayInsertEx

func (set *MutateInBuilder) ArrayInsertEx(path string, value interface{}, flags SubdocFlag) *MutateInBuilder

ArrayInsertEx allows you to perform a sub-document ArrayInsert operation with flags

Experimental: This API is subject to change at any time.

func (*MutateInBuilder) ArrayInsertMulti

func (set *MutateInBuilder) ArrayInsertMulti(path string, values interface{}) *MutateInBuilder

ArrayInsertMulti inserts multiple elements at a specified position within the array. See ArrayAppendMulti for more information about multiple element operations, and ArrayInsert for more information about array insertion operations

func (*MutateInBuilder) ArrayInsertMultiEx

func (set *MutateInBuilder) ArrayInsertMultiEx(path string, values interface{}, flags SubdocFlag) *MutateInBuilder

ArrayInsertMultiEx allows you to perform a sub-document ArrayInsertMulti operation with flags

Experimental: This API is subject to change at any time.

func (*MutateInBuilder) ArrayPrepend

func (set *MutateInBuilder) ArrayPrepend(path string, value interface{}, createParents bool) *MutateInBuilder

ArrayPrepend adds an element to the beginning (i.e. left) of an array

func (*MutateInBuilder) ArrayPrependEx

func (set *MutateInBuilder) ArrayPrependEx(path string, value interface{}, flags SubdocFlag) *MutateInBuilder

ArrayPrependEx allows you to perform a sub-document ArrayPrepend operation with flags

Experimental: This API is subject to change at any time.

func (*MutateInBuilder) ArrayPrependMulti

func (set *MutateInBuilder) ArrayPrependMulti(path string, values interface{}, createParents bool) *MutateInBuilder

ArrayPrependMulti adds multiple values at the beginning of an array. See ArrayAppendMulti for more information about multiple element operations and ArrayPrepend for the semantics of this operation

func (*MutateInBuilder) ArrayPrependMultiEx

func (set *MutateInBuilder) ArrayPrependMultiEx(path string, values interface{}, flags SubdocFlag) *MutateInBuilder

ArrayPrependMultiEx allows you to perform a sub-document ArrayPrependMulti operation with flags

Experimental: This API is subject to change at any time.

func (*MutateInBuilder) Counter

func (set *MutateInBuilder) Counter(path string, delta int64, createParents bool) *MutateInBuilder

Counter adds an counter operation to this mutation operation set.

func (*MutateInBuilder) CounterEx

func (set *MutateInBuilder) CounterEx(path string, delta int64, flags SubdocFlag) *MutateInBuilder

CounterEx allows you to perform a sub-document Counter operation with flags

Experimental: This API is subject to change at any time.

func (*MutateInBuilder) Execute

func (set *MutateInBuilder) Execute() (*DocumentFragment, error)

Execute executes this set of mutation operations on the bucket.

func (*MutateInBuilder) Insert

func (set *MutateInBuilder) Insert(path string, value interface{}, createParents bool) *MutateInBuilder

Insert adds an insert operation to this mutation operation set.

func (*MutateInBuilder) InsertEx

func (set *MutateInBuilder) InsertEx(path string, value interface{}, flags SubdocFlag) *MutateInBuilder

InsertEx allows you to perform a sub-document Insert operation with flags

Experimental: This API is subject to change at any time.

func (*MutateInBuilder) Remove

func (set *MutateInBuilder) Remove(path string) *MutateInBuilder

Remove adds an remove operation to this mutation operation set.

func (*MutateInBuilder) RemoveEx

func (set *MutateInBuilder) RemoveEx(path string, flags SubdocFlag) *MutateInBuilder

RemoveEx allows you to perform a sub-document Remove operation with flags

Experimental: This API is subject to change at any time.

func (*MutateInBuilder) Replace

func (set *MutateInBuilder) Replace(path string, value interface{}) *MutateInBuilder

Replace adds an replace operation to this mutation operation set.

func (*MutateInBuilder) ReplaceEx

func (set *MutateInBuilder) ReplaceEx(path string, value interface{}, flags SubdocFlag) *MutateInBuilder

ReplaceEx allows you to perform a sub-document Replace operation with flags

Experimental: This API is subject to change at any time.

func (*MutateInBuilder) Upsert

func (set *MutateInBuilder) Upsert(path string, value interface{}, createParents bool) *MutateInBuilder

Upsert adds an upsert operation to this mutation operation set.

func (*MutateInBuilder) UpsertEx

func (set *MutateInBuilder) UpsertEx(path string, value interface{}, flags SubdocFlag) *MutateInBuilder

UpsertEx allows you to perform a sub-document Upsert operation with flags

Experimental: This API is subject to change at any time.

type MutationState

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

MutationState holds and aggregates MutationToken's across multiple operations.

func NewMutationState

func NewMutationState(tokens ...MutationToken) *MutationState

NewMutationState creates a new MutationState for tracking mutation state.

func (*MutationState) Add

func (mt *MutationState) Add(tokens ...MutationToken)

Add includes an operation's mutation information in this mutation state.

func (*MutationState) MarshalJSON

func (mt *MutationState) MarshalJSON() ([]byte, error)

MarshalJSON marshal's this mutation state to JSON.

func (*MutationState) UnmarshalJSON

func (mt *MutationState) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal's a mutation state from JSON.

type MutationToken

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

MutationToken holds the mutation state information from an operation.

type N1qlQuery

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

N1qlQuery represents a pending N1QL query.

func NewN1qlQuery

func NewN1qlQuery(statement string) *N1qlQuery

NewN1qlQuery creates a new N1qlQuery object from a query string.

func (*N1qlQuery) AdHoc

func (nq *N1qlQuery) AdHoc(adhoc bool) *N1qlQuery

AdHoc specifies that this query is adhoc and should not be prepared.

func (*N1qlQuery) Consistency

func (nq *N1qlQuery) Consistency(stale ConsistencyMode) *N1qlQuery

Consistency specifies the level of consistency required for this query.

func (*N1qlQuery) ConsistentWith

func (nq *N1qlQuery) ConsistentWith(state *MutationState) *N1qlQuery

ConsistentWith specifies a mutation state to be consistent with for this query.

func (*N1qlQuery) Custom

func (nq *N1qlQuery) Custom(name string, value interface{}) *N1qlQuery

Custom allows specifying custom query options.

func (*N1qlQuery) Timeout

func (nq *N1qlQuery) Timeout(timeout time.Duration) *N1qlQuery

Timeout indicates the maximum time to wait for this query to complete.

type PasswordAuthenticator

type PasswordAuthenticator struct {
	Username string
	Password string
}

PasswordAuthenticator implements an Authenticator which uses an RBAC username and password.

type PrependOp

type PrependOp struct {
	Key   string
	Value string
	Cas   Cas
	Err   error
	// contains filtered or unexported fields
}

PrependOp represents a type of `BulkOp` used for Prepend operations. See BulkOp.

type QueryResultMetrics

type QueryResultMetrics struct {
	ElapsedTime   time.Duration
	ExecutionTime time.Duration
	ResultCount   uint
	ResultSize    uint
	MutationCount uint
	SortCount     uint
	ErrorCount    uint
	WarningCount  uint
}

QueryResultMetrics encapsulates various metrics gathered during a queries execution.

type QueryResults

type QueryResults interface {
	One(valuePtr interface{}) error
	Next(valuePtr interface{}) bool
	NextBytes() []byte
	Close() error

	RequestId() string
	ClientContextId() string
	Metrics() QueryResultMetrics
}

QueryResults allows access to the results of a N1QL query.

type RemoveOp

type RemoveOp struct {
	Key string
	Cas Cas
	Err error
	// contains filtered or unexported fields
}

RemoveOp represents a type of `BulkOp` used for Remove operations. See BulkOp.

type ReplaceOp

type ReplaceOp struct {
	Key    string
	Value  interface{}
	Expiry uint32
	Cas    Cas
	Err    error
	// contains filtered or unexported fields
}

ReplaceOp represents a type of `BulkOp` used for Replace operations. See BulkOp.

type SearchHighlightStyle

type SearchHighlightStyle string

SearchHighlightStyle indicates the type of highlighting to use for a search query.

type SearchQuery

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

SearchQuery represents a pending search query.

Experimental: This API is subject to change at any time.

func NewSearchQuery

func NewSearchQuery(indexName string, query interface{}) *SearchQuery

NewSearchQuery creates a new SearchQuery object from an index name and query.

Experimental: This API is subject to change at any time.

func (*SearchQuery) AddFacet

func (sq *SearchQuery) AddFacet(name string, facet interface{}) *SearchQuery

AddFacet adds a new search facet to include in the results.

func (*SearchQuery) Consistency

func (sq *SearchQuery) Consistency(stale ConsistencyMode) *SearchQuery

Consistency specifies the level of consistency required for this query.

func (*SearchQuery) ConsistentWith

func (sq *SearchQuery) ConsistentWith(state *MutationState) *SearchQuery

ConsistentWith specifies a mutation state to be consistent with for this query.

func (*SearchQuery) Explain

func (sq *SearchQuery) Explain(value bool) *SearchQuery

Explain enables search query explanation which provides details on how a query is executed.

func (*SearchQuery) Fields

func (sq *SearchQuery) Fields(fields ...string) *SearchQuery

Fields specifies which fields you wish to return in the results.

func (*SearchQuery) Highlight

func (sq *SearchQuery) Highlight(style SearchHighlightStyle, fields ...string) *SearchQuery

Highlight specifies how to highlight the hits in the search result.

func (*SearchQuery) Limit

func (sq *SearchQuery) Limit(value int) *SearchQuery

Limit specifies a limit on the number of results to return.

func (*SearchQuery) Skip

func (sq *SearchQuery) Skip(value int) *SearchQuery

Skip specifies how many results to skip at the beginning of the result list.

func (*SearchQuery) Sort

func (sq *SearchQuery) Sort(fields ...interface{}) *SearchQuery

Sort specifies a sorting order for the results. Only available in Couchbase Server 4.6+.

func (*SearchQuery) Timeout

func (sq *SearchQuery) Timeout(value time.Duration) *SearchQuery

Timeout indicates the maximum time to wait for this query to complete.

type SearchResultDateFacet

type SearchResultDateFacet struct {
	Name  string `json:"name,omitempty"`
	Min   string `json:"min,omitempty"`
	Max   string `json:"max,omitempty"`
	Count int    `json:"count,omitempty"`
}

SearchResultDateFacet holds the results of a date facet in search results.

type SearchResultFacet

type SearchResultFacet struct {
	Field         string                     `json:"field,omitempty"`
	Total         int                        `json:"total,omitempty"`
	Missing       int                        `json:"missing,omitempty"`
	Other         int                        `json:"other,omitempty"`
	Terms         []SearchResultTermFacet    `json:"terms,omitempty"`
	NumericRanges []SearchResultNumericFacet `json:"numeric_ranges,omitempty"`
	DateRanges    []SearchResultDateFacet    `json:"date_ranges,omitempty"`
}

SearchResultFacet holds the results of a specified facet in search results.

type SearchResultHit

type SearchResultHit struct {
	Index       string                                       `json:"index,omitempty"`
	Id          string                                       `json:"id,omitempty"`
	Score       float64                                      `json:"score,omitempty"`
	Explanation map[string]interface{}                       `json:"explanation,omitempty"`
	Locations   map[string]map[string][]SearchResultLocation `json:"locations,omitempty"`
	Fragments   map[string][]string                          `json:"fragments,omitempty"`
	Fields      map[string]string                            `json:"fields,omitempty"`
}

SearchResultHit holds a single hit in a list of search results.

type SearchResultLocation

type SearchResultLocation struct {
	Position       int    `json:"position,omitempty"`
	Start          int    `json:"start,omitempty"`
	End            int    `json:"end,omitempty"`
	ArrayPositions []uint `json:"array_positions,omitempty"`
}

SearchResultLocation holds the location of a hit in a list of search results.

type SearchResultNumericFacet

type SearchResultNumericFacet struct {
	Name  string  `json:"name,omitempty"`
	Min   float64 `json:"min,omitempty"`
	Max   float64 `json:"max,omitempty"`
	Count int     `json:"count,omitempty"`
}

SearchResultNumericFacet holds the results of a numeric facet in search results.

type SearchResultStatus

type SearchResultStatus struct {
	Total      int `json:"total,omitempty"`
	Failed     int `json:"failed,omitempty"`
	Successful int `json:"successful,omitempty"`
}

SearchResultStatus holds the status information for an executed search query.

type SearchResultTermFacet

type SearchResultTermFacet struct {
	Term  string `json:"term,omitempty"`
	Count int    `json:"count,omitempty"`
}

SearchResultTermFacet holds the results of a term facet in search results.

type SearchResults

type SearchResults interface {
	Status() SearchResultStatus
	Errors() []string
	TotalHits() int
	Hits() []SearchResultHit
	Facets() map[string]SearchResultFacet
	Took() time.Duration
	MaxScore() float64
}

SearchResults allows access to the results of a search query.

Experimental: This API is subject to change at any time.

type ServerStats

type ServerStats map[string]map[string]string

ServerStats is a tree of statistics information returned from the server.

stats := cb.Stats(...)
for server := stats {
    for statName, stat := server {
    //...
    }
}

type SortOrder

type SortOrder int

SortOrder specifies the ordering for the view queries results.

type SpatialQuery

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

SpatialQuery represents a pending spatial query.

func NewSpatialQuery

func NewSpatialQuery(ddoc, name string) *SpatialQuery

NewSpatialQuery creates a new SpatialQuery object from a design document and view name.

func (*SpatialQuery) Bbox

func (vq *SpatialQuery) Bbox(bounds []float64) *SpatialQuery

Bbox specifies the bounding region to use for the spatial query.

func (*SpatialQuery) Custom

func (vq *SpatialQuery) Custom(name, value string) *SpatialQuery

Custom allows specifying custom query options.

func (*SpatialQuery) Development

func (vq *SpatialQuery) Development(val bool) *SpatialQuery

Development specifies whether to query the production or development design document.

func (*SpatialQuery) Limit

func (vq *SpatialQuery) Limit(num uint) *SpatialQuery

Limit specifies a limit on the number of results to return.

func (*SpatialQuery) Skip

func (vq *SpatialQuery) Skip(num uint) *SpatialQuery

Skip specifies how many results to skip at the beginning of the result list.

func (*SpatialQuery) Stale

func (vq *SpatialQuery) Stale(stale StaleMode) *SpatialQuery

Stale specifies the level of consistency required for this query.

type StaleMode

type StaleMode int

StaleMode specifies the consistency required for a view query.

type StreamingBucket

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

StreamingBucket represents a bucket connection used for streaming data over DCP.

func (*StreamingBucket) IoRouter

func (b *StreamingBucket) IoRouter() *gocbcore.Agent

IoRouter returns the underlying gocb agent managing connections.

type SubdocDocFlag

type SubdocDocFlag gocbcore.SubdocDocFlag

SubdocDocFlag specifies document-level flags for a sub-document operation.

type SubdocFlag

type SubdocFlag gocbcore.SubdocFlag

SubdocFlag provides special handling flags for sub-document operations

type TouchOp

type TouchOp struct {
	Key    string
	Expiry uint32
	Cas    Cas
	Err    error
	// contains filtered or unexported fields
}

TouchOp represents a type of `BulkOp` used for Touch operations. See BulkOp.

type Transcoder

type Transcoder interface {
	// Decodes retrieved bytes into a Go type.
	Decode([]byte, uint32, interface{}) error

	// Encodes a Go type into bytes for storage.
	Encode(interface{}) ([]byte, uint32, error)
}

Transcoder provides an interface for transforming Go values to and from raw bytes for storage and retreival from Couchbase data storage.

type UpsertOp

type UpsertOp struct {
	Key    string
	Value  interface{}
	Expiry uint32
	Cas    Cas
	Err    error
	// contains filtered or unexported fields
}

UpsertOp represents a type of `BulkOp` used for Upsert operations. See BulkOp.

type User

type User struct {
	Id    string
	Name  string
	Type  string
	Roles []UserRole
}

User represents a user which was retrieved from the server.

type UserRole

type UserRole struct {
	Role       string
	BucketName string
}

UserRole represents a role for a particular user on the server.

type UserSettings

type UserSettings struct {
	Name     string
	Password string
	Roles    []UserRole
}

UserSettings represents a user during user creation.

type View

type View struct {
	Map    string `json:"map,omitempty"`
	Reduce string `json:"reduce,omitempty"`
}

View represents a Couchbase view within a design document.

type ViewQuery

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

ViewQuery represents a pending view query.

func NewViewQuery

func NewViewQuery(ddoc, name string) *ViewQuery

NewViewQuery creates a new ViewQuery object from a design document and view name.

func (*ViewQuery) Custom

func (vq *ViewQuery) Custom(name, value string) *ViewQuery

Custom allows specifying custom query options.

func (*ViewQuery) Development

func (vq *ViewQuery) Development(val bool) *ViewQuery

Development specifies whether to query the production or development design document.

func (*ViewQuery) Group

func (vq *ViewQuery) Group(useGrouping bool) *ViewQuery

Group specifies whether to group the map-reduce results.

func (*ViewQuery) GroupLevel

func (vq *ViewQuery) GroupLevel(groupLevel uint) *ViewQuery

GroupLevel specifies at what level to group the map-reduce results.

func (*ViewQuery) IdRange

func (vq *ViewQuery) IdRange(start, end string) *ViewQuery

IdRange specifies a range of document id's to get results within. Usually requires Range to be specified as well.

func (*ViewQuery) Key

func (vq *ViewQuery) Key(key interface{}) *ViewQuery

Key specifies a specific key to retrieve from the index.

func (*ViewQuery) Keys

func (vq *ViewQuery) Keys(keys []interface{}) *ViewQuery

Keys specifies a list of specific keys to retrieve from the index.

func (*ViewQuery) Limit

func (vq *ViewQuery) Limit(num uint) *ViewQuery

Limit specifies a limit on the number of results to return.

func (*ViewQuery) Order

func (vq *ViewQuery) Order(order SortOrder) *ViewQuery

Order specifies the order to sort the view results in.

func (*ViewQuery) Range

func (vq *ViewQuery) Range(start, end interface{}, inclusiveEnd bool) *ViewQuery

Range specifies a value range to get results within.

func (*ViewQuery) Reduce

func (vq *ViewQuery) Reduce(reduce bool) *ViewQuery

Reduce specifies whether to run the reduce part of the map-reduce.

func (*ViewQuery) Skip

func (vq *ViewQuery) Skip(num uint) *ViewQuery

Skip specifies how many results to skip at the beginning of the result list.

func (*ViewQuery) Stale

func (vq *ViewQuery) Stale(stale StaleMode) *ViewQuery

Stale specifies the level of consistency required for this query.

type ViewResultMetrics

type ViewResultMetrics interface {
	TotalRows() int
}

ViewResultMetrics allows access to the TotalRows value from the view response. This is implemented as an additional interface to maintain ABI compatibility for the 1.x series.

type ViewResults

type ViewResults interface {
	One(valuePtr interface{}) error
	Next(valuePtr interface{}) bool
	NextBytes() []byte
	Close() error
}

ViewResults implements an iterator interface which can be used to iterate over the rows of the query results.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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