Documentation
¶
Index ¶
- Constants
- Variables
- func CopyStore(ctx context.Context, t *testing.T, store TestStore, name string) anystore.DB
- func CreateObjectTreeRoot(payload ObjectTreeCreatePayload, aclList list.AclList) (root *treechangeproto.RawTreeChangeWithId, err error)
- func DeriveObjectTreeRoot(payload ObjectTreeDerivePayload, aclList list.AclList) (root *treechangeproto.RawTreeChangeWithId, err error)
- func DoSnapshot(treeLen int) bool
- func IsDerivedRoot(root *treechangeproto.RawTreeChangeWithId) (derived bool, err error)
- func IsEmptyDerivedTree(tree ObjectTree) bool
- func IsEmptyTree(tree ObjectTree) bool
- func UnmarshallRoot(rawRoot *treechangeproto.RawTreeChangeWithId) (root *treechangeproto.RootChange, err error)
- func ValidateRawTree(payload treestorage.TreeStorageCreatePayload, aclList list.AclList, ...) (err error)
- type AddResult
- type AddResultSummary
- type BuildObjectTreeFunc
- type BuilderContent
- type Change
- type ChangeBuilder
- type ChangeConvertFunc
- type ChangeDiffer
- type ChangeIterateFunc
- type ChangeValidator
- type DebugInfo
- type DescriptionParser
- type DiffManager
- type Flusher
- type HistoryTree
- type HistoryTreeParams
- type InitialContent
- type InitialDerivedContent
- type IteratorBatch
- type LoadIterator
- type MockChangeCreator
- func (c *MockChangeCreator) CreateDerivedRoot(id string, isDerived bool) *treechangeproto.RawTreeChangeWithId
- func (c *MockChangeCreator) CreateNewTreeStorage(t *testing.T, treeId, aclHeadId string, isDerived bool) Storage
- func (c *MockChangeCreator) CreateRaw(id, aclId, snapshotId string, isSnapshot bool, prevIds ...string) *treechangeproto.RawTreeChangeWithId
- func (c *MockChangeCreator) CreateRawWithData(id, aclId, snapshotId string, isSnapshot bool, data []byte, prevIds ...string) *treechangeproto.RawTreeChangeWithId
- func (c *MockChangeCreator) CreateRoot(id, aclId string) *treechangeproto.RawTreeChangeWithId
- type Mode
- type ObjectTree
- func BuildEmptyDataKeyFilterableObjectTree(storage Storage, aclList list.AclList) (ObjectTree, error)
- func BuildEmptyDataObjectTree(storage Storage, aclList list.AclList) (ObjectTree, error)
- func BuildEmptyDataTestableTree(storage Storage, aclList list.AclList) (ObjectTree, error)
- func BuildKeyFilterableObjectTree(storage Storage, aclList list.AclList) (ObjectTree, error)
- func BuildMigratableObjectTree(storage Storage, aclList list.AclList) (ObjectTree, error)
- func BuildObjectTree(storage Storage, aclList list.AclList) (ObjectTree, error)
- func BuildTestableTree(storage Storage, aclList list.AclList) (ObjectTree, error)
- func ValidateFilterRawTree(payload treestorage.TreeStorageCreatePayload, ...) (objTree ObjectTree, err error)
- func ValidateRawTreeDefault(payload treestorage.TreeStorageCreatePayload, ...) (objTree ObjectTree, err error)
- type ObjectTreeCreatePayload
- type ObjectTreeDerivePayload
- type ObjectTreeValidator
- type RawChangesPayload
- type ReadableObjectTree
- type SignableChangeContent
- type Storage
- type StorageChange
- type StorageIterator
- type TestStore
- type Tree
- func (t *Tree) Add(changes ...*Change) (mode Mode, added []*Change)
- func (t *Tree) AddFast(changes ...*Change) []*Change
- func (t *Tree) AddMergedHead(c *Change) error
- func (t *Tree) Get(id string) *Change
- func (t *Tree) GetDuplicateEvents() int
- func (t *Tree) Graph(parser DescriptionParser) (data string, err error)
- func (t *Tree) Hash() string
- func (t *Tree) Heads() []string
- func (t *Tree) HeadsChanges() []*Change
- func (t *Tree) IterateBranching(startId string, f func(c *Change, branchLevel int) (isContinue bool))
- func (t *Tree) IterateSkip(startId string, f func(c *Change) (isContinue bool))
- func (t *Tree) LeaveOnlyBefore(proposedHeads []string)
- func (t *Tree) Len() int
- func (t *Tree) RemoveInvalidChange(id string)
- func (t *Tree) ResetDuplicateEvents()
- func (t *Tree) Root() *Change
- func (t *Tree) RootId() string
- func (t *Tree) String() string
- type TreeMigrator
- type TreeStorageCreator
- type TryLocker
- type Updater
- type ValidatorFunc
Constants ¶
View Source
const ( OrderKey = "o" SnapshotCounterKey = "sc" ChangeSizeKey = "sz" TreeKey = "t" CollName = "changes" )
Variables ¶
View Source
var ( ErrIncorrectSignature = errors.New("change has incorrect signature") ErrIncorrectCid = errors.New("change has incorrect CID") )
View Source
var ( ErrHasInvalidChanges = errors.New("the change is invalid") ErrNoCommonSnapshot = errors.New("trees doesn't have a common snapshot") ErrNoChangeInTree = errors.New("no such change in tree") ErrMissingKey = errors.New("missing current read key") ErrDerived = errors.New("expect >= 2 changes in derived tree") ErrDeleted = errors.New("object tree is deleted") ErrNoAclHead = errors.New("no acl head") )
View Source
var (
ErrEmpty = errors.New("logs empty")
)
View Source
var ErrEmptyChange = errors.New("change payload should not be empty")
View Source
var ErrLoadBeforeRoot = errors.New("can't load before root")
View Source
var NoOpDescriptionParser = noopDescriptionParser{}
Functions ¶
func CreateObjectTreeRoot ¶
func CreateObjectTreeRoot(payload ObjectTreeCreatePayload, aclList list.AclList) (root *treechangeproto.RawTreeChangeWithId, err error)
func DeriveObjectTreeRoot ¶ added in v0.3.2
func DeriveObjectTreeRoot(payload ObjectTreeDerivePayload, aclList list.AclList) (root *treechangeproto.RawTreeChangeWithId, err error)
func DoSnapshot ¶
func IsDerivedRoot ¶ added in v0.3.2
func IsDerivedRoot(root *treechangeproto.RawTreeChangeWithId) (derived bool, err error)
func IsEmptyDerivedTree ¶ added in v0.3.2
func IsEmptyDerivedTree(tree ObjectTree) bool
func IsEmptyTree ¶ added in v0.3.21
func IsEmptyTree(tree ObjectTree) bool
func UnmarshallRoot ¶ added in v0.5.23
func UnmarshallRoot(rawRoot *treechangeproto.RawTreeChangeWithId) (root *treechangeproto.RootChange, err error)
func ValidateRawTree ¶
func ValidateRawTree(payload treestorage.TreeStorageCreatePayload, aclList list.AclList, store anystore.DB) (err error)
Types ¶
type AddResult ¶
type AddResult struct {
OldHeads []string
Heads []string
Added []StorageChange
Mode Mode
}
func (AddResult) RawChanges ¶ added in v0.6.0
func (a AddResult) RawChanges() []*treechangeproto.RawTreeChangeWithId
type AddResultSummary ¶
type AddResultSummary int
type BuildObjectTreeFunc ¶
type BuildObjectTreeFunc = func(storage Storage, aclList list.AclList) (ObjectTree, error)
type BuilderContent ¶
type Change ¶
type Change struct {
Next []*Change
PreviousIds []string
Previous []*Change
AclHeadId string
Id string
SnapshotId string
Timestamp int64
ReadKeyId string
Identity crypto.PubKey
Data []byte
// TODO: add call one time comment
Model interface{}
Signature []byte
DataType string
IsSnapshot bool
IsDerived bool
IsNew bool
OrderId string
SnapshotCounter int
// contains filtered or unexported fields
}
Change is an abstract type for all types of changes
func NewChangeFromRoot ¶
func NewChangeFromRoot(id string, identity crypto.PubKey, ch *treechangeproto.RootChange, signature []byte, isDerived bool) *Change
type ChangeBuilder ¶
type ChangeBuilder interface {
Unmarshall(rawIdChange *treechangeproto.RawTreeChangeWithId, verify bool) (ch *Change, err error)
UnmarshallReduced(rawIdChange *treechangeproto.RawTreeChangeWithId) (ch *Change, err error)
Build(payload BuilderContent) (ch *Change, raw *treechangeproto.RawTreeChangeWithId, err error)
BuildRoot(payload InitialContent) (ch *Change, raw *treechangeproto.RawTreeChangeWithId, err error)
BuildDerivedRoot(payload InitialDerivedContent) (ch *Change, raw *treechangeproto.RawTreeChangeWithId, err error)
Marshall(ch *Change) (*treechangeproto.RawTreeChangeWithId, error)
}
func NewChangeBuilder ¶
func NewChangeBuilder(keys crypto.KeyStorage, rootChange *treechangeproto.RawTreeChangeWithId) ChangeBuilder
func NewEmptyDataChangeBuilder ¶ added in v0.5.0
func NewEmptyDataChangeBuilder(keys crypto.KeyStorage, rootChange *treechangeproto.RawTreeChangeWithId) ChangeBuilder
type ChangeConvertFunc ¶
type ChangeDiffer ¶ added in v0.6.0
type ChangeDiffer struct {
// contains filtered or unexported fields
}
func NewChangeDiffer ¶ added in v0.6.0
func NewChangeDiffer(tree ReadableObjectTree, hasChanges hasChangesFunc) (*ChangeDiffer, error)
func (*ChangeDiffer) Add ¶ added in v0.6.0
func (d *ChangeDiffer) Add(changes ...*Change)
func (*ChangeDiffer) RemoveBefore ¶ added in v0.6.0
type ChangeIterateFunc ¶
type ChangeValidator ¶ added in v0.5.1
type ChangeValidator = func(change StorageChange) error
type DescriptionParser ¶
type DiffManager ¶ added in v0.6.0
type DiffManager struct {
// contains filtered or unexported fields
}
func NewDiffManager ¶ added in v0.6.0
func NewDiffManager(initHeads, curHeads []string, treeBuilder treeBuilderFunc, onRemove onRemoveFunc) (*DiffManager, error)
func (*DiffManager) Add ¶ added in v0.6.0
func (d *DiffManager) Add(change *Change)
func (*DiffManager) Init ¶ added in v0.6.0
func (d *DiffManager) Init()
func (*DiffManager) Remove ¶ added in v0.6.0
func (d *DiffManager) Remove(ids []string)
func (*DiffManager) SeenHeads ¶ added in v0.6.0
func (d *DiffManager) SeenHeads() []string
func (*DiffManager) Update ¶ added in v0.6.0
func (d *DiffManager) Update(objTree ObjectTree)
type Flusher ¶ added in v0.5.1
type Flusher interface {
MarkNewChange(ch *Change)
FlushAfterBuild(t *objectTree) error
Flush(t *objectTree) error
}
func MarkNewChangeFlusher ¶ added in v0.5.1
func MarkNewChangeFlusher() Flusher
type HistoryTree ¶
type HistoryTree interface {
ReadableObjectTree
}
func BuildHistoryTree ¶
func BuildHistoryTree(params HistoryTreeParams) (HistoryTree, error)
func BuildNonVerifiableHistoryTree ¶
func BuildNonVerifiableHistoryTree(params HistoryTreeParams) (HistoryTree, error)
type HistoryTreeParams ¶
type InitialContent ¶
type InitialDerivedContent ¶ added in v0.3.2
type IteratorBatch ¶ added in v0.5.0
type IteratorBatch struct {
Batch []*treechangeproto.RawTreeChangeWithId
Heads []string
SnapshotPath []string
Root *treechangeproto.RawTreeChangeWithId
}
type LoadIterator ¶ added in v0.5.0
type LoadIterator interface {
NextBatch(maxSize int) (batch IteratorBatch, err error)
}
type MockChangeCreator ¶
type MockChangeCreator struct {
// contains filtered or unexported fields
}
func NewMockChangeCreator ¶
func NewMockChangeCreator(storeCreator func() anystore.DB) *MockChangeCreator
func (*MockChangeCreator) CreateDerivedRoot ¶ added in v0.3.2
func (c *MockChangeCreator) CreateDerivedRoot(id string, isDerived bool) *treechangeproto.RawTreeChangeWithId
func (*MockChangeCreator) CreateNewTreeStorage ¶
func (*MockChangeCreator) CreateRaw ¶
func (c *MockChangeCreator) CreateRaw(id, aclId, snapshotId string, isSnapshot bool, prevIds ...string) *treechangeproto.RawTreeChangeWithId
func (*MockChangeCreator) CreateRawWithData ¶
func (c *MockChangeCreator) CreateRawWithData(id, aclId, snapshotId string, isSnapshot bool, data []byte, prevIds ...string) *treechangeproto.RawTreeChangeWithId
func (*MockChangeCreator) CreateRoot ¶
func (c *MockChangeCreator) CreateRoot(id, aclId string) *treechangeproto.RawTreeChangeWithId
type ObjectTree ¶
type ObjectTree interface {
ReadableObjectTree
SnapshotPath() []string
ChangesAfterCommonSnapshotLoader(snapshotPath, heads []string) (LoadIterator, error)
Storage() Storage
AddContent(ctx context.Context, content SignableChangeContent) (AddResult, error)
AddContentWithValidator(ctx context.Context, content SignableChangeContent, validate ChangeValidator) (AddResult, error)
AddRawChanges(ctx context.Context, changes RawChangesPayload) (AddResult, error)
AddRawChangesWithUpdater(ctx context.Context, changes RawChangesPayload, updater Updater) (AddResult, error)
UnpackChange(raw *treechangeproto.RawTreeChangeWithId) (data []byte, err error)
PrepareChange(content SignableChangeContent) (res *treechangeproto.RawTreeChangeWithId, err error)
Delete() error
Close() error
SetFlusher(flusher Flusher)
TryClose(objectTTL time.Duration) (bool, error)
}
func BuildEmptyDataKeyFilterableObjectTree ¶ added in v0.5.13
func BuildEmptyDataKeyFilterableObjectTree(storage Storage, aclList list.AclList) (ObjectTree, error)
func BuildEmptyDataObjectTree ¶
func BuildEmptyDataObjectTree(storage Storage, aclList list.AclList) (ObjectTree, error)
func BuildEmptyDataTestableTree ¶
func BuildEmptyDataTestableTree(storage Storage, aclList list.AclList) (ObjectTree, error)
func BuildKeyFilterableObjectTree ¶ added in v0.3.21
func BuildKeyFilterableObjectTree(storage Storage, aclList list.AclList) (ObjectTree, error)
func BuildMigratableObjectTree ¶ added in v0.6.0
func BuildMigratableObjectTree(storage Storage, aclList list.AclList) (ObjectTree, error)
func BuildObjectTree ¶
func BuildObjectTree(storage Storage, aclList list.AclList) (ObjectTree, error)
func BuildTestableTree ¶
func BuildTestableTree(storage Storage, aclList list.AclList) (ObjectTree, error)
func ValidateFilterRawTree ¶ added in v0.3.21
func ValidateFilterRawTree(payload treestorage.TreeStorageCreatePayload, storageCreator TreeStorageCreator, aclList list.AclList) (objTree ObjectTree, err error)
func ValidateRawTreeDefault ¶ added in v0.5.13
func ValidateRawTreeDefault(payload treestorage.TreeStorageCreatePayload, storageCreator TreeStorageCreator, aclList list.AclList) (objTree ObjectTree, err error)
type ObjectTreeCreatePayload ¶
type ObjectTreeDerivePayload ¶ added in v0.3.2
type ObjectTreeValidator ¶
type ObjectTreeValidator interface {
// ValidateFullTree should always be entered while holding a read lock on AclList
ValidateFullTree(tree *Tree, aclList list.AclList) error
// ValidateNewChanges should always be entered while holding a read lock on AclList
ValidateNewChanges(tree *Tree, aclList list.AclList, newChanges []*Change) error
FilterChanges(aclList list.AclList, changes []*Change, snapshots []*Change, indexes []int) (filteredHeads bool, filtered, filteredSnapshots []*Change, newIndexes []int)
}
type RawChangesPayload ¶
type RawChangesPayload struct {
NewHeads []string
RawChanges []*treechangeproto.RawTreeChangeWithId
SnapshotPath []string
}
type ReadableObjectTree ¶
type ReadableObjectTree interface {
TryLocker
Id() string
Header() *treechangeproto.RawTreeChangeWithId
UnmarshalledHeader() *Change
ChangeInfo() *treechangeproto.TreeChangeInfo
Heads() []string
Root() *Change
Len() int
IsDerived() bool
AclList() list.AclList
HasChanges(...string) bool
GetChange(string) (*Change, error)
Debug(parser DescriptionParser) (DebugInfo, error)
IterateRoot(convert ChangeConvertFunc, iterate ChangeIterateFunc) error
IterateFrom(id string, convert ChangeConvertFunc, iterate ChangeIterateFunc) error
}
type SignableChangeContent ¶
type SignableChangeContent struct {
// Data is a data provided by the client
Data []byte
// Key is the key which will be used to sign the change
Key crypto.PrivKey
// IsSnapshot tells if the change has snapshot of all previous data
IsSnapshot bool
// IsEncrypted tells if we encrypt the data with the relevant symmetric key
IsEncrypted bool
// Timestamp is a timestamp of change, if it is <= 0, then we use current timestamp
Timestamp int64
// DataType contains additional info about the data in the payload
DataType string
}
SignableChangeContent is a payload to be passed when we are creating change
type Storage ¶ added in v0.6.0
type Storage interface {
Id() string
Root(ctx context.Context) (StorageChange, error)
Heads(ctx context.Context) ([]string, error)
CommonSnapshot(ctx context.Context) (string, error)
Has(ctx context.Context, id string) (bool, error)
Get(ctx context.Context, id string) (StorageChange, error)
GetAfterOrder(ctx context.Context, orderId string, iter StorageIterator) error
AddAll(ctx context.Context, changes []StorageChange, heads []string, commonSnapshot string) error
AddAllNoError(ctx context.Context, changes []StorageChange, heads []string, commonSnapshot string) error
Delete(ctx context.Context) error
Close() error
}
func CreateStorage ¶ added in v0.6.0
func CreateStorage(ctx context.Context, root *treechangeproto.RawTreeChangeWithId, headStorage headstorage.HeadStorage, store anystore.DB) (Storage, error)
func NewStorage ¶ added in v0.6.0
func NewStorage(ctx context.Context, id string, headStorage headstorage.HeadStorage, store anystore.DB) (Storage, error)
type StorageChange ¶ added in v0.6.0
type StorageChange struct {
RawChange []byte
PrevIds []string
Id string
SnapshotCounter int
SnapshotId string
OrderId string
ChangeSize int
TreeId string
}
func (StorageChange) RawTreeChangeWithId ¶ added in v0.6.0
func (c StorageChange) RawTreeChangeWithId() *treechangeproto.RawTreeChangeWithId
type StorageIterator ¶ added in v0.6.0
type StorageIterator = func(ctx context.Context, change StorageChange) (shouldContinue bool, err error)
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
func (*Tree) AddMergedHead ¶
func (*Tree) GetDuplicateEvents ¶
func (*Tree) HeadsChanges ¶
func (*Tree) IterateBranching ¶
func (*Tree) IterateSkip ¶
func (*Tree) LeaveOnlyBefore ¶ added in v0.6.0
func (*Tree) RemoveInvalidChange ¶
RemoveInvalidChange removes all the changes that are descendants of id
func (*Tree) ResetDuplicateEvents ¶
func (t *Tree) ResetDuplicateEvents()
type TreeMigrator ¶ added in v0.6.0
type TreeMigrator struct {
// contains filtered or unexported fields
}
func NewTreeMigrator ¶ added in v0.6.0
func NewTreeMigrator(keyStorage crypto.KeyStorage, aclList list.AclList) *TreeMigrator
func (*TreeMigrator) MigrateTreeStorage ¶ added in v0.6.0
func (tm *TreeMigrator) MigrateTreeStorage(ctx context.Context, storage treeStorage, headStorage headstorage.HeadStorage, store anystore.DB) error
type TreeStorageCreator ¶ added in v0.5.13
type TreeStorageCreator interface {
CreateTreeStorage(ctx context.Context, payload treestorage.TreeStorageCreatePayload) (Storage, error)
}
type Updater ¶ added in v0.5.1
type Updater = func(tree ObjectTree, md Mode) error
type ValidatorFunc ¶ added in v0.3.21
type ValidatorFunc func(payload treestorage.TreeStorageCreatePayload, storageCreator TreeStorageCreator, aclList list.AclList) (ret ObjectTree, err error)
Source Files
¶
- change.go
- changebuilder.go
- changediffer.go
- derivedtree.go
- descriptionparser.go
- flusher.go
- historytree.go
- loaditerator.go
- objecttree.go
- objecttreedebug.go
- objecttreefactory.go
- objecttreevalidator.go
- signablecontent.go
- storage.go
- testutils.go
- tree.go
- treebuilder.go
- treegraph_nix.go
- treeiterator.go
- treemigrator.go
- treereduce.go
- util.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mock_objecttree is a generated GoMock package.
|
Package mock_objecttree is a generated GoMock package. |
Click to show internal directories.
Click to hide internal directories.