Documentation ¶
Overview ¶
Package gocbcore implements methods for low-level communication with a Couchbase Server cluster.
Index ¶
- Constants
- Variables
- func AcquireTimer(d time.Duration) *time.Timer
- func DecodeCommonFlags(flags uint32) (DataType, CompressionType)
- func EncodeCommonFlags(valueType DataType, compression CompressionType) uint32
- func ReleaseTimer(t *time.Timer, wasRead bool)
- func SaslAuthBest(username, password string, client AuthClient, deadline time.Time) error
- func SaslAuthPlain(username, password string, client AuthClient, deadline time.Time) error
- func SetLogger(logger Logger)
- type Agent
- func (agent *Agent) Add(key, value []byte, flags uint32, expiry uint32, cb StoreCallback) (PendingOp, error)
- func (agent *Agent) AddIn(key []byte, path string, value []byte, flags SubdocFlag, cas Cas, ...) (PendingOp, error)
- func (agent *Agent) AddUniqueIn(key []byte, path string, value []byte, flags SubdocFlag, cas Cas, ...) (PendingOp, error)
- func (agent *Agent) Append(key, value []byte, cb StoreCallback) (PendingOp, error)
- func (agent *Agent) ArrayInsertIn(key []byte, path string, value []byte, cas Cas, expiry uint32, ...) (PendingOp, error)
- func (agent *Agent) CapiEps() []string
- func (agent *Agent) Close() error
- func (agent *Agent) CloseStream(vbId uint16, cb CloseStreamCallback) (PendingOp, error)
- func (agent *Agent) CounterIn(key []byte, path string, value []byte, cas Cas, expiry uint32, ...) (PendingOp, error)
- func (agent *Agent) Decrement(key []byte, delta, initial uint64, expiry uint32, cb CounterCallback) (PendingOp, error)
- func (agent *Agent) DeleteMeta(key, extra []byte, options, flags, expiry uint32, cas, revseqno uint64, ...) (PendingOp, error)
- func (agent *Agent) ExistsIn(key []byte, path string, flags SubdocFlag, cb ExistsInCallback) (PendingOp, error)
- func (agent *Agent) FtsEps() []string
- func (agent *Agent) Get(key []byte, cb GetCallback) (PendingOp, error)
- func (agent *Agent) GetAndLock(key []byte, lockTime uint32, cb GetCallback) (PendingOp, error)
- func (agent *Agent) GetAndTouch(key []byte, expiry uint32, cb GetCallback) (PendingOp, error)
- func (agent *Agent) GetFailoverLog(vbId uint16, cb GetFailoverLogCallback) (PendingOp, error)
- func (agent *Agent) GetIn(key []byte, path string, flags SubdocFlag, cb GetInCallback) (PendingOp, error)
- func (agent *Agent) GetRandom(cb GetRandomCallback) (PendingOp, error)
- func (agent *Agent) GetReplica(key []byte, replicaIdx int, cb GetCallback) (PendingOp, error)
- func (agent *Agent) GetVbucketSeqnos(serverIdx int, cb GetVBucketSeqnosCallback) (PendingOp, error)
- func (agent *Agent) HttpClient() *http.Client
- func (agent *Agent) Increment(key []byte, delta, initial uint64, expiry uint32, cb CounterCallback) (PendingOp, error)
- func (agent *Agent) IsSecure() bool
- func (agent *Agent) KeyToVbucket(key []byte) uint16
- func (agent *Agent) MgmtEps() []string
- func (agent *Agent) N1qlEps() []string
- func (agent *Agent) NumReplicas() int
- func (agent *Agent) NumServers() int
- func (agent *Agent) NumVbuckets() int
- func (agent *Agent) Observe(key []byte, replicaIdx int, cb ObserveCallback) (PendingOp, error)
- func (agent *Agent) ObserveSeqNo(key []byte, vbUuid VbUuid, replicaIdx int, cb ObserveSeqNoCallback) (PendingOp, error)
- func (agent *Agent) OpenStream(vbId uint16, vbUuid VbUuid, ...) (PendingOp, error)
- func (agent *Agent) Prepend(key, value []byte, cb StoreCallback) (PendingOp, error)
- func (agent *Agent) PushBackIn(key []byte, path string, value []byte, flags SubdocFlag, cas Cas, ...) (PendingOp, error)
- func (agent *Agent) PushFrontIn(key []byte, path string, value []byte, flags SubdocFlag, cas Cas, ...) (PendingOp, error)
- func (agent *Agent) Remove(key []byte, cas Cas, cb RemoveCallback) (PendingOp, error)
- func (agent *Agent) RemoveIn(key []byte, path string, cas Cas, expiry uint32, flags SubdocFlag, ...) (PendingOp, error)
- func (agent *Agent) Replace(key, value []byte, flags uint32, cas Cas, expiry uint32, cb StoreCallback) (PendingOp, error)
- func (agent *Agent) ReplaceIn(key []byte, path string, value []byte, cas Cas, expiry uint32, ...) (PendingOp, error)
- func (agent *Agent) ServerConnectTimeout() time.Duration
- func (agent *Agent) Set(key, value []byte, flags uint32, expiry uint32, cb StoreCallback) (PendingOp, error)
- func (agent *Agent) SetIn(key []byte, path string, value []byte, flags SubdocFlag, cas Cas, ...) (PendingOp, error)
- func (agent *Agent) SetMeta(key, value, extra []byte, options, flags, expiry uint32, cas, revseqno uint64, ...) (PendingOp, error)
- func (agent *Agent) SetServerConnectTimeout(timeout time.Duration)
- func (agent *Agent) Stats(key string, callback ServerStatsCallback) (PendingOp, error)
- func (agent *Agent) SubDocLookup(key []byte, ops []SubDocOp, cb LookupInCallback) (PendingOp, error)
- func (agent *Agent) SubDocMutate(key []byte, ops []SubDocOp, cas Cas, expiry uint32, cb MutateInCallback) (PendingOp, error)
- func (agent *Agent) Touch(key []byte, cas Cas, expiry uint32, cb TouchCallback) (PendingOp, error)
- func (agent *Agent) Unlock(key []byte, cas Cas, cb UnlockCallback) (PendingOp, error)
- func (agent *Agent) VbucketsOnServer(index int) []uint16
- type AgentConfig
- type AuthClient
- type AuthFunc
- type Cas
- type CloseStreamCallback
- type CompressionType
- type CounterCallback
- type CounterInCallback
- type DataType
- type ExistsInCallback
- type FailoverEntry
- type GetCallback
- type GetFailoverLogCallback
- type GetInCallback
- type GetRandomCallback
- type GetVBucketSeqnosCallback
- type KeyState
- type LogLevel
- type Logger
- type LookupInCallback
- type MultiError
- type MutateInCallback
- type MutationToken
- type ObserveCallback
- type ObserveSeqNoCallback
- type OpenStreamCallback
- type PendingOp
- type RemoveCallback
- type RemoveInCallback
- type SeqNo
- type ServerStatsCallback
- type SetMetaOption
- type SingleServerStats
- type SnapshotState
- type StoreCallback
- type StoreInCallback
- type StreamObserver
- type SubDocMutateError
- type SubDocOp
- type SubDocOpType
- type SubDocResult
- type SubdocFlag
- type TouchCallback
- type UnlockCallback
- type VbUuid
Constants ¶
const ( // UnknownType indicates the values type is unknown. UnknownType = DataType(0) // JsonType indicates the value is JSON data. JsonType = DataType(1) // BinaryType indicates the value is binary data. BinaryType = DataType(2) // StringType indicates the value is string data. StringType = DataType(3) )
const ( // UnknownCompression indicates that the compression type is unknown. UnknownCompression = CompressionType(0) // NoCompression indicates that no compression is being used. NoCompression = CompressionType(1) )
const ( // SkipConflictResolution disables conflict resolution for the document. SkipConflictResolution = SetMetaOption(0x01) // UseLwwConflictResolution switches to Last-Write-Wins conflict resolution // for the document. UseLwwConflictResolution = SetMetaOption(0x02) // RegenerateCas causes the server to invalidate the current CAS value for // a document, and to generate a new one. RegenerateCas = SetMetaOption(0x04) )
const ( // KeyStateNotPersisted indicates the key is in memory, but not yet written to disk. KeyStateNotPersisted = KeyState(0x00) // KeyStatePersisted indicates that the key has been written to disk. KeyStatePersisted = KeyState(0x01) // KeyStateNotFound indicates that the key is not found in memory or on disk. KeyStateNotFound = KeyState(0x80) // KeyStateDeleted indicates that the key has been written to disk as deleted. KeyStateDeleted = KeyState(0x81) )
const ( // SubDocOpGet indicates the operation is a sub-document `Get` operation. SubDocOpGet = SubDocOpType(cmdSubDocGet) // SubDocOpExists indicates the operation is a sub-document `Exists` operation. SubDocOpExists = SubDocOpType(cmdSubDocExists) // SubDocOpDictAdd indicates the operation is a sub-document `Add` operation. SubDocOpDictAdd = SubDocOpType(cmdSubDocDictAdd) // SubDocOpDictSet indicates the operation is a sub-document `Set` operation. SubDocOpDictSet = SubDocOpType(cmdSubDocDictSet) // SubDocOpDelete indicates the operation is a sub-document `Remove` operation. SubDocOpDelete = SubDocOpType(cmdSubDocDelete) // SubDocOpReplace indicates the operation is a sub-document `Replace` operation. SubDocOpReplace = SubDocOpType(cmdSubDocReplace) // SubDocOpArrayPushLast indicates the operation is a sub-document `ArrayPushLast` operation. SubDocOpArrayPushLast = SubDocOpType(cmdSubDocArrayPushLast) // SubDocOpArrayPushFirst indicates the operation is a sub-document `ArrayPushFirst` operation. SubDocOpArrayPushFirst = SubDocOpType(cmdSubDocArrayPushFirst) // SubDocOpArrayInsert indicates the operation is a sub-document `ArrayInsert` operation. SubDocOpArrayInsert = SubDocOpType(cmdSubDocArrayInsert) // SubDocOpArrayAddUnique indicates the operation is a sub-document `ArrayAddUnique` operation. SubDocOpArrayAddUnique = SubDocOpType(cmdSubDocArrayAddUnique) // SubDocOpCounter indicates the operation is a sub-document `Counter` operation. SubDocOpCounter = SubDocOpType(cmdSubDocCounter) )
const ( // SubdocFlagNone indicates no special treatment for this operation. SubdocFlagNone = SubdocFlag(0x00) // SubdocFlagMkDirP indicates that the path should be created if it does not already exist. SubdocFlagMkDirP = SubdocFlag(0x01) // SubdocFlagMkDoc indicates that the document should be created if it does not already exist. SubdocFlagMkDoc = SubdocFlag(0x02) // SubdocFlagXattrPath indicates that the path refers to an Xattr rather than the document body. SubdocFlagXattrPath = SubdocFlag(0x04) // SubdocFlagExpandMacros indicates that the value portion of any sub-document mutations // should be expanded if they contain macros such as ${Mutation.CAS}. SubdocFlagExpandMacros = SubdocFlag(0x10) )
Variables ¶
var ( // ErrNoAuthMethod occurs when the server does not support any of the // authentication methods that the client finds suitable. ErrNoAuthMethod = errors.New("no supported auth") // ErrDispatchFail occurs when the request router fails to dispatch an operation ErrDispatchFail = errors.New("failed to dispatch operation") // ErrBadHosts occurs when the list of hosts specified cannot be contacted. ErrBadHosts = errors.New("failed to connect to any of the specified hosts") // ErrProtocol occurs when the server responds with unexpected or unparseable data. ErrProtocol = errors.New("failed to parse server response") // ErrNoReplicas occurs when no replicas respond in time ErrNoReplicas = errors.New("no replicas responded in time") // ErrNoServer occurs when no server is available to service a keys vbucket. ErrNoServer = errors.New("no server available for this vbucket") // ErrInvalidServer occurs when an explicit, but invalid server index is specified. ErrInvalidServer = errors.New("specific server index is invalid") // ErrInvalidVBucket occurs when an explicit, but invalid vbucket index is specified. ErrInvalidVBucket = errors.New("specific vbucket index is invalid") // ErrInvalidReplica occurs when an explicit, but invalid replica index is specified. ErrInvalidReplica = errors.New("specific server index is invalid") // ErrInvalidCert occurs when a certificate that is not useable is passed to an Agent. ErrInvalidCert = errors.New("certificate is invalid") // ErrShutdown occurs when operations are performed on a previously closed Agent. ErrShutdown = &shutdownError{} // ErrOverload occurs when too many operations are dispatched and all queues are full. ErrOverload = &overloadError{} // ErrNetwork occurs when network failures prevent an operation from succeeding. ErrNetwork = &networkError{} // ErrTimeout occurs when an operation does not receive a response in a timely manner. ErrTimeout = &timeoutError{} // ErrStreamClosed occurs when a DCP stream is closed gracefully. ErrStreamClosed = &streamEndError{streamEndClosed} // ErrStreamStateChanged occurs when a DCP stream is interrupted by failover. ErrStreamStateChanged = &streamEndError{streamEndStateChanged} // ErrStreamDisconnected occurs when a DCP stream is disconnected. ErrStreamDisconnected = &streamEndError{streamEndDisconnected} // ErrStreamTooSlow occurs when a DCP stream is cancelled due to the application // not keeping up with the rate of flow of DCP events sent by the server. ErrStreamTooSlow = &streamEndError{streamEndTooSlow} // ErrKeyNotFound occurs when an operation is performed on a key that does not exist. ErrKeyNotFound = &memdError{statusKeyNotFound} // ErrKeyExists occurs when an operation is performed on a key that could not be found. ErrKeyExists = &memdError{statusKeyExists} // ErrTooBig occurs when an operation attempts to store more data in a single document // than the server is capable of storing (by default, this is a 20MB limit). ErrTooBig = &memdError{statusTooBig} // ErrInvalidArgs occurs when the server receives invalid arguments for an operation. ErrInvalidArgs = &memdError{statusInvalidArgs} // ErrNotStored occurs when the server fails to store a key. ErrNotStored = &memdError{statusNotStored} // ErrBadDelta occurs when an invalid delta value is specified to a counter operation. ErrBadDelta = &memdError{statusBadDelta} // ErrNotMyVBucket occurs when an operation is dispatched to a server which is // non-authoritative for a specific vbucket. ErrNotMyVBucket = &memdError{statusNotMyVBucket} // ErrNoBucket occurs when no bucket was selected on a connection. ErrNoBucket = &memdError{statusNoBucket} // ErrAuthStale occurs when authentication credentials have become invalidated. ErrAuthStale = &memdError{statusAuthStale} // ErrAuthError occurs when the authentication information provided was not valid. ErrAuthError = &memdError{statusAuthError} // ErrAuthContinue occurs in multi-step authentication when more authentication // work needs to be performed in order to complete the authentication process. ErrAuthContinue = &memdError{statusAuthContinue} // ErrRangeError occurs when the range specified to the server is not valid. ErrRangeError = &memdError{statusRangeError} // ErrRollback occurs when a DCP stream fails to open due to a rollback having // previously occurred since the last time the stream was opened. ErrRollback = &memdError{statusRollback} // ErrAccessError occurs when an access error occurs. ErrAccessError = &memdError{statusAccessError} // ErrNotInitialized is sent by servers which are still initializing, and are not // yet ready to accept operations on behalf of a particular bucket. ErrNotInitialized = &memdError{statusNotInitialized} // ErrUnknownCommand occurs when an unknown operation is sent to a server. ErrUnknownCommand = &memdError{statusUnknownCommand} // ErrOutOfMemory occurs when the server cannot service a request due to memory // limitations. ErrOutOfMemory = &memdError{statusOutOfMemory} // ErrNotSupported occurs when an operation is understood by the server, but that // operation is not supported on this server (occurs for a variety of reasons). ErrNotSupported = &memdError{statusNotSupported} // ErrInternalError occurs when internal errors prevent the server from processing // your request. ErrInternalError = &memdError{statusInternalError} // ErrBusy occurs when the server is too busy to process your request right away. // Attempting the operation at a later time will likely succeed. ErrBusy = &memdError{statusBusy} // ErrTmpFail occurs when a temporary failure is preventing the server from // processing your request. ErrTmpFail = &memdError{statusTmpFail} // ErrSubDocPathNotFound occurs when a sub-document operation targets a path // which does not exist in the specifie document. ErrSubDocPathNotFound = &memdError{statusSubDocPathNotFound} // ErrSubDocPathMismatch occurs when a sub-document operation specifies a path // which does not match the document structure (field access on an array). ErrSubDocPathMismatch = &memdError{statusSubDocPathMismatch} // ErrSubDocPathInvalid occurs when a sub-document path could not be parsed. ErrSubDocPathInvalid = &memdError{statusSubDocPathInvalid} // ErrSubDocPathTooBig occurs when a sub-document path is too big. ErrSubDocPathTooBig = &memdError{statusSubDocPathTooBig} // ErrSubDocDocTooDeep occurs when an operation would cause a document to be // nested beyond the depth limits allowed by the sub-document specification. ErrSubDocDocTooDeep = &memdError{statusSubDocDocTooDeep} // ErrSubDocCantInsert occurs when a sub-document operation could not insert. ErrSubDocCantInsert = &memdError{statusSubDocCantInsert} // ErrSubDocNotJson occurs when a sub-document operation is performed on a // document which is not JSON. ErrSubDocNotJson = &memdError{statusSubDocNotJson} // ErrSubDocBadRange occurs when a sub-document operation is performed with // a bad range. ErrSubDocBadRange = &memdError{statusSubDocBadRange} // ErrSubDocBadDelta occurs when a sub-document counter operation is performed // and the specified delta is not valid. ErrSubDocBadDelta = &memdError{statusSubDocBadDelta} // ErrSubDocPathExists occurs when a sub-document operation expects a path not // to exists, but the path was found in the document. ErrSubDocPathExists = &memdError{statusSubDocPathExists} // ErrSubDocValueTooDeep occurs when a sub-document operation specifies a value // which is deeper than the depth limits of the sub-document specification. ErrSubDocValueTooDeep = &memdError{statusSubDocValueTooDeep} // ErrSubDocBadCombo occurs when a multi-operation sub-document operation is // performed and operations within the package of ops conflict with each other. ErrSubDocBadCombo = &memdError{statusSubDocBadCombo} // ErrSubDocBadMulti occurs when a multi-operation sub-document operation is // performed and operations within the package of ops conflict with each other. ErrSubDocBadMulti = &memdError{statusSubDocBadMulti} )
Functions ¶
func AcquireTimer ¶
AcquireTimer acquires a time from a global pool of timers maintained by the library.
func DecodeCommonFlags ¶
func DecodeCommonFlags(flags uint32) (DataType, CompressionType)
DecodeCommonFlags decodes a flags value into a data type and compression type using the common flags specification.
func EncodeCommonFlags ¶
func EncodeCommonFlags(valueType DataType, compression CompressionType) uint32
EncodeCommonFlags encodes a data type and compression type into a flags value using the common flags specification.
func ReleaseTimer ¶
ReleaseTimer returns a timer to the global pool of timers maintained by the library.
func SaslAuthBest ¶
func SaslAuthBest(username, password string, client AuthClient, deadline time.Time) error
SaslAuthBest performs SASL authentication against an AuthClient using the best supported authentication algorithm available on both client and server.
func SaslAuthPlain ¶
func SaslAuthPlain(username, password string, client AuthClient, deadline time.Time) error
SaslAuthPlain performs PLAIN SASL authentication against an AuthClient.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent represents the base client handling connections to a Couchbase Server. This is used internally by the higher level classes for communicating with the cluster, it can also be used to perform more advanced operations with a cluster.
func CreateAgent ¶
func CreateAgent(config *AgentConfig) (*Agent, error)
CreateAgent creates an agent for performing normal operations.
func CreateDcpAgent ¶
func CreateDcpAgent(config *AgentConfig, dcpStreamName string) (*Agent, error)
CreateDcpAgent creates an agent for performing DCP operations.
func (*Agent) Add ¶
func (agent *Agent) Add(key, value []byte, flags uint32, expiry uint32, cb StoreCallback) (PendingOp, error)
Add stores a document as long as it does not already exist.
func (*Agent) AddIn ¶
func (agent *Agent) AddIn(key []byte, path string, value []byte, flags SubdocFlag, cas Cas, expiry uint32, cb StoreInCallback) (PendingOp, error)
AddIn adds a value at the path within a document. This method works like SetIn, but only only succeeds if the path does not currently exist.
func (*Agent) AddUniqueIn ¶
func (agent *Agent) AddUniqueIn(key []byte, path string, value []byte, flags SubdocFlag, cas Cas, expiry uint32, cb StoreInCallback) (PendingOp, error)
AddUniqueIn adds an entry to an array at a path but only if the value doesn't already exist in the array.
func (*Agent) Append ¶
func (agent *Agent) Append(key, value []byte, cb StoreCallback) (PendingOp, error)
Append appends some bytes to a document.
func (*Agent) ArrayInsertIn ¶
func (agent *Agent) ArrayInsertIn(key []byte, path string, value []byte, cas Cas, expiry uint32, flags SubdocFlag, cb StoreInCallback) (PendingOp, error)
ArrayInsertIn inserts an entry to an array at a path within the document.
func (*Agent) CapiEps ¶
CapiEps returns all the available endpoints for performing map-reduce queries.
func (*Agent) Close ¶
Close shuts down the agent, disconnecting from all servers and failing any outstanding operations with ErrShutdown.
func (*Agent) CloseStream ¶
func (agent *Agent) CloseStream(vbId uint16, cb CloseStreamCallback) (PendingOp, error)
CloseStream shuts down an open stream for the specified VBucket.
func (*Agent) CounterIn ¶
func (agent *Agent) CounterIn(key []byte, path string, value []byte, cas Cas, expiry uint32, flags SubdocFlag, cb CounterInCallback) (PendingOp, error)
CounterIn performs an arithmetic add or subtract on a value at a path in the document.
func (*Agent) Decrement ¶
func (agent *Agent) Decrement(key []byte, delta, initial uint64, expiry uint32, cb CounterCallback) (PendingOp, error)
Decrement decrements the unsigned integer value in a document.
func (*Agent) DeleteMeta ¶
func (agent *Agent) DeleteMeta(key, extra []byte, options, flags, expiry uint32, cas, revseqno uint64, cb RemoveCallback) (PendingOp, error)
DeleteMeta deletes a document along with setting some internal Couchbase meta-data.
func (*Agent) ExistsIn ¶
func (agent *Agent) ExistsIn(key []byte, path string, flags SubdocFlag, cb ExistsInCallback) (PendingOp, error)
ExistsIn returns whether a particular path exists within a document.
func (*Agent) Get ¶
func (agent *Agent) Get(key []byte, cb GetCallback) (PendingOp, error)
Get retrieves a document.
func (*Agent) GetAndLock ¶
GetAndLock retrieves a document and locks it.
func (*Agent) GetAndTouch ¶
GetAndTouch retrieves a document and updates its expiry.
func (*Agent) GetFailoverLog ¶
func (agent *Agent) GetFailoverLog(vbId uint16, cb GetFailoverLogCallback) (PendingOp, error)
GetFailoverLog retrieves the fail-over log for a particular VBucket. This is used to resume an interrupted stream after a node fail-over has occurred.
func (*Agent) GetIn ¶
func (agent *Agent) GetIn(key []byte, path string, flags SubdocFlag, cb GetInCallback) (PendingOp, error)
GetIn retrieves the value at a particular path within a JSON document.
func (*Agent) GetRandom ¶
func (agent *Agent) GetRandom(cb GetRandomCallback) (PendingOp, error)
GetRandom retrieves the key and value of a random document stored within Couchbase Server.
func (*Agent) GetReplica ¶
GetReplica retrieves a document from a replica server.
func (*Agent) GetVbucketSeqnos ¶
func (agent *Agent) GetVbucketSeqnos(serverIdx int, cb GetVBucketSeqnosCallback) (PendingOp, error)
GetVbucketSeqnos returns the last checkpoint for a particular VBucket. This is useful for starting a DCP stream from wherever the server currently is.
func (*Agent) HttpClient ¶
HttpClient returns a pre-configured HTTP Client for communicating with Couchbase Server. You must still specify authentication information for any dispatched requests.
func (*Agent) Increment ¶
func (agent *Agent) Increment(key []byte, delta, initial uint64, expiry uint32, cb CounterCallback) (PendingOp, error)
Increment increments the unsigned integer value in a document.
func (*Agent) KeyToVbucket ¶
KeyToVbucket translates a particular key to its assigned vbucket.
func (*Agent) MgmtEps ¶
MgmtEps returns all the available endpoints for performing management queries.
func (*Agent) NumReplicas ¶
NumReplicas returns the number of replicas configured on the connected cluster.
func (*Agent) NumServers ¶
NumServers returns the number of servers accessible for K/V.
func (*Agent) NumVbuckets ¶
NumVbuckets returns the number of VBuckets configured on the connected cluster.
func (*Agent) ObserveSeqNo ¶
func (agent *Agent) ObserveSeqNo(key []byte, vbUuid VbUuid, replicaIdx int, cb ObserveSeqNoCallback) (PendingOp, error)
ObserveSeqNo retrieves the persistence state sequence numbers for a particular VBucket.
func (*Agent) OpenStream ¶
func (agent *Agent) OpenStream(vbId uint16, vbUuid VbUuid, startSeqNo, endSeqNo, snapStartSeqNo, snapEndSeqNo SeqNo, evtHandler StreamObserver, cb OpenStreamCallback) (PendingOp, error)
OpenStream opens a DCP stream for a particular VBucket.
func (*Agent) Prepend ¶
func (agent *Agent) Prepend(key, value []byte, cb StoreCallback) (PendingOp, error)
Prepend prepends some bytes to a document.
func (*Agent) PushBackIn ¶
func (agent *Agent) PushBackIn(key []byte, path string, value []byte, flags SubdocFlag, cas Cas, expiry uint32, cb StoreInCallback) (PendingOp, error)
PushBackIn pushes an entry to the back of an array at a path within a document.
func (*Agent) PushFrontIn ¶
func (agent *Agent) PushFrontIn(key []byte, path string, value []byte, flags SubdocFlag, cas Cas, expiry uint32, cb StoreInCallback) (PendingOp, error)
PushFrontIn pushes an entry to the front of an array at a path within a document.
func (*Agent) RemoveIn ¶
func (agent *Agent) RemoveIn(key []byte, path string, cas Cas, expiry uint32, flags SubdocFlag, cb RemoveInCallback) (PendingOp, error)
RemoveIn removes the value at a path within the document.
func (*Agent) Replace ¶
func (agent *Agent) Replace(key, value []byte, flags uint32, cas Cas, expiry uint32, cb StoreCallback) (PendingOp, error)
Replace replaces the value of a Couchbase document with another value.
func (*Agent) ReplaceIn ¶
func (agent *Agent) ReplaceIn(key []byte, path string, value []byte, cas Cas, expiry uint32, flags SubdocFlag, cb StoreInCallback) (PendingOp, error)
ReplaceIn replaces the value at the path within a document. This method works like SetIn, but only only succeeds if the path currently exists.
func (*Agent) ServerConnectTimeout ¶
ServerConnectTimeout gets the timeout for each server connection, including all authentication steps.
func (*Agent) Set ¶
func (agent *Agent) Set(key, value []byte, flags uint32, expiry uint32, cb StoreCallback) (PendingOp, error)
Set stores a document.
func (*Agent) SetIn ¶
func (agent *Agent) SetIn(key []byte, path string, value []byte, flags SubdocFlag, cas Cas, expiry uint32, cb StoreInCallback) (PendingOp, error)
SetIn sets the value at a path within a document.
func (*Agent) SetMeta ¶
func (agent *Agent) SetMeta(key, value, extra []byte, options, flags, expiry uint32, cas, revseqno uint64, cb StoreCallback) (PendingOp, error)
SetMeta stores a document along with setting some internal Couchbase meta-data.
func (*Agent) SetServerConnectTimeout ¶
SetServerConnectTimeout sets the timeout for each server connection.
func (*Agent) Stats ¶
func (agent *Agent) Stats(key string, callback ServerStatsCallback) (PendingOp, error)
Stats retrieves statistics information from the server.
func (*Agent) SubDocLookup ¶
func (agent *Agent) SubDocLookup(key []byte, ops []SubDocOp, cb LookupInCallback) (PendingOp, error)
SubDocLookup performs a multiple-lookup sub-document operation on a document.
func (*Agent) SubDocMutate ¶
func (agent *Agent) SubDocMutate(key []byte, ops []SubDocOp, cas Cas, expiry uint32, cb MutateInCallback) (PendingOp, error)
SubDocMutate performs a multiple-mutation sub-document operation on a document.
func (*Agent) VbucketsOnServer ¶
VbucketsOnServer returns the list of VBuckets for a server.
type AgentConfig ¶
type AgentConfig struct { MemdAddrs []string HttpAddrs []string TlsConfig *tls.Config BucketName string Username string Password string AuthHandler AuthFunc UseMutationTokens bool UseKvErrorMaps bool ConnectTimeout time.Duration ServerConnectTimeout time.Duration NmvRetryDelay time.Duration MaxQueueSize int }
AgentConfig specifies the configuration options for creation of an Agent.
type AuthClient ¶
type AuthClient interface { Address() string ExecSaslListMechs(deadline time.Time) ([]string, error) ExecSaslAuth(k, v []byte, deadline time.Time) ([]byte, error) ExecSaslStep(k, v []byte, deadline time.Time) ([]byte, error) ExecSelectBucket(b []byte, deadline time.Time) error }
AuthClient exposes an interface for performing authentication on a connected Couchbase K/V client.
type AuthFunc ¶
type AuthFunc func(client AuthClient, deadline time.Time) error
AuthFunc is invoked by the agent to authenticate a client.
type Cas ¶
type Cas uint64
Cas represents a unique revision of a document. This can be used to perform optimistic locking.
type CloseStreamCallback ¶
type CloseStreamCallback func(error)
CloseStreamCallback is invoked with the results of `CloseStream` operations.
type CompressionType ¶
type CompressionType uint32
CompressionType indicates the type of compression for a value
type CounterCallback ¶
type CounterCallback func(uint64, Cas, MutationToken, error)
CounterCallback is invoked with the results of `Counter` operations.
type CounterInCallback ¶
type CounterInCallback func([]byte, Cas, MutationToken, error)
CounterInCallback is invoked with the results of `CounterIn` operations.
type ExistsInCallback ¶
ExistsInCallback is invoked with the results of `ExistsIn` operations.
type FailoverEntry ¶
FailoverEntry represents a single entry in the server fail-over log.
type GetCallback ¶
GetCallback is invoked with the results of `Get` operations.
type GetFailoverLogCallback ¶
type GetFailoverLogCallback func([]FailoverEntry, error)
GetFailoverLogCallback is invoked with the results of `GetFailoverLog` operations.
type GetInCallback ¶
GetInCallback is invoked with the results of `GetIn` operations.
type GetRandomCallback ¶
GetRandomCallback is invoked with the results of `GetRandom` operations.
type GetVBucketSeqnosCallback ¶
GetVBucketSeqnosCallback is invoked with the results of `GetVBucketSeqnos` operations.
type KeyState ¶
type KeyState uint8
KeyState represents the various storage states of a key on the server.
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 DefaultStdOutLogger
deprecated
func DefaultStdOutLogger() Logger
DefaultStdOutLogger gets the default logger. This actually logs to stderr rather than stdout. Use DefaultStdioLogger which has a correct name, since the "standard" logger logs to stderr, rather than stdout.
Deprecated: Use DefaultStdioLogger() instead.
func DefaultStdioLogger ¶
func DefaultStdioLogger() Logger
DefaultStdioLogger gets the default standard I/O logger.
gocbcore.SetLogger(gocbcore.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.
gocbcore.SetLogger(gocbcore.VerboseStdioLogger())
type LookupInCallback ¶
type LookupInCallback func([]SubDocResult, Cas, error)
LookupInCallback is invoked with the results of `LookupIn` operations.
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 MutateInCallback ¶
type MutateInCallback func([]SubDocResult, Cas, MutationToken, error)
MutateInCallback is invoked with the results of `MutateIn` operations.
type MutationToken ¶
MutationToken represents a particular mutation within the cluster.
type ObserveCallback ¶
ObserveCallback is invoked with the results of `Observe` operations.
type ObserveSeqNoCallback ¶
ObserveSeqNoCallback is invoked with the results of `ObserveSeqNo` operations.
type OpenStreamCallback ¶
type OpenStreamCallback func([]FailoverEntry, error)
OpenStreamCallback is invoked with the results of `OpenStream` operations.
type PendingOp ¶
type PendingOp interface {
Cancel() bool
}
PendingOp represents an outstanding operation within the client. This can be used to cancel an operation before it completes.
type RemoveCallback ¶
type RemoveCallback func(Cas, MutationToken, error)
RemoveCallback is invoked with the results of `Remove` operations.
type RemoveInCallback ¶
type RemoveInCallback func(Cas, MutationToken, error)
RemoveInCallback is invoked with the results of `RemoveIn` operations.
type SeqNo ¶
type SeqNo uint64
SeqNo is a sequential mutation number indicating the order and precise position of a write that has occurred.
type ServerStatsCallback ¶
type ServerStatsCallback func(stats map[string]SingleServerStats)
ServerStatsCallback is invoked with the results of `Stats` operations.
type SetMetaOption ¶
type SetMetaOption uint32
SetMetaOption represents possible option values for a SetMeta operation.
type SingleServerStats ¶
SingleServerStats represents the stats returned from a single server.
type SnapshotState ¶
type SnapshotState uint32
SnapshotState represents the state of a particular cluster snapshot.
func (SnapshotState) HasInMemory ¶
func (s SnapshotState) HasInMemory() bool
HasInMemory returns whether this snapshot is available in memory.
func (SnapshotState) HasOnDisk ¶
func (s SnapshotState) HasOnDisk() bool
HasOnDisk returns whether this snapshot is available on disk.
type StoreCallback ¶
type StoreCallback func(Cas, MutationToken, error)
StoreCallback is invoked with the results of any basic storage operations.
type StoreInCallback ¶
type StoreInCallback func(Cas, MutationToken, error)
StoreInCallback is invoked with the results of any sub-document storage operations.
type StreamObserver ¶
type StreamObserver interface { SnapshotMarker(startSeqNo, endSeqNo uint64, vbId uint16, snapshotType SnapshotState) Mutation(seqNo, revNo uint64, flags, expiry, lockTime uint32, cas uint64, datatype uint8, vbId uint16, key, value []byte) Deletion(seqNo, revNo, cas uint64, vbId uint16, key []byte) Expiration(seqNo, revNo, cas uint64, vbId uint16, key []byte) End(vbId uint16, err error) }
StreamObserver provides an interface to receive events from a running DCP stream.
type SubDocMutateError ¶
SubDocMutateError encapsulates errors that occur during sub-document mutations.
func (SubDocMutateError) Error ¶
func (e SubDocMutateError) Error() string
type SubDocOp ¶
type SubDocOp struct { Op SubDocOpType Flags SubdocFlag Path string Value []byte }
SubDocOp defines a per-operation structure to be passed to MutateIn or LookupIn for performing many sub-document operations.
type SubDocOpType ¶
type SubDocOpType uint8
SubDocOpType specifies the type of a sub-document operation.
type SubDocResult ¶
SubDocResult encapsulates the results from a single subdocument operation.
type TouchCallback ¶
type TouchCallback func(Cas, MutationToken, error)
TouchCallback is invoked with the results of `Touch` operations.
type UnlockCallback ¶
type UnlockCallback func(Cas, MutationToken, error)
UnlockCallback is invoked with the results of `Unlock` operations.
Source Files ¶
- agent.go
- agenthttpcfg.go
- agentops.go
- agentops_crud.go
- agentops_dcp.go
- agentops_dura.go
- agentops_internal.go
- agentops_subdoc.go
- agentrouting.go
- authclient.go
- cbcrc.go
- commonflags.go
- config.go
- constants.go
- errmap.go
- errmapptr.go
- error.go
- ketama.go
- logging.go
- memdclient.go
- memdclientmux.go
- memdconn.go
- memdopmap.go
- memdopqueue.go
- memdpipeline.go
- memdqpackets.go
- routeconfig.go
- routedata.go
- syncclient.go
- timerpool.go
- vbucketmap.go