blob: 2fa5413b530f969c3d0b52716283943bf6a15461 [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package watchable
import (
"v.io/x/ref/services/syncbase/server/interfaces"
)
// GetOp represents a store get operation.
type GetOp struct {
Key []byte
}
// ScanOp represents a store scan operation.
type ScanOp struct {
Start []byte
Limit []byte
}
// PutOp represents a store put operation. The new version is written instead
// of the value to avoid duplicating the user data in the store. The version
// is used to access the user data of that specific mutation. The key and the
// version of the permissions entry that was checked to allow this put operation
// are also tracked to secure the access to this history.
type PutOp struct {
Key []byte
Version []byte
PermKey []byte
PermVersion []byte
}
// DeleteOp represents a store delete operation. The key and the version of the
// permissions entry that was checked to allow this delete operation are also
// tracked to secure the access to this history.
type DeleteOp struct {
Key []byte
PermKey []byte
PermVersion []byte
}
// SyncgroupOp represents a change in the set of prefixes that should be tracked
// by sync, i.e. the union of prefix sets across all syncgroups. Note that an
// individual syncgroup's prefixes cannot be changed; this record type is used
// to track changes due to syncgroup create/join/leave/destroy.
type SyncgroupOp struct {
SgId interfaces.GroupId
Prefixes []string
Remove bool
}
// SyncSnapshotOp represents a snapshot operation when creating and joining a
// syncgroup. The sync watcher needs to get a snapshot of the Database at the
// point of creating/joining a syncgroup. A SyncSnapshotOp entry is written to
// the log for each Database key that falls within the syncgroup prefixes. This
// allows sync to initialize its metadata at the correct versions of the objects
// when they become syncable. These log entries should be filtered by the
// client-facing Watch interface because the user data did not actually change.
// The key and the version of the permissions entry that was checked when the
// key was accessed are also tracked to secure the access to this history.
type SyncSnapshotOp struct {
Key []byte
Version []byte
PermKey []byte
PermVersion []byte
}
// Op represents a store operation.
type Op union {
Get GetOp
Scan ScanOp
Put PutOp
Delete DeleteOp
Syncgroup SyncgroupOp
SyncSnapshot SyncSnapshotOp
}
// LogEntry represents a single store operation. This operation may have been
// part of a transaction, as signified by the Continued boolean. Read-only
// operations (and read-only transactions) are not logged.
type LogEntry struct {
// The store operation that was performed.
Op Op
// Time when the operation was committed.
CommitTimestamp int64
// Operation came from sync (used for echo suppression).
FromSync bool
// If true, this entry is followed by more entries that belong to the same
// commit as this entry.
Continued bool
}