base

package
v0.0.0-...-e3a33ee Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2016 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TapFeedType      = "tap"
	DcpFeedType      = "dcp"
	DcpShardFeedType = "dcpshard"
)
View Source
const (
	MaxConcurrentSingleOps = 1000 // Max 1000 concurrent single bucket ops
	MaxConcurrentBulkOps   = 35   // Max 35 concurrent bulk ops
	MaxBulkBatchSize       = 100  // Maximum number of ops per bulk call
)
View Source
const (

	// The username of the special "GUEST" user
	GuestUsername = "GUEST"
	ISO8601Format = "2006-01-02T15:04:05.000Z07:00"
)
View Source
const (
	KMaxVbNo           = 1024 // TODO: load from cluster config
	KStableSequenceKey = "_idx_stableSeq"
)
View Source
const (
	SourceTypeCouchbase      = "couchbase"
	IndexTypeSyncGateway     = "sync_gateway" // Used by CBGT for its data path
	IndexCategorySyncGateway = "general"      // CBGT expects this index to fit into a category (general vs advanced)
)
View Source
const (
	KIndexPartitionKey = "_idxPartitionMap"

	KPrincipalCountKeyFormat = "_idx_p_count:%s"  // key for principal count
	KPrincipalCountKeyPrefix = "_idx_p_count:"    // key prefix for principal count
	KTotalPrincipalCountKey  = "_idx_p_count_all" // key for overall principal count
)

Variables

View Source
var LogKeys map[string]bool

Set of LogTo() key strings that are enabled.

Functions

func AddDbPathToCookie

func AddDbPathToCookie(rq *http.Request, cookie *http.Cookie)

Needed due to https://github.com/couchbase/sync_gateway/issues/1345

func CBGTPlanParams

func CBGTPlanParams(numShards, numVbuckets uint16) cbgt.PlanParams

func ConvertBackQuotedStrings

func ConvertBackQuotedStrings(data []byte) []byte

Preprocesses a string containing `...`-delimited strings. Converts the backquotes into double-quotes, and escapes any newlines or double-quotes within them with backslashes.

func CouchHTTPErrorName

func CouchHTTPErrorName(status int) string

Returns the standard CouchDB error string for an HTTP error status. These are important for compatibility, as some REST APIs don't show numeric statuses, only these strings.

func CouchbaseUrlWithAuth

func CouchbaseUrlWithAuth(serverUrl, username, password, bucketname string) (string, error)

func CreateUUID

func CreateUUID() string

Returns a cryptographically-random 160-bit number encoded as a hex string.

func DurationToCbsExpiry

func DurationToCbsExpiry(ttl time.Duration) int

This is how Couchbase Server handles document expiration times

The actual value sent may either be Unix time (number of seconds since January 1, 1970, as a 32-bit value), or a number of seconds starting from current time. In the latter case, this number of seconds may not exceed 60*60*24*30 (number of seconds in 30 days); if the number sent by a client is larger than that, the server will consider it to be real Unix time value rather than an offset from current time.

This function takes a ttl as a Duration and returns an int formatted as required by CBS expiry processing

func EnableGoCBLogging

func EnableGoCBLogging()

func EnableLogKey

func EnableLogKey(key string)

func ErrorAsHTTPStatus

func ErrorAsHTTPStatus(err error) (int, string)

Attempts to map an error to an HTTP status code and message. Defaults to 500 if it doesn't recognize the error. Returns 200 for a nil error.

func FixJSONNumbers

func FixJSONNumbers(value interface{}) interface{}

This is a workaround for an incompatibility between Go's JSON marshaler and CouchDB. Go parses JSON numbers into float64 type, and then when it marshals float64 to JSON it uses scientific notation if the number is more than six digits long, even if it's an integer. However, CouchDB doesn't seem to like scientific notation and throws an exception. (See <https://issues.apache.org/jira/browse/COUCHDB-1670>) Thus, this function, which walks through a JSON-compatible object and converts float64 values to int64 when possible. NOTE: This function works on generic map[string]interface{}, but *not* on types based on it, like db.Body. Thus, db.Body has a special FixJSONNumbers method -- call that instead. TODO: In Go 1.1 we will be able to use a new option in the JSON parser that converts numbers to a special number type that preserves the exact formatting.

func GenerateRandomSecret

func GenerateRandomSecret() string

func GetCallersName

func GetCallersName(depth int) string

Returns a string identifying a function on the call stack. Use depth=1 for the caller of the function that calls GetCallersName, etc.

func GetLogKeys

func GetLogKeys() map[string]bool

func IsDocNotFoundError

func IsDocNotFoundError(err error) bool

Returns true if an error is a doc-not-found error

func IsPowerOfTwo

func IsPowerOfTwo(n uint16) bool

func ListenAndServeHTTP

func ListenAndServeHTTP(addr string, connLimit int, certFile *string, keyFile *string, handler http.Handler, readTimeout *int, writeTimeout *int) error

This is like a combination of http.ListenAndServe and http.ListenAndServeTLS, which also uses ThrottledListen to limit the number of open HTTP connections.

func LoadClockCounter

func LoadClockCounter(baseKey string, bucket Bucket) (uint64, error)

Count retrieval - utility for use outside of the context of a sharded clock.

func Log

func Log(message string)

Logs a message to the console.

func LogColor

func LogColor()

func LogEnabled

func LogEnabled(key string) bool

func LogError

func LogError(err error) error

If the error is not nil, logs its description and the name of the calling function. Returns the input error for easy chaining.

func LogFatal

func LogFatal(format string, args ...interface{})

Logs a warning to the console, then exits the process.

func LogLevel

func LogLevel() int

func LogNoColor

func LogNoColor()

Disables ANSI color in log output.

func LogNoTime

func LogNoTime()

func LogPanic

func LogPanic(format string, args ...interface{})

Logs a warning to the console, then panics.

func LogTo

func LogTo(key string, format string, args ...interface{})

Logs a message to the console, but only if the corresponding key is true in LogKeys.

func Logf

func Logf(format string, args ...interface{})

Logs a formatted message to the console.

func MergeStringArrays

func MergeStringArrays(arrays ...[]string) (merged []string)

Concatenates and merges multiple string arrays into one, discarding all duplicates (including duplicates within a single array.) Ordering is preserved.

func ParseLogFlag

func ParseLogFlag(flag string)

Parses a comma-separated list of log keys, probably coming from an argv flag. The key "bw" is interpreted as a call to LogNoColor, not a key.

func ParseLogFlags

func ParseLogFlags(flags []string)

Parses an array of log keys, probably coming from a argv flags. The key "bw" is interpreted as a call to LogNoColor, not a key.

func PrintClock

func PrintClock(clock SequenceClock) string

Clock utility functions

func RetryLoop

func RetryLoop(description string, worker RetryWorker, sleeper RetrySleeper) (error, interface{})

func SeedTestPartitionMap

func SeedTestPartitionMap(bucket Bucket, numPartitions uint16) error

Index partitions for unit tests

func SetLogLevel

func SetLogLevel(level int)

func TEMP

func TEMP(format string, args ...interface{})

Logs a highlighted message prefixed with "TEMP". This function is intended for temporary logging calls added during development and not to be checked in, hence its distinctive name (which is visible and easy to search for before committing.)

func ThrottledListen

func ThrottledListen(protocol string, addr string, limit int) (net.Listener, error)

Equivalent to net.Listen except that the returned listener allows only a limited number of open connections at a time. When the limit is reached it will block until some are closed before accepting any more. If the 'limit' parameter is 0, there is no limit and the behavior is identical to net.Listen.

func ToInt64

func ToInt64(value interface{}) (int64, bool)

func TransformBucketCredentials

func TransformBucketCredentials(inputUsername, inputPassword, inputBucketname string) (username, password, bucketname string)

This transforms raw input bucket credentials (for example, from config), to input credentials expected by Couchbase server, based on a few rules

func UpdateLogKeys

func UpdateLogKeys(keys map[string]bool, replace bool)

func UpdateLogger

func UpdateLogger(logFilePath string)

func VBHash

func VBHash(key string, numVb uint16) uint32

VBHash finds the vbucket for the given key.

func Warn

func Warn(format string, args ...interface{})

Logs a warning to the console

func WriteCasRaw

func WriteCasRaw(bucket Bucket, key string, value []byte, cas uint64, exp int, callback func([]byte) ([]byte, error)) (casOut uint64, err error)

Types

type AuthHandler

type AuthHandler couchbase.AuthHandler

type Bucket

type Bucket sgbucket.Bucket

func GetBucket

func GetBucket(spec BucketSpec, callback sgbucket.BucketNotifyFn) (bucket Bucket, err error)

func GetCouchbaseBucket

func GetCouchbaseBucket(spec BucketSpec, callback sgbucket.BucketNotifyFn) (bucket Bucket, err error)

Creates a Bucket that talks to a real live Couchbase server.

func GetCouchbaseBucketGoCB

func GetCouchbaseBucketGoCB(spec BucketSpec) (bucket Bucket, err error)

Creates a Bucket that talks to a real live Couchbase server.

func NewLeakyBucket

func NewLeakyBucket(bucket Bucket, config LeakyBucketConfig) Bucket

type BucketSpec

type BucketSpec struct {
	Server, PoolName, BucketName, FeedType string
	Auth                                   AuthHandler
	CbgtContext                            CbgtContext
	CouchbaseDriver                        CouchbaseDriver
	MaxNumRetries                          int // max number of retries before giving up
	InitialRetrySleepTimeMS                int // the initial time to sleep in between retry attempts (in millisecond), which will double each retry
}

Full specification of how to connect to a bucket

type CBGTDCPFeed

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

func (*CBGTDCPFeed) Close

func (c *CBGTDCPFeed) Close() error

func (*CBGTDCPFeed) Events

func (c *CBGTDCPFeed) Events() <-chan sgbucket.TapEvent

func (*CBGTDCPFeed) WriteEvents

func (c *CBGTDCPFeed) WriteEvents() chan<- sgbucket.TapEvent

type CbgtContext

type CbgtContext struct {
	Manager *cbgt.Manager
	Cfg     cbgt.Cfg
}

The two "handles" we have for CBGT are the manager and Cfg objects. This struct makes it easy to pass them around together as a unit.

type CouchbaseBucket

type CouchbaseBucket struct {
	*couchbase.Bucket // the underlying go-couchbase bucket
	// contains filtered or unexported fields
}

Implementation of sgbucket.Bucket that talks to a Couchbase server

func (CouchbaseBucket) CBSVersion

func (bucket CouchbaseBucket) CBSVersion() (major uint64, minor uint64, micro string, err error)

func (CouchbaseBucket) CreateCBGTIndex

func (bucket CouchbaseBucket) CreateCBGTIndex(numShards uint16, spec BucketSpec) error

func (CouchbaseBucket) Dump

func (bucket CouchbaseBucket) Dump()

func (CouchbaseBucket) Get

func (bucket CouchbaseBucket) Get(k string, v interface{}) (cas uint64, err error)

func (CouchbaseBucket) GetCBGTIndexName

func (bucket CouchbaseBucket) GetCBGTIndexName() string

func (CouchbaseBucket) GetMaxVbno

func (bucket CouchbaseBucket) GetMaxVbno() (uint16, error)

func (CouchbaseBucket) GetName

func (bucket CouchbaseBucket) GetName() string

func (CouchbaseBucket) GetRaw

func (bucket CouchbaseBucket) GetRaw(k string) (v []byte, cas uint64, err error)

func (CouchbaseBucket) GetStatsVbSeqno

func (bucket CouchbaseBucket) GetStatsVbSeqno(maxVbno uint16, useAbsHighSeqNo bool) (uuids map[uint16]uint64, highSeqnos map[uint16]uint64, seqErr error)

func (CouchbaseBucket) SetBulk

func (bucket CouchbaseBucket) SetBulk(entries []*sgbucket.BulkSetEntry) (err error)

func (CouchbaseBucket) StartCouchbaseTapFeed

func (bucket CouchbaseBucket) StartCouchbaseTapFeed(args sgbucket.TapArguments) (sgbucket.TapFeed, error)

func (CouchbaseBucket) StartDCPFeed

func (bucket CouchbaseBucket) StartDCPFeed(args sgbucket.TapArguments) (sgbucket.TapFeed, error)

Start cbdatasource-based DCP feed, using DCPReceiver.

func (CouchbaseBucket) StartTapFeed

func (bucket CouchbaseBucket) StartTapFeed(args sgbucket.TapArguments) (sgbucket.TapFeed, error)

func (CouchbaseBucket) Update

func (bucket CouchbaseBucket) Update(k string, exp int, callback sgbucket.UpdateFunc) error

func (CouchbaseBucket) View

func (bucket CouchbaseBucket) View(ddoc, name string, params map[string]interface{}) (sgbucket.ViewResult, error)

func (CouchbaseBucket) Write

func (bucket CouchbaseBucket) Write(k string, flags int, exp int, v interface{}, opt sgbucket.WriteOptions) (err error)

func (CouchbaseBucket) WriteCas

func (bucket CouchbaseBucket) WriteCas(k string, flags int, exp int, cas uint64, v interface{}, opt sgbucket.WriteOptions) (casOut uint64, err error)

func (CouchbaseBucket) WriteUpdate

func (bucket CouchbaseBucket) WriteUpdate(k string, exp int, callback sgbucket.WriteUpdateFunc) error

type CouchbaseBucketGoCB

type CouchbaseBucketGoCB struct {
	*gocb.Bucket // the underlying gocb bucket
	// contains filtered or unexported fields
}

Implementation of sgbucket.Bucket that talks to a Couchbase server and uses gocb

func (CouchbaseBucketGoCB) Add

func (bucket CouchbaseBucketGoCB) Add(k string, exp int, v interface{}) (added bool, err error)

func (CouchbaseBucketGoCB) AddRaw

func (bucket CouchbaseBucketGoCB) AddRaw(k string, exp int, v []byte) (added bool, err error)

func (CouchbaseBucketGoCB) Append

func (bucket CouchbaseBucketGoCB) Append(k string, data []byte) error

func (CouchbaseBucketGoCB) Close

func (bucket CouchbaseBucketGoCB) Close()

func (CouchbaseBucketGoCB) Delete

func (bucket CouchbaseBucketGoCB) Delete(k string) error

func (CouchbaseBucketGoCB) DeleteDDoc

func (bucket CouchbaseBucketGoCB) DeleteDDoc(docname string) error

func (CouchbaseBucketGoCB) Dump

func (bucket CouchbaseBucketGoCB) Dump()

func (CouchbaseBucketGoCB) Get

func (bucket CouchbaseBucketGoCB) Get(k string, rv interface{}) (cas uint64, err error)

func (CouchbaseBucketGoCB) GetAndTouchRaw

func (bucket CouchbaseBucketGoCB) GetAndTouchRaw(k string, exp int) (rv []byte, cas uint64, err error)

func (CouchbaseBucketGoCB) GetBulkRaw

func (bucket CouchbaseBucketGoCB) GetBulkRaw(keys []string) (map[string][]byte, error)

Retrieve keys in bulk for increased efficiency. If any keys are not found, they will not be returned, and so the size of the map may be less than the size of the keys slice, and no error will be returned in that case since it's an expected situation.

If there is an "overall error" calling the underlying GoCB bulk operation, then that error will be returned.

If there are errors on individual keys -- aside from "not found" errors -- such as QueueOverflow errors that can be retried successfully, they will be retried with a backoff loop.

func (CouchbaseBucketGoCB) GetDDoc

func (bucket CouchbaseBucketGoCB) GetDDoc(docname string, into interface{}) error

func (CouchbaseBucketGoCB) GetName

func (bucket CouchbaseBucketGoCB) GetName() string

func (CouchbaseBucketGoCB) GetRaw

func (bucket CouchbaseBucketGoCB) GetRaw(k string) (rv []byte, cas uint64, err error)

func (CouchbaseBucketGoCB) Incr

func (bucket CouchbaseBucketGoCB) Incr(k string, amt, def uint64, exp int) (uint64, error)

func (CouchbaseBucketGoCB) PutDDoc

func (bucket CouchbaseBucketGoCB) PutDDoc(docname string, value interface{}) error

func (CouchbaseBucketGoCB) Set

func (bucket CouchbaseBucketGoCB) Set(k string, exp int, v interface{}) error

func (CouchbaseBucketGoCB) SetBulk

func (bucket CouchbaseBucketGoCB) SetBulk(entries []*sgbucket.BulkSetEntry) (err error)

Retry up to the retry limit, then return. Does not retry items if they had CAS failures, and it's up to the caller to handle those.

func (CouchbaseBucketGoCB) SetRaw

func (bucket CouchbaseBucketGoCB) SetRaw(k string, exp int, v []byte) error

func (CouchbaseBucketGoCB) StartTapFeed

func (bucket CouchbaseBucketGoCB) StartTapFeed(args sgbucket.TapArguments) (sgbucket.TapFeed, error)

func (CouchbaseBucketGoCB) Update

func (bucket CouchbaseBucketGoCB) Update(k string, exp int, callback sgbucket.UpdateFunc) error

func (CouchbaseBucketGoCB) VBHash

func (bucket CouchbaseBucketGoCB) VBHash(docID string) uint32

func (CouchbaseBucketGoCB) View

func (bucket CouchbaseBucketGoCB) View(ddoc, name string, params map[string]interface{}) (sgbucket.ViewResult, error)

func (CouchbaseBucketGoCB) ViewCustom

func (bucket CouchbaseBucketGoCB) ViewCustom(ddoc, name string, params map[string]interface{}, vres interface{}) error

func (CouchbaseBucketGoCB) Write

func (bucket CouchbaseBucketGoCB) Write(k string, flags int, exp int, v interface{}, opt sgbucket.WriteOptions) error

func (CouchbaseBucketGoCB) WriteCas

func (bucket CouchbaseBucketGoCB) WriteCas(k string, flags int, exp int, cas uint64, v interface{}, opt sgbucket.WriteOptions) (casOut uint64, err error)

func (CouchbaseBucketGoCB) WriteUpdate

func (bucket CouchbaseBucketGoCB) WriteUpdate(k string, exp int, callback sgbucket.WriteUpdateFunc) error

type CouchbaseDriver

type CouchbaseDriver int
const (
	GoCouchbase CouchbaseDriver = iota
	GoCB
)

type DCPLoggingReceiver

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

DCPReceiver implements cbdatasource.Receiver to manage updates coming from a cbdatasource BucketDataSource. See go-couchbase/cbdatasource for additional details

func (*DCPLoggingReceiver) DataDelete

func (r *DCPLoggingReceiver) DataDelete(vbucketId uint16, key []byte, seq uint64,
	req *gomemcached.MCRequest) error

func (*DCPLoggingReceiver) DataUpdate

func (r *DCPLoggingReceiver) DataUpdate(vbucketId uint16, key []byte, seq uint64,
	req *gomemcached.MCRequest) error

func (*DCPLoggingReceiver) GetBucketNotifyFn

func (r *DCPLoggingReceiver) GetBucketNotifyFn() sgbucket.BucketNotifyFn

func (*DCPLoggingReceiver) GetEventFeed

func (r *DCPLoggingReceiver) GetEventFeed() <-chan sgbucket.TapEvent

func (*DCPLoggingReceiver) GetMetaData

func (r *DCPLoggingReceiver) GetMetaData(vbucketId uint16) (
	value []byte, lastSeq uint64, err error)

func (*DCPLoggingReceiver) GetOutput

func (r *DCPLoggingReceiver) GetOutput() chan sgbucket.TapEvent

func (*DCPLoggingReceiver) OnError

func (r *DCPLoggingReceiver) OnError(err error)

func (*DCPLoggingReceiver) Rollback

func (r *DCPLoggingReceiver) Rollback(vbucketId uint16, rollbackSeq uint64) error

func (*DCPLoggingReceiver) SeedSeqnos

func (r *DCPLoggingReceiver) SeedSeqnos(uuids map[uint16]uint64, seqs map[uint16]uint64)

func (*DCPLoggingReceiver) SetBucketNotifyFn

func (r *DCPLoggingReceiver) SetBucketNotifyFn(notify sgbucket.BucketNotifyFn)

func (*DCPLoggingReceiver) SetEventFeed

func (r *DCPLoggingReceiver) SetEventFeed(c chan sgbucket.TapEvent)

func (*DCPLoggingReceiver) SetMetaData

func (r *DCPLoggingReceiver) SetMetaData(vbucketId uint16, value []byte) error

func (*DCPLoggingReceiver) SnapshotStart

func (r *DCPLoggingReceiver) SnapshotStart(vbucketId uint16,
	snapStart, snapEnd uint64, snapType uint32) error

type DCPReceiver

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

DCPReceiver implements cbdatasource.Receiver to manage updates coming from a cbdatasource BucketDataSource. See go-couchbase/cbdatasource for additional details

func (*DCPReceiver) DataDelete

func (r *DCPReceiver) DataDelete(vbucketId uint16, key []byte, seq uint64,
	req *gomemcached.MCRequest) error

func (*DCPReceiver) DataUpdate

func (r *DCPReceiver) DataUpdate(vbucketId uint16, key []byte, seq uint64,
	req *gomemcached.MCRequest) error

func (*DCPReceiver) GetBucketNotifyFn

func (r *DCPReceiver) GetBucketNotifyFn() sgbucket.BucketNotifyFn

func (*DCPReceiver) GetEventFeed

func (r *DCPReceiver) GetEventFeed() <-chan sgbucket.TapEvent

func (*DCPReceiver) GetMetaData

func (r *DCPReceiver) GetMetaData(vbucketId uint16) (
	value []byte, lastSeq uint64, err error)

func (*DCPReceiver) GetOutput

func (r *DCPReceiver) GetOutput() chan sgbucket.TapEvent

func (*DCPReceiver) OnError

func (r *DCPReceiver) OnError(err error)

func (*DCPReceiver) Rollback

func (r *DCPReceiver) Rollback(vbucketId uint16, rollbackSeq uint64) error

Until we have CBL client support for rollback, we just rollback the sequence for the vbucket to unblock the DCP stream.

func (*DCPReceiver) SeedSeqnos

func (r *DCPReceiver) SeedSeqnos(uuids map[uint16]uint64, seqs map[uint16]uint64)

Seeds the sequence numbers returned by GetMetadata to support starting DCP from a particular sequence.

func (*DCPReceiver) SetBucketNotifyFn

func (r *DCPReceiver) SetBucketNotifyFn(notify sgbucket.BucketNotifyFn)

func (*DCPReceiver) SetEventFeed

func (r *DCPReceiver) SetEventFeed(c chan sgbucket.TapEvent)

func (*DCPReceiver) SetMetaData

func (r *DCPReceiver) SetMetaData(vbucketId uint16, value []byte) error

SetMetaData and GetMetaData used internally by cbdatasource. Expects send/recieve of opaque []byte data. cbdatasource is multithreaded so need to manage synchronization

func (*DCPReceiver) SnapshotStart

func (r *DCPReceiver) SnapshotStart(vbucketId uint16,
	snapStart, snapEnd uint64, snapType uint32) error

type EventUpdateFunc

type EventUpdateFunc func(event *sgbucket.TapEvent) bool

type GoCBError

type GoCBError uint8

GoCB error types - workaround until gocb has public error type lookup support

const (
	GoCBErr_MemdStatusKeyNotFound GoCBError = iota
	GoCBErr_MemdStatusKeyExists
	GoCBErr_MemdStatusBusy
	GoCBErr_MemdStatusTmpFail
	GoCBErr_Timeout
	GoCBErr_QueueOverflow
	GoCBErr_Unknown
)

func GoCBErrorType

func GoCBErrorType(err error) GoCBError

GoCB error types - workaround until gocb has public error type lookup support

type GoCBLogger

type GoCBLogger struct{}

func (GoCBLogger) Output

func (l GoCBLogger) Output(s string) error

type HTTPError

type HTTPError struct {
	Status  int
	Message string
}

Simple error implementation wrapping an HTTP response status.

func HTTPErrorf

func HTTPErrorf(status int, format string, args ...interface{}) *HTTPError

func (*HTTPError) Error

func (err *HTTPError) Error() string

type HeartbeatStoppedHandler

type HeartbeatStoppedHandler struct {
	Cfg         cbgt.Cfg
	Manager     *cbgt.Manager
	CbgtVersion string
}

When we detect other nodes have stopped pushing heartbeats, remove from CBGT cluster

func (HeartbeatStoppedHandler) StaleHeartBeatDetected

func (h HeartbeatStoppedHandler) StaleHeartBeatDetected(nodeUuid string)

type IndexPartitionMap

type IndexPartitionMap map[uint16]uint16 // Maps vbuckets to index partition value

type IndexPartitions

type IndexPartitions struct {
	PartitionDefs  PartitionStorageSet      // Partition definitions, as stored in bucket _idxPartitionMap
	VbMap          IndexPartitionMap        // Map from vbucket to partition
	VbPositionMaps map[uint16]VbPositionMap // VBPositionMaps, keyed by partition
}

func NewIndexPartitions

func NewIndexPartitions(partitions PartitionStorageSet) *IndexPartitions

type IntMax

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

IntMax is an expvar.Value that tracks the maximum value it's given.

func (*IntMax) SetIfMax

func (v *IntMax) SetIfMax(value int64)

func (*IntMax) String

func (v *IntMax) String() string

type LRUCache

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

An LRU cache of document revision bodies, together with their channel access.

func NewLRUCache

func NewLRUCache(capacity int) (*LRUCache, error)

Creates an LRU cache with the given capacity and an optional loader function.

func (*LRUCache) Count

func (lc *LRUCache) Count() int

func (*LRUCache) Get

func (lc *LRUCache) Get(key string) (result interface{}, found bool)

Looks up an entry from the cache.

func (*LRUCache) Put

func (lc *LRUCache) Put(key string, value interface{})

Adds an entry to the cache.

type LRUCacheLoaderFunc

type LRUCacheLoaderFunc func(key string) (value interface{}, err error)

type LeakyBucket

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

A wrapper around a Bucket to support forced errors. For testing use only.

func (*LeakyBucket) Add

func (b *LeakyBucket) Add(k string, exp int, v interface{}) (added bool, err error)

func (*LeakyBucket) AddRaw

func (b *LeakyBucket) AddRaw(k string, exp int, v []byte) (added bool, err error)

func (*LeakyBucket) Append

func (b *LeakyBucket) Append(k string, data []byte) error

func (*LeakyBucket) Close

func (b *LeakyBucket) Close()

func (*LeakyBucket) Delete

func (b *LeakyBucket) Delete(k string) error

func (*LeakyBucket) DeleteDDoc

func (b *LeakyBucket) DeleteDDoc(docname string) error

func (*LeakyBucket) Dump

func (b *LeakyBucket) Dump()

func (*LeakyBucket) Get

func (b *LeakyBucket) Get(k string, rv interface{}) (cas uint64, err error)

func (*LeakyBucket) GetAndTouchRaw

func (b *LeakyBucket) GetAndTouchRaw(k string, exp int) (v []byte, cas uint64, err error)

func (*LeakyBucket) GetBulkRaw

func (b *LeakyBucket) GetBulkRaw(keys []string) (map[string][]byte, error)

func (*LeakyBucket) GetDDoc

func (b *LeakyBucket) GetDDoc(docname string, value interface{}) error

func (*LeakyBucket) GetName

func (b *LeakyBucket) GetName() string

func (*LeakyBucket) GetRaw

func (b *LeakyBucket) GetRaw(k string) (v []byte, cas uint64, err error)

func (*LeakyBucket) Incr

func (b *LeakyBucket) Incr(k string, amt, def uint64, exp int) (uint64, error)

func (*LeakyBucket) PutDDoc

func (b *LeakyBucket) PutDDoc(docname string, value interface{}) error

func (*LeakyBucket) Set

func (b *LeakyBucket) Set(k string, exp int, v interface{}) error

func (*LeakyBucket) SetBulk

func (b *LeakyBucket) SetBulk(entries []*sgbucket.BulkSetEntry) (err error)

func (*LeakyBucket) SetRaw

func (b *LeakyBucket) SetRaw(k string, exp int, v []byte) error

func (*LeakyBucket) StartTapFeed

func (b *LeakyBucket) StartTapFeed(args sgbucket.TapArguments) (sgbucket.TapFeed, error)

func (*LeakyBucket) Update

func (b *LeakyBucket) Update(k string, exp int, callback sgbucket.UpdateFunc) (err error)

func (*LeakyBucket) VBHash

func (b *LeakyBucket) VBHash(docID string) uint32

func (*LeakyBucket) View

func (b *LeakyBucket) View(ddoc, name string, params map[string]interface{}) (sgbucket.ViewResult, error)

func (*LeakyBucket) ViewCustom

func (b *LeakyBucket) ViewCustom(ddoc, name string, params map[string]interface{}, vres interface{}) error

func (*LeakyBucket) Write

func (b *LeakyBucket) Write(k string, flags int, exp int, v interface{}, opt sgbucket.WriteOptions) error

func (*LeakyBucket) WriteCas

func (b *LeakyBucket) WriteCas(k string, flags int, exp int, cas uint64, v interface{}, opt sgbucket.WriteOptions) (uint64, error)

func (*LeakyBucket) WriteUpdate

func (b *LeakyBucket) WriteUpdate(k string, exp int, callback sgbucket.WriteUpdateFunc) (err error)

type LeakyBucketConfig

type LeakyBucketConfig struct {

	// Incr() fails 3 times before finally succeeding
	IncrTemporaryFailCount uint16

	// Emulate TAP/DCP feed de-dupliation behavior, such that within a
	// window of # of mutations or a timeout, mutations for a given document
	// will be filtered such that only the _latest_ mutation will make it through.
	TapFeedDeDuplication bool
	TapFeedVbuckets      bool     // Emulate vbucket numbers on feed
	TapFeedMissingDocs   []string // Emulate entry not appearing on tap feed
}

The config object that controls the LeakyBucket behavior

type LoggingBucket

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

A wrapper around a Bucket that transparently adds logging of all the API calls.

func (*LoggingBucket) Add

func (b *LoggingBucket) Add(k string, exp int, v interface{}) (added bool, err error)

func (*LoggingBucket) AddRaw

func (b *LoggingBucket) AddRaw(k string, exp int, v []byte) (added bool, err error)

func (*LoggingBucket) Append

func (b *LoggingBucket) Append(k string, data []byte) error

func (*LoggingBucket) Close

func (b *LoggingBucket) Close()

func (*LoggingBucket) Delete

func (b *LoggingBucket) Delete(k string) error

func (*LoggingBucket) DeleteDDoc

func (b *LoggingBucket) DeleteDDoc(docname string) error

func (*LoggingBucket) Dump

func (b *LoggingBucket) Dump()

func (*LoggingBucket) Get

func (b *LoggingBucket) Get(k string, rv interface{}) (uint64, error)

func (*LoggingBucket) GetAndTouchRaw

func (b *LoggingBucket) GetAndTouchRaw(k string, exp int) (v []byte, cas uint64, err error)

func (*LoggingBucket) GetBulkRaw

func (b *LoggingBucket) GetBulkRaw(keys []string) (map[string][]byte, error)

func (*LoggingBucket) GetDDoc

func (b *LoggingBucket) GetDDoc(docname string, value interface{}) error

func (*LoggingBucket) GetName

func (b *LoggingBucket) GetName() string

func (*LoggingBucket) GetRaw

func (b *LoggingBucket) GetRaw(k string) (v []byte, cas uint64, err error)

func (*LoggingBucket) Incr

func (b *LoggingBucket) Incr(k string, amt, def uint64, exp int) (uint64, error)

func (*LoggingBucket) PutDDoc

func (b *LoggingBucket) PutDDoc(docname string, value interface{}) error

func (*LoggingBucket) Set

func (b *LoggingBucket) Set(k string, exp int, v interface{}) error

func (*LoggingBucket) SetBulk

func (b *LoggingBucket) SetBulk(entries []*sgbucket.BulkSetEntry) (err error)

func (*LoggingBucket) SetRaw

func (b *LoggingBucket) SetRaw(k string, exp int, v []byte) error

func (*LoggingBucket) StartTapFeed

func (b *LoggingBucket) StartTapFeed(args sgbucket.TapArguments) (sgbucket.TapFeed, error)

func (*LoggingBucket) Update

func (b *LoggingBucket) Update(k string, exp int, callback sgbucket.UpdateFunc) (err error)

func (*LoggingBucket) VBHash

func (b *LoggingBucket) VBHash(docID string) uint32

func (*LoggingBucket) View

func (b *LoggingBucket) View(ddoc, name string, params map[string]interface{}) (sgbucket.ViewResult, error)

func (*LoggingBucket) ViewCustom

func (b *LoggingBucket) ViewCustom(ddoc, name string, params map[string]interface{}, vres interface{}) error

func (*LoggingBucket) Write

func (b *LoggingBucket) Write(k string, flags int, exp int, v interface{}, opt sgbucket.WriteOptions) error

func (*LoggingBucket) WriteCas

func (b *LoggingBucket) WriteCas(k string, flags int, exp int, cas uint64, v interface{}, opt sgbucket.WriteOptions) (uint64, error)

func (*LoggingBucket) WriteUpdate

func (b *LoggingBucket) WriteUpdate(k string, exp int, callback sgbucket.WriteUpdateFunc) (err error)

type PartitionStorage

type PartitionStorage struct {
	Uuid  string   `json:"uuid"`
	Index uint16   `json:"index"`
	VbNos []uint16 `json:"vbNos"`
}

type PartitionStorageSet

type PartitionStorageSet []PartitionStorage

func (PartitionStorageSet) Len

func (c PartitionStorageSet) Len() int

Implementation of sort.Interface

func (PartitionStorageSet) Less

func (c PartitionStorageSet) Less(i, j int) bool

func (PartitionStorageSet) Sort

func (c PartitionStorageSet) Sort()

Sorts the PartitionStorageSet by Uuid

func (PartitionStorageSet) String

func (c PartitionStorageSet) String() string

func (PartitionStorageSet) Swap

func (c PartitionStorageSet) Swap(i, j int)

type Receiver

type Receiver interface {
	cbdatasource.Receiver
	SeedSeqnos(map[uint16]uint64, map[uint16]uint64)
	GetEventFeed() <-chan sgbucket.TapEvent
	SetEventFeed(chan sgbucket.TapEvent)
	GetOutput() chan sgbucket.TapEvent

	SetBucketNotifyFn(sgbucket.BucketNotifyFn)
	GetBucketNotifyFn() sgbucket.BucketNotifyFn
	// contains filtered or unexported methods
}

func NewDCPReceiver

func NewDCPReceiver() Receiver

type RetrySleeper

type RetrySleeper func(retryCount int) (shouldContinue bool, timeTosleepMs int)

A retry sleeper is called back by the retry loop and passed the current retryCount, and should return the amount of milliseconds that the retry should sleep.

func CreateDoublingSleeperFunc

func CreateDoublingSleeperFunc(maxNumAttempts, initialTimeToSleepMs int) RetrySleeper

Create a RetrySleeper that will double the retry time on every iteration and use the given parameters

type RetryWorker

type RetryWorker func() (shouldRetry bool, err error, value interface{})

A RetryWorker encapsulates the work being done in a Retry Loop. The shouldRetry return value determines whether the worker will retry, regardless of the err value. If the worker has exceeded it's retry attempts, then it will not be called again even if it returns shouldRetry = true.

type SequenceClock

type SequenceClock interface {
	SetSequence(vbNo uint16, vbSequence uint64)    // Sets the sequence value for a vbucket
	SetMaxSequence(vbNo uint16, vbSequence uint64) // Sets the sequence value for a vbucket - must be larger than existing sequence
	GetSequence(vbNo uint16) (vbSequence uint64)   // Retrieves the sequence value for a vbucket
	Cas() (casOut uint64)                          // Gets the last known cas for this sequence clock
	SetCas(cas uint64)                             // Sets the last known cas for this sequence clock
	Marshal() (value []byte, err error)            // Marshals the sequence value
	Unmarshal(value []byte) error                  // Unmarshals the sequence value
	UpdateWithClock(updateClock SequenceClock)     // Updates the clock with values from updateClock
	Value() []uint64                               // Returns the raw vector clock
	ValueAsMap() map[uint16]uint64                 // Returns the raw vector clock
	GetHashedValue() string                        // Returns previously hashed value, if present.  If not present, does NOT generate hash
	SetHashedValue(value string)                   // Returns previously hashed value, if present.  If not present, does NOT generate hash
	Equals(otherClock SequenceClock) bool          // Evaluates whether two clocks are identical
	AllAfter(otherClock SequenceClock) bool        // True if all entries in clock are greater than or equal to the corresponding values in otherClock
	AllBefore(otherClock SequenceClock) bool       // True if all entries in clock are less than or equal to the corresponding values in otherClock
	AnyAfter(otherClock SequenceClock) bool        // True if any entries in clock are greater than the corresponding values in otherClock
	AnyBefore(otherClock SequenceClock) bool       // True if any entries in clock are less than the corresponding values in otherClock
	SetTo(otherClock SequenceClock)                // Sets the current clock to a copy of the other clock
	Copy() SequenceClock                           // Returns a copy of the clock
}

func LoadStableSequence

func LoadStableSequence(bucket Bucket) SequenceClock

func StableCallbackTest

func StableCallbackTest(callback StableSequenceFunc) (SequenceClock, error)

type SequenceClockImpl

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

Vector-clock based sequence. Not thread-safe - use SyncSequenceClock for usages with potential for concurrent access.

func NewSequenceClockForBytes

func NewSequenceClockForBytes(bytes []byte) (*SequenceClockImpl, error)

func NewSequenceClockImpl

func NewSequenceClockImpl() *SequenceClockImpl

func (*SequenceClockImpl) AllAfter

func (c *SequenceClockImpl) AllAfter(other SequenceClock) bool

Compares another sequence clock with this one. Returns true only if ALL vb values in the clock are greater than or equal to corresponding values in other

func (*SequenceClockImpl) AllBefore

func (c *SequenceClockImpl) AllBefore(other SequenceClock) bool

Compares another sequence clock with this one. Returns true only if ALL vb values in the clock are less than or equal to the corresponding values in other

func (*SequenceClockImpl) AnyAfter

func (c *SequenceClockImpl) AnyAfter(other SequenceClock) bool

Compares another sequence clock with this one. Returns true if ANY vb values in the clock are greater than the corresponding values in other

func (*SequenceClockImpl) AnyBefore

func (c *SequenceClockImpl) AnyBefore(other SequenceClock) bool

Compares another sequence clock with this one. Returns true if ANY vb values in the clock are less than the corresponding values in other

func (*SequenceClockImpl) Cas

func (c *SequenceClockImpl) Cas() uint64

func (*SequenceClockImpl) Copy

func (c *SequenceClockImpl) Copy() SequenceClock

Deep-copies a SequenceClock

func (*SequenceClockImpl) Equals

func (c *SequenceClockImpl) Equals(other SequenceClock) bool

Compares another sequence clock with this one

func (*SequenceClockImpl) GetHashedValue

func (c *SequenceClockImpl) GetHashedValue() string

func (*SequenceClockImpl) GetSequence

func (c *SequenceClockImpl) GetSequence(vbNo uint16) (vbSequence uint64)

func (*SequenceClockImpl) Init

func (c *SequenceClockImpl) Init(value []uint64, hash string)

func (*SequenceClockImpl) Marshal

func (c *SequenceClockImpl) Marshal() ([]byte, error)

TODO: replace with something more intelligent than gob encode, to take advantage of known

clock structure?

func (*SequenceClockImpl) SetCas

func (c *SequenceClockImpl) SetCas(cas uint64)

func (*SequenceClockImpl) SetHashedValue

func (c *SequenceClockImpl) SetHashedValue(value string)

func (*SequenceClockImpl) SetMaxSequence

func (c *SequenceClockImpl) SetMaxSequence(vbNo uint16, vbSequence uint64)

func (*SequenceClockImpl) SetSequence

func (c *SequenceClockImpl) SetSequence(vbNo uint16, vbSequence uint64)

func (*SequenceClockImpl) SetTo

func (c *SequenceClockImpl) SetTo(other SequenceClock)

Compares another sequence clock with this one. Returns true if ANY vb values in the clock are greater than the corresponding values in other

func (*SequenceClockImpl) Unmarshal

func (c *SequenceClockImpl) Unmarshal(value []byte) error

func (*SequenceClockImpl) UpdateWithClock

func (c *SequenceClockImpl) UpdateWithClock(updateClock SequenceClock)

func (*SequenceClockImpl) Value

func (c *SequenceClockImpl) Value() []uint64

func (*SequenceClockImpl) ValueAsMap

func (c *SequenceClockImpl) ValueAsMap() map[uint16]uint64

type Set

type Set map[string]present

An immutable set of strings, represented as a map.

func SetFromArray

func SetFromArray(names []string) Set

Creates a new Set from an array of strings.

func SetOf

func SetOf(names ...string) Set

Creates a new Set from zero or more inline string arguments.

func (Set) Contains

func (set Set) Contains(ch string) bool

Returns true if the set includes the channel.

func (Set) Equals

func (set Set) Equals(other Set) bool

func (Set) MarshalJSON

func (set Set) MarshalJSON() ([]byte, error)

func (Set) Removing

func (set Set) Removing(str string) Set

Returns a set with any instance of 'str' removed

func (Set) String

func (set Set) String() string

func (Set) ToArray

func (set Set) ToArray() []string

Converts a Set to an array of strings (ordering is undefined).

func (Set) Union

func (set Set) Union(other Set) Set

Returns the union of two sets.

func (*Set) UnmarshalJSON

func (setPtr *Set) UnmarshalJSON(data []byte) error

type ShardedClock

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

ShardedClock maintains the collection of clock shards (ShardedClockPartitions), and also manages the counter for the clock.

func NewShardedClock

func NewShardedClock(baseKey string, partitions *IndexPartitions, bucket Bucket) *ShardedClock

func NewShardedClockWithPartitions

func NewShardedClockWithPartitions(baseKey string, partitions *IndexPartitions, bucket Bucket) *ShardedClock

func (*ShardedClock) AsClock

func (s *ShardedClock) AsClock() *SequenceClockImpl

func (*ShardedClock) Load

func (s *ShardedClock) Load() (isChanged bool, err error)

Loads clock from bucket. If counter isn't changed, returns false and leaves as-is. For newly initialized ShardedClocks (counter=0), this will only happen if there are no entries in the bucket for the clock.

func (*ShardedClock) UpdateAndWrite

func (s *ShardedClock) UpdateAndWrite(updateClock SequenceClock) (err error)

type ShardedClockPartition

type ShardedClockPartition struct {
	Key string // Clock partition document key
	// contains filtered or unexported fields
}

ShardedClockPartition manages storage for one clock partition, where a clock partition is a set of {vb, seq} values for a subset of vbuckets. Modifying clock values and metadata is done directly to the []byte storage, to avoid marshal/unmarshal overhead. SeqSize defines how many bytes are used to store each clock value. It is initialized at 2 bytes/value (uint16 capacity), but gets increased via the resize() operation when a call to SetSequence would exceed the current capacity. Structure of []byte:

index : 2 bytes.  Partition Index, as uint16.
seqSize: 1 byte.  Sequence Size.  Supports values 1-4, where max sequence for that size is defined in kClockMaxSequences[size]
vbucket sequences: 2-8 bytes per sequence (depending on seqSize)

func NewShardedClockPartition

func NewShardedClockPartition(baseKey string, index uint16, vbuckets []uint16) *ShardedClockPartition

func NewShardedClockPartitionForBytes

func NewShardedClockPartitionForBytes(key string, bytes []byte, partitions *IndexPartitions) *ShardedClockPartition

func (*ShardedClockPartition) AddToClock

func (p *ShardedClockPartition) AddToClock(clock SequenceClock) error

func (*ShardedClockPartition) GetIndex

func (p *ShardedClockPartition) GetIndex() uint16

func (*ShardedClockPartition) GetSeqSize

func (p *ShardedClockPartition) GetSeqSize() uint8

Sequence Size - used as variable-length encoding, but for all sequences in the partition.

func (*ShardedClockPartition) GetSequence

func (p *ShardedClockPartition) GetSequence(vb uint16) (seq uint64)

func (*ShardedClockPartition) Init

func (p *ShardedClockPartition) Init(vbuckets []uint16)

Initializes vbucketOffsets

func (*ShardedClockPartition) Marshal

func (p *ShardedClockPartition) Marshal() ([]byte, error)

func (*ShardedClockPartition) SetIndex

func (p *ShardedClockPartition) SetIndex(index uint16)

func (*ShardedClockPartition) SetSeqSize

func (p *ShardedClockPartition) SetSeqSize(size uint8)

func (*ShardedClockPartition) SetSequence

func (p *ShardedClockPartition) SetSequence(vb uint16, seq uint64)

Sets sequence. Uses big endian byte ordering.

func (*ShardedClockPartition) Unmarshal

func (p *ShardedClockPartition) Unmarshal(value []byte) error

type StableSequenceFunc

type StableSequenceFunc func() (clock SequenceClock, err error)

Callback function to return the stable sequence

type SyncGatewayIndexParams

type SyncGatewayIndexParams struct {
	BucketName string `json:"bucket_name"`
}

type SyncGatewayPIndex

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

func NewSyncGatewayPIndex

func NewSyncGatewayPIndex(feedEvents chan<- sgbucket.TapEvent, bucket CouchbaseBucket, args sgbucket.TapArguments, stableClock SequenceClock) *SyncGatewayPIndex

func (*SyncGatewayPIndex) Close

func (s *SyncGatewayPIndex) Close() error

func (*SyncGatewayPIndex) ConsistencyWait

func (s *SyncGatewayPIndex) ConsistencyWait(partition, partitionUUID string,
	consistencyLevel string,
	consistencySeq uint64,
	cancelCh <-chan bool) error

func (*SyncGatewayPIndex) Count

func (s *SyncGatewayPIndex) Count(pindex *cbgt.PIndex, cancelCh <-chan bool) (uint64, error)

func (*SyncGatewayPIndex) DataDelete

func (s *SyncGatewayPIndex) DataDelete(partition string, key []byte, seq uint64,
	cas uint64, extrasType cbgt.DestExtrasType, extras []byte) error

func (*SyncGatewayPIndex) DataUpdate

func (s *SyncGatewayPIndex) DataUpdate(partition string, key []byte, seq uint64, val []byte,
	cas uint64, extrasType cbgt.DestExtrasType, extras []byte) error

func (*SyncGatewayPIndex) OpaqueGet

func (s *SyncGatewayPIndex) OpaqueGet(partition string) (value []byte, lastSeq uint64, err error)

OpaqueGet() should return the opaque value previously provided by an earlier call to OpaqueSet(). If there was no previous call to OpaqueSet(), such as in the case of a brand new instance of a Dest (as opposed to a restarted or reloaded Dest), the Dest should return (nil, 0, nil) for (value, lastSeq, err), respectively. The lastSeq should be the last sequence number received and persisted during calls to the Dest's DataUpdate() & DataDelete() methods.

func (*SyncGatewayPIndex) OpaqueSet

func (s *SyncGatewayPIndex) OpaqueSet(partition string, value []byte) error

The Dest implementation should persist the value parameter of OpaqueSet() for retrieval during some future call to OpaqueGet() by the system. The metadata value should be considered "in-stream", or as part of the sequence history of mutations. That is, a later Rollback() to some previous sequence number for a particular partition should rollback both persisted metadata and regular data. The Dest implementation should make its own copy of the value data.

func (*SyncGatewayPIndex) Query

func (s *SyncGatewayPIndex) Query(pindex *cbgt.PIndex, req []byte, w io.Writer,
	cancelCh <-chan bool) error

func (*SyncGatewayPIndex) Rollback

func (s *SyncGatewayPIndex) Rollback(partition string, rollbackSeq uint64) error

func (*SyncGatewayPIndex) SeedSeqnos

func (s *SyncGatewayPIndex) SeedSeqnos() error

func (*SyncGatewayPIndex) SnapshotStart

func (s *SyncGatewayPIndex) SnapshotStart(partition string, snapStart, snapEnd uint64) error

func (*SyncGatewayPIndex) Stats

func (s *SyncGatewayPIndex) Stats(w io.Writer) error

type SyncSequenceClock

type SyncSequenceClock struct {
	Clock *SequenceClockImpl
	// contains filtered or unexported fields
}

Synchronized Sequence Clock - should be used in shared usage scenarios

func NewSyncSequenceClock

func NewSyncSequenceClock() *SyncSequenceClock

func (*SyncSequenceClock) AllAfter

func (c *SyncSequenceClock) AllAfter(other SequenceClock) bool

func (*SyncSequenceClock) AllBefore

func (c *SyncSequenceClock) AllBefore(other SequenceClock) bool

func (*SyncSequenceClock) AnyAfter

func (c *SyncSequenceClock) AnyAfter(other SequenceClock) bool

func (*SyncSequenceClock) AnyBefore

func (c *SyncSequenceClock) AnyBefore(other SequenceClock) bool

func (*SyncSequenceClock) Cas

func (c *SyncSequenceClock) Cas() uint64

func (*SyncSequenceClock) Copy

func (c *SyncSequenceClock) Copy() SequenceClock

func (*SyncSequenceClock) Equals

func (c *SyncSequenceClock) Equals(other SequenceClock) bool

func (*SyncSequenceClock) GetHashedValue

func (c *SyncSequenceClock) GetHashedValue() string

func (*SyncSequenceClock) GetSequence

func (c *SyncSequenceClock) GetSequence(vbNo uint16) (sequence uint64)

func (*SyncSequenceClock) Marshal

func (c *SyncSequenceClock) Marshal() ([]byte, error)

TODO: possibly replace with something more intelligent than gob encode, to take advantage of known

clock structure?

func (*SyncSequenceClock) SetCas

func (c *SyncSequenceClock) SetCas(cas uint64)

func (*SyncSequenceClock) SetHashedValue

func (c *SyncSequenceClock) SetHashedValue(value string)

func (*SyncSequenceClock) SetMaxSequence

func (c *SyncSequenceClock) SetMaxSequence(vbNo uint16, vbSequence uint64)

func (*SyncSequenceClock) SetSequence

func (c *SyncSequenceClock) SetSequence(vbNo uint16, sequence uint64)

func (*SyncSequenceClock) SetTo

func (c *SyncSequenceClock) SetTo(other SequenceClock)

Copies a channel clock

func (*SyncSequenceClock) Unmarshal

func (c *SyncSequenceClock) Unmarshal(value []byte) error

func (*SyncSequenceClock) UpdateWithClock

func (c *SyncSequenceClock) UpdateWithClock(updateClock SequenceClock)

func (*SyncSequenceClock) Value

func (c *SyncSequenceClock) Value() []uint64

func (*SyncSequenceClock) ValueAsMap

func (c *SyncSequenceClock) ValueAsMap() map[uint16]uint64

type TapArguments

type TapArguments sgbucket.TapArguments

type TapFeed

type TapFeed sgbucket.TapFeed

type Uint64Slice

type Uint64Slice []uint64

Uint64Slice attaches the methods of sort.Interface to []uint64, sorting in increasing order.

func (Uint64Slice) Len

func (s Uint64Slice) Len() int

func (Uint64Slice) Less

func (s Uint64Slice) Less(i, j int) bool

func (Uint64Slice) Sort

func (s Uint64Slice) Sort()

Sort is a convenience method.

func (Uint64Slice) Swap

func (s Uint64Slice) Swap(i, j int)

type VbPositionMap

type VbPositionMap map[uint16]uint64 // Map from vbucket to position within partition.  Stored as uint64 to avoid cast during arithmetic

type VbSequence

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

VbSequence supports collections of {vb, seq} without requiring a map.

Jump to

Keyboard shortcuts

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