Documentation ¶
Index ¶
- Variables
- func GenerateNewCas(now time.Time) uint64
- type Bucket
- func (b *Bucket) Chrono() *mocktime.Chrono
- func (b *Bucket) Compact() error
- func (b *Bucket) Flush()
- func (b *Bucket) Get(repIdx, vbIdx uint, collectionID uint, key []byte) (*Document, error)
- func (b *Bucket) GetAll(repIdx, collectionID uint) ([]*Document, error)
- func (b *Bucket) GetRandom(repIdx, collectionID uint) (*Document, error)
- func (b *Bucket) GetVbucket(vbIdx uint) *Vbucket
- func (b *Bucket) Insert(doc *Document) (*Document, error)
- func (b *Bucket) Remove(vbIdx uint, key []byte) (*Document, error)
- func (b *Bucket) Rollback(snap *BucketSnapshot) error
- func (b *Bucket) Snapshot() *BucketSnapshot
- func (b *Bucket) Update(vbID, collectionID uint, key []byte, fn UpdateFunc) (*Document, error)
- type BucketSnapshot
- type Document
- type NewBucketOptions
- type UpdateFunc
- type VbMetaState
- type VbRevData
- type Vbucket
- func (s *Vbucket) Compact() error
- func (s *Vbucket) CurrentMetaState(repIdx uint) VbMetaState
- func (s *Vbucket) Flush()
- func (s *Vbucket) Get(repIdx, collectionID uint, key []byte) (*Document, error)
- func (s *Vbucket) GetAll(repIdx, collectionID uint) ([]*Document, error)
- func (s *Vbucket) GetAllWithin(repIdx uint, startSeqNo, endSeqNo uint64) ([]*Document, uint64, error)
- func (s *Vbucket) GetRandom(repIdx, collectionID uint) *Document
Constants ¶
This section is empty.
Variables ¶
var ErrDocExists = errors.New("document already exists")
ErrDocExists is thrown when document was expected not to exist, but did.
var ErrDocNotFound = errors.New("document not found")
ErrDocNotFound is thrown when a document was expected to exist but did not.
var ErrValueTooBig = errors.New("document value too large")
ErrValueTooBig is thrown when a document was set with a value that is too large.
Functions ¶
func GenerateNewCas ¶
GenerateNewCas will generate a new CAS to use with a document.
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket represents a Bucket store
func NewBucket ¶
func NewBucket(opts NewBucketOptions) (*Bucket, error)
NewBucket will create a new Bucket store.
func (*Bucket) Compact ¶
Compact will compact all of the vbuckets within this bucket. This is not yet supported. See Vbucket::Compact for details on why.
func (*Bucket) GetRandom ¶
GetRandom fetches a random document from a particular replica and vbucket index.
func (*Bucket) GetVbucket ¶
GetVbucket will return the Vbucket object for a particular replica and vbucket index within this particular bucket store.
func (*Bucket) Rollback ¶
func (b *Bucket) Rollback(snap *BucketSnapshot) error
Rollback will rollback the bucket to a previously snapshotted state.
func (*Bucket) Snapshot ¶
func (b *Bucket) Snapshot() *BucketSnapshot
Snapshot returns a snapshot of the current state of a Bucket which can be used to later rollback to the bucket to that point in time.
type BucketSnapshot ¶
type BucketSnapshot struct {
// contains filtered or unexported fields
}
BucketSnapshot represents a snapshot of the bucket at a point in time. This can later be used to rollback the bucket to this point in time.
type Document ¶
type Document struct { VbID uint CollectionID uint Key []byte Value []byte Xattrs map[string][]byte Flags uint32 Datatype uint8 IsDeleted bool Expiry time.Time LockExpiry time.Time VbUUID uint64 Cas uint64 SeqNo uint64 ModifiedTime time.Time RevID uint64 }
Document represents one document stored in the vbucket. For the purposes of simplicity of this mock storage engine, this one object is used throughout the implementation.
type NewBucketOptions ¶
type NewBucketOptions struct { Chrono *mocktime.Chrono NumReplicas uint NumVbuckets uint ReplicaLatency time.Duration PersistLatency time.Duration }
NewBucketOptions specifies the configuration for a new Bucket store.
type UpdateFunc ¶
UpdateFunc represents a function which can modify the state of a document.
type VbMetaState ¶
VbMetaState holds some information about the meta-state of a vbucket.
type Vbucket ¶
type Vbucket struct {
// contains filtered or unexported fields
}
Vbucket represents a single Vbucket worth of documents
func (*Vbucket) Compact ¶
Compact will compact all of the mutations within a vbucket such that no two sequence numbers exist which are for the same document key.
func (*Vbucket) CurrentMetaState ¶
func (s *Vbucket) CurrentMetaState(repIdx uint) VbMetaState
CurrentMetaState returns the current sequence numbering information. Returns the vbuuid, seqno and persistSeqno.
func (*Vbucket) Flush ¶
func (s *Vbucket) Flush()
Flush is a basic implementation of this process and simply resets the documents in the vbucket and resets the max seq no
func (*Vbucket) GetAllWithin ¶
func (s *Vbucket) GetAllWithin(repIdx uint, startSeqNo, endSeqNo uint64) ([]*Document, uint64, error)
GetAllWithin returns a list of all the mutations that have occurred in a vbucket within the bounds of the sequence numbers passed. NOTE: There is an assumption that the items returned by this method are in ascending seqno order, and that last-modified times are in ascending order as well.