Documentation ¶
Index ¶
- Constants
- Variables
- func CheckDDoc(design *sgbucket.DesignDoc) error
- func CollateJSON(key1, key2 interface{}) int
- func Parallelize(f PipelineFunc, parallelism int, input <-chan jsMapFunctionInput) <-chan interface{}
- type CollectionBucket
- func (cb *CollectionBucket) Close(ctx context.Context)
- func (cb *CollectionBucket) CloseAndDelete() error
- func (wh *CollectionBucket) CreateDataStore(_ context.Context, name sgbucket.DataStoreName) error
- func (wh *CollectionBucket) DefaultDataStore() sgbucket.DataStore
- func (wh *CollectionBucket) DropDataStore(name sgbucket.DataStoreName) error
- func (wh *CollectionBucket) GetCollectionID(scope, collection string) (uint32, error)
- func (wh *CollectionBucket) GetMaxVbno() (uint16, error)
- func (wh *CollectionBucket) GetName() string
- func (wh *CollectionBucket) IsError(err error, errorType sgbucket.DataStoreErrorType) bool
- func (wh *CollectionBucket) IsSupported(feature sgbucket.BucketStoreFeature) bool
- func (wh *CollectionBucket) ListDataStores() ([]sgbucket.DataStoreName, error)
- func (wh *CollectionBucket) NamedDataStore(name sgbucket.DataStoreName) (sgbucket.DataStore, error)
- func (wh *CollectionBucket) StartDCPFeed(ctx context.Context, args sgbucket.FeedArguments, ...) error
- func (wh *CollectionBucket) StartTapFeed(args sgbucket.FeedArguments, dbStats *expvar.Map) (sgbucket.MutationFeed, error)
- func (wh *CollectionBucket) UUID() (string, error)
- type DocTooBigErr
- type JSONCollator
- type Pipeline
- type PipelineFunc
- type WalrusBucket
- func (bucket *WalrusBucket) Add(k string, exp uint32, v interface{}) (added bool, err error)
- func (bucket *WalrusBucket) AddRaw(k string, exp uint32, v []byte) (added bool, err error)
- func (bucket *WalrusBucket) Append(k string, data []byte) error
- func (bucket *WalrusBucket) Close(_ context.Context)
- func (bucket *WalrusBucket) CloseAndDelete() error
- func (bucket *WalrusBucket) CouchbaseServerVersion() (major uint64, minor uint64, micro string)
- func (bucket *WalrusBucket) DefaultDataStore() sgbucket.DataStore
- func (bucket *WalrusBucket) Delete(k string) error
- func (bucket *WalrusBucket) DeleteDDoc(docname string) error
- func (bucket *WalrusBucket) DeleteWithXattr(_ context.Context, k string, xattrKey string) error
- func (bucket *WalrusBucket) DeleteXattrs(_ context.Context, k string, xattrKeys ...string) error
- func (bucket *WalrusBucket) Dump()
- func (bucket *WalrusBucket) Exists(k string) (ok bool, err error)
- func (bucket *WalrusBucket) Get(k string, rv interface{}) (cas uint64, err error)
- func (bucket *WalrusBucket) GetAndTouchRaw(k string, exp uint32) (rv []byte, cas uint64, err error)
- func (bucket *WalrusBucket) GetBulkRaw(keys []string) (map[string][]byte, error)
- func (bucket *WalrusBucket) GetDDoc(docname string) (ddoc sgbucket.DesignDoc, err error)
- func (bucket *WalrusBucket) GetDDocs() (ddocs map[string]sgbucket.DesignDoc, err error)
- func (bucket *WalrusBucket) GetExpiry(_ context.Context, k string) (expiry uint32, getMetaError error)
- func (bucket *WalrusBucket) GetMaxVbno() (uint16, error)
- func (bucket *WalrusBucket) GetName() string
- func (bucket *WalrusBucket) GetRaw(k string) (rv []byte, cas uint64, err error)
- func (bucket *WalrusBucket) GetStatsVbSeqno(maxVbno uint16, useAbsHighSeqNo bool) (uuids map[uint16]uint64, highSeqnos map[uint16]uint64, seqErr error)
- func (bucket *WalrusBucket) GetSubDocRaw(_ context.Context, k string, subdocKey string) (value []byte, casOut uint64, err error)
- func (bucket *WalrusBucket) GetWithXattr(_ context.Context, k string, xattrKey string, userXattrKey string, ...) (cas uint64, err error)
- func (bucket *WalrusBucket) GetXattr(_ context.Context, k string, xattrKey string, xv interface{}) (casOut uint64, err error)
- func (bucket *WalrusBucket) Incr(k string, amt, def uint64, exp uint32) (uint64, error)
- func (bucket *WalrusBucket) IsError(err error, errorType sgbucket.DataStoreErrorType) bool
- func (bucket *WalrusBucket) IsSupported(feature sgbucket.BucketStoreFeature) bool
- func (bucket *WalrusBucket) ListDataStores() ([]sgbucket.DataStoreName, error)
- func (bucket *WalrusBucket) NamedDataStore(name sgbucket.DataStoreName) (sgbucket.DataStore, error)
- func (bucket *WalrusBucket) PutDDoc(_ context.Context, docname string, design *sgbucket.DesignDoc) error
- func (bucket *WalrusBucket) Refresh() error
- func (bucket *WalrusBucket) Remove(k string, cas uint64) (casOut uint64, err error)
- func (bucket *WalrusBucket) RemoveXattr(_ context.Context, k string, xattrKey string, cas uint64) error
- func (bucket *WalrusBucket) Set(k string, exp uint32, _ *sgbucket.UpsertOptions, v interface{}) error
- func (bucket *WalrusBucket) SetBulk(entries []*sgbucket.BulkSetEntry) (err error)
- func (bucket *WalrusBucket) SetRaw(k string, exp uint32, _ *sgbucket.UpsertOptions, v []byte) error
- func (bucket *WalrusBucket) SetVbAndSeq(doc *walrusDoc, k string) (err error)
- func (bucket *WalrusBucket) SetXattr(_ context.Context, k string, xattrKey string, xv []byte) (casOut uint64, err error)
- func (bucket *WalrusBucket) StartDCPFeed(ctx context.Context, args sgbucket.FeedArguments, ...) error
- func (bucket *WalrusBucket) StartTapFeed(args sgbucket.FeedArguments, dbStats *expvar.Map) (sgbucket.MutationFeed, error)
- func (bucket *WalrusBucket) SubdocInsert(_ context.Context, docID string, fieldPath string, cas uint64, ...) error
- func (bucket *WalrusBucket) Touch(k string, exp uint32) (casOut uint64, err error)
- func (bucket *WalrusBucket) UUID() (string, error)
- func (bucket *WalrusBucket) Update(k string, exp uint32, callback sgbucket.UpdateFunc) (casOut uint64, err error)
- func (bucket *WalrusBucket) VBHash(docID string) uint32
- func (bucket *WalrusBucket) View(_ context.Context, docName, viewName string, params map[string]interface{}) (sgbucket.ViewResult, error)
- func (bucket *WalrusBucket) ViewCustom(ctx context.Context, ddoc, name string, params map[string]interface{}, ...) error
- func (bucket *WalrusBucket) ViewQuery(ctx context.Context, ddoc, name string, params map[string]interface{}) (sgbucket.QueryResultIterator, error)
- func (bucket *WalrusBucket) Write(k string, flags int, exp uint32, v interface{}, opt sgbucket.WriteOptions) (err error)
- func (bucket *WalrusBucket) WriteCas(k string, flags int, exp uint32, cas uint64, v interface{}, ...) (casOut uint64, err error)
- func (bucket *WalrusBucket) WriteCasWithXattr(_ context.Context, k string, xattrKey string, exp uint32, cas uint64, ...) (casOut uint64, err error)
- func (bucket *WalrusBucket) WriteSubDoc(_ context.Context, k string, subdocKey string, cas uint64, value []byte) (casOut uint64, err error)
- func (bucket *WalrusBucket) WriteUpdate(k string, exp uint32, callback sgbucket.WriteUpdateFunc) (casOut uint64, err error)
- func (bucket *WalrusBucket) WriteUpdateWithXattr(_ context.Context, k string, xattrKey string, userXattrKey string, exp uint32, ...) (casOut uint64, err error)
- func (bucket *WalrusBucket) WriteWithXattr(_ context.Context, k string, xattrKey string, exp uint32, cas uint64, ...) (casOut uint64, err error)
- type WalrusCollection
Constants ¶
const (
SimulatedVBucketCount = 1024 // Used when hashing doc id -> vbno
)
Variables ¶
var Logging bool
Set this to true to enable logging
var MaxDocSize = 0 // Used during the write function
Functions ¶
func CollateJSON ¶
func CollateJSON(key1, key2 interface{}) int
func Parallelize ¶
func Parallelize(f PipelineFunc, parallelism int, input <-chan jsMapFunctionInput) <-chan interface{}
Feeds the input channel through a number of copies of the function in parallel. This call is asynchronous. Output can be read from the returned channel.
Types ¶
type CollectionBucket ¶
type CollectionBucket struct {
// contains filtered or unexported fields
}
CollectionBucket is an in-memory implementation of a BucketStore. Individual collections are implemented as standard WalrusBuckets (in-memory DataStore implementations).
func GetCollectionBucket ¶
func GetCollectionBucket(url, bucketName string) (*CollectionBucket, error)
func NewCollectionBucket ¶
func NewCollectionBucket(bucketName string) *CollectionBucket
func (*CollectionBucket) Close ¶
func (cb *CollectionBucket) Close(ctx context.Context)
func (*CollectionBucket) CloseAndDelete ¶
func (cb *CollectionBucket) CloseAndDelete() error
CloseAndDelete calls closeAndDelete on the underlying buckets when using persisted buckets
func (*CollectionBucket) CreateDataStore ¶
func (wh *CollectionBucket) CreateDataStore(_ context.Context, name sgbucket.DataStoreName) error
func (*CollectionBucket) DefaultDataStore ¶
func (wh *CollectionBucket) DefaultDataStore() sgbucket.DataStore
func (*CollectionBucket) DropDataStore ¶
func (wh *CollectionBucket) DropDataStore(name sgbucket.DataStoreName) error
func (*CollectionBucket) GetCollectionID ¶
func (wh *CollectionBucket) GetCollectionID(scope, collection string) (uint32, error)
func (*CollectionBucket) GetMaxVbno ¶
func (wh *CollectionBucket) GetMaxVbno() (uint16, error)
func (*CollectionBucket) GetName ¶
func (wh *CollectionBucket) GetName() string
func (*CollectionBucket) IsError ¶
func (wh *CollectionBucket) IsError(err error, errorType sgbucket.DataStoreErrorType) bool
func (*CollectionBucket) IsSupported ¶
func (wh *CollectionBucket) IsSupported(feature sgbucket.BucketStoreFeature) bool
func (*CollectionBucket) ListDataStores ¶
func (wh *CollectionBucket) ListDataStores() ([]sgbucket.DataStoreName, error)
func (*CollectionBucket) NamedDataStore ¶
func (wh *CollectionBucket) NamedDataStore(name sgbucket.DataStoreName) (sgbucket.DataStore, error)
func (*CollectionBucket) StartDCPFeed ¶
func (wh *CollectionBucket) StartDCPFeed(ctx context.Context, args sgbucket.FeedArguments, callback sgbucket.FeedEventCallbackFunc, dbStats *expvar.Map) error
StartDCPFeed implements a multi-collection feed by calling StartDCPFeed for each requested collection. Each collection's DCP feed runs its own goroutine, callback may be invoked concurrently by these goroutines.
func (*CollectionBucket) StartTapFeed ¶
func (wh *CollectionBucket) StartTapFeed(args sgbucket.FeedArguments, dbStats *expvar.Map) (sgbucket.MutationFeed, error)
func (*CollectionBucket) UUID ¶
func (wh *CollectionBucket) UUID() (string, error)
type DocTooBigErr ¶
type DocTooBigErr struct{}
func (DocTooBigErr) Error ¶
func (err DocTooBigErr) Error() string
type JSONCollator ¶
type JSONCollator struct {
// contains filtered or unexported fields
}
Context for JSON collation. This struct is not thread-safe (or rather, its embedded string collator isn't) so it should only be used on one goroutine at a time.
func (*JSONCollator) Clear ¶
func (c *JSONCollator) Clear()
func (*JSONCollator) Collate ¶
func (c *JSONCollator) Collate(key1, key2 interface{}) int
CouchDB-compatible collation/comparison of JSON values. See: http://wiki.apache.org/couchdb/View_collation#Collation_Specification
func (*JSONCollator) CollateRaw ¶
func (c *JSONCollator) CollateRaw(key1, key2 []byte) int
Collates raw JSON data without unmarshaling it. THE INPUTS MUST BE VALID JSON, WITH NO WHITESPACE! Invalid input will result in a panic, or perhaps just bogus output.
type PipelineFunc ¶
type PipelineFunc func(input jsMapFunctionInput, output chan<- interface{})
type WalrusBucket ¶
type WalrusBucket struct {
// contains filtered or unexported fields
}
Simple, inefficient in-memory implementation of Bucket interface. http://ihasabucket.com
func GetBucket ¶
func GetBucket(url, poolName, bucketName string) (*WalrusBucket, error)
Returns a Walrus-based Bucket specific to the given (url, pool, bucketname) tuple. That is, passing the same parameters will return the same Bucket.
If the urlStr has any of the forms below it will be considered a filesystem directory path, and the bucket will use a persistent backing file in that directory.
walrus:/foo/bar walrus:bar file:///foo/bar /foo/bar ./bar
The bucket's filename will be "bucketName.walrus", or if the poolName is not "default", "poolName-bucketName.walrus".
If the URL isn't considered a directory (e.g. "walrus:" or ""), the bucket will just be created in memory using NewBucket.
func NewBucket ¶
func NewBucket(bucketName string) *WalrusBucket
Creates a simple in-memory Bucket, suitable only for amusement purposes & testing. The Bucket is created empty. There is no way to save it persistently.
func NewPersistentBucket ¶
func NewPersistentBucket(dir, poolName, bucketName string) (*WalrusBucket, error)
Loads or creates a persistent bucket in the given filesystem directory. The bucket's backing file will be named "bucketName.walrus", or if the poolName is not empty "default", "poolName-bucketName.walrus".
func (*WalrusBucket) Add ¶
func (bucket *WalrusBucket) Add(k string, exp uint32, v interface{}) (added bool, err error)
func (*WalrusBucket) Close ¶
func (bucket *WalrusBucket) Close(_ context.Context)
func (*WalrusBucket) CloseAndDelete ¶
func (bucket *WalrusBucket) CloseAndDelete() error
func (*WalrusBucket) CouchbaseServerVersion ¶
func (bucket *WalrusBucket) CouchbaseServerVersion() (major uint64, minor uint64, micro string)
func (*WalrusBucket) DefaultDataStore ¶
func (bucket *WalrusBucket) DefaultDataStore() sgbucket.DataStore
func (*WalrusBucket) Delete ¶
func (bucket *WalrusBucket) Delete(k string) error
func (*WalrusBucket) DeleteDDoc ¶
func (bucket *WalrusBucket) DeleteDDoc(docname string) error
func (*WalrusBucket) DeleteWithXattr ¶
func (*WalrusBucket) DeleteXattrs ¶
func (*WalrusBucket) Dump ¶
func (bucket *WalrusBucket) Dump()
func (*WalrusBucket) Get ¶
func (bucket *WalrusBucket) Get(k string, rv interface{}) (cas uint64, err error)
func (*WalrusBucket) GetAndTouchRaw ¶
func (*WalrusBucket) GetBulkRaw ¶
func (bucket *WalrusBucket) GetBulkRaw(keys []string) (map[string][]byte, error)
func (*WalrusBucket) GetDDoc ¶
func (bucket *WalrusBucket) GetDDoc(docname string) (ddoc sgbucket.DesignDoc, err error)
func (*WalrusBucket) GetDDocs ¶
func (bucket *WalrusBucket) GetDDocs() (ddocs map[string]sgbucket.DesignDoc, err error)
func (*WalrusBucket) GetMaxVbno ¶
func (bucket *WalrusBucket) GetMaxVbno() (uint16, error)
func (*WalrusBucket) GetName ¶
func (bucket *WalrusBucket) GetName() string
func (*WalrusBucket) GetRaw ¶
func (bucket *WalrusBucket) GetRaw(k string) (rv []byte, cas uint64, err error)
func (*WalrusBucket) GetStatsVbSeqno ¶
func (*WalrusBucket) GetSubDocRaw ¶
func (bucket *WalrusBucket) GetSubDocRaw(_ context.Context, k string, subdocKey string) (value []byte, casOut uint64, err error)
GetSubDocRaw Walrus implementation only works with a top-level subdocKey
func (*WalrusBucket) GetWithXattr ¶
func (*WalrusBucket) IsError ¶
func (bucket *WalrusBucket) IsError(err error, errorType sgbucket.DataStoreErrorType) bool
func (*WalrusBucket) IsSupported ¶
func (bucket *WalrusBucket) IsSupported(feature sgbucket.BucketStoreFeature) bool
func (*WalrusBucket) ListDataStores ¶
func (bucket *WalrusBucket) ListDataStores() ([]sgbucket.DataStoreName, error)
func (*WalrusBucket) NamedDataStore ¶
func (bucket *WalrusBucket) NamedDataStore(name sgbucket.DataStoreName) (sgbucket.DataStore, error)
func (*WalrusBucket) Refresh ¶
func (bucket *WalrusBucket) Refresh() error
func (*WalrusBucket) Remove ¶
func (bucket *WalrusBucket) Remove(k string, cas uint64) (casOut uint64, err error)
func (*WalrusBucket) RemoveXattr ¶
func (*WalrusBucket) Set ¶
func (bucket *WalrusBucket) Set(k string, exp uint32, _ *sgbucket.UpsertOptions, v interface{}) error
func (*WalrusBucket) SetBulk ¶
func (bucket *WalrusBucket) SetBulk(entries []*sgbucket.BulkSetEntry) (err error)
func (*WalrusBucket) SetRaw ¶
func (bucket *WalrusBucket) SetRaw(k string, exp uint32, _ *sgbucket.UpsertOptions, v []byte) error
func (*WalrusBucket) SetVbAndSeq ¶
func (bucket *WalrusBucket) SetVbAndSeq(doc *walrusDoc, k string) (err error)
func (*WalrusBucket) StartDCPFeed ¶
func (bucket *WalrusBucket) StartDCPFeed(ctx context.Context, args sgbucket.FeedArguments, callback sgbucket.FeedEventCallbackFunc, dbStats *expvar.Map) error
Until a full DCP implementation is available, walrus wraps tap feed to invoke callback
func (*WalrusBucket) StartTapFeed ¶
func (bucket *WalrusBucket) StartTapFeed(args sgbucket.FeedArguments, dbStats *expvar.Map) (sgbucket.MutationFeed, error)
Starts a TAP feed on a client connection. The events can be read from the returned channel. To stop receiving events, call Close() on the feed.
func (*WalrusBucket) SubdocInsert ¶
func (*WalrusBucket) Touch ¶
func (bucket *WalrusBucket) Touch(k string, exp uint32) (casOut uint64, err error)
func (*WalrusBucket) UUID ¶
func (bucket *WalrusBucket) UUID() (string, error)
func (*WalrusBucket) Update ¶
func (bucket *WalrusBucket) Update(k string, exp uint32, callback sgbucket.UpdateFunc) (casOut uint64, err error)
func (*WalrusBucket) VBHash ¶
func (bucket *WalrusBucket) VBHash(docID string) uint32
func (*WalrusBucket) View ¶
func (bucket *WalrusBucket) View(_ context.Context, docName, viewName string, params map[string]interface{}) (sgbucket.ViewResult, error)
func (*WalrusBucket) ViewCustom ¶
func (*WalrusBucket) ViewQuery ¶
func (bucket *WalrusBucket) ViewQuery(ctx context.Context, ddoc, name string, params map[string]interface{}) (sgbucket.QueryResultIterator, error)
func (*WalrusBucket) Write ¶
func (bucket *WalrusBucket) Write(k string, flags int, exp uint32, v interface{}, opt sgbucket.WriteOptions) (err error)
func (*WalrusBucket) WriteCas ¶
func (bucket *WalrusBucket) WriteCas(k string, flags int, exp uint32, cas uint64, v interface{}, opt sgbucket.WriteOptions) (casOut uint64, err error)
func (*WalrusBucket) WriteCasWithXattr ¶
func (*WalrusBucket) WriteSubDoc ¶
func (bucket *WalrusBucket) WriteSubDoc(_ context.Context, k string, subdocKey string, cas uint64, value []byte) (casOut uint64, err error)
WriteSubDoc Walrus implementation only works with a top-level subdocKey
func (*WalrusBucket) WriteUpdate ¶
func (bucket *WalrusBucket) WriteUpdate(k string, exp uint32, callback sgbucket.WriteUpdateFunc) (casOut uint64, err error)
func (*WalrusBucket) WriteUpdateWithXattr ¶
func (bucket *WalrusBucket) WriteUpdateWithXattr(_ context.Context, k string, xattrKey string, userXattrKey string, exp uint32, opts *sgbucket.MutateInOptions, previous *sgbucket.BucketDocument, callback sgbucket.WriteUpdateWithXattrFunc) (casOut uint64, err error)
type WalrusCollection ¶
type WalrusCollection struct { *WalrusBucket FQName scopeAndCollection // Fully qualified collection name (scope and collection) CollectionID uint32 // Unique collectionID }
A WalrusCollection wraps a walrus single key value store to add metadata
func (*WalrusCollection) CollectionName ¶
func (wh *WalrusCollection) CollectionName() string
func (*WalrusCollection) ScopeName ¶
func (wh *WalrusCollection) ScopeName() string