Documentation
¶
Index ¶
- Variables
- 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 ValidateRawTree(payload treestorage.TreeStorageCreatePayload, aclList list.AclList) (err error)
- type AddResult
- type AddResultSummary
- type BuildObjectTreeFunc
- type BuilderContent
- type Change
- type ChangeBuilder
- type ChangeConvertFunc
- type ChangeIterateFunc
- type ChangeValidator
- type DebugInfo
- type DescriptionParser
- type Flusher
- type HistoryTree
- type HistoryTreeParams
- type InMemoryStorageCreator
- type InitialContent
- type InitialDerivedContent
- type IteratorBatch
- type LoadIterator
- type MockChangeCreator
- func (c *MockChangeCreator) CreateDerivedRoot(id string, isDerived bool) *treechangeproto.RawTreeChangeWithId
- func (c *MockChangeCreator) CreateNewTreeStorage(treeId, aclHeadId string, isDerived bool) treestorage.TreeStorage
- 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(treeStorage treestorage.TreeStorage, aclList list.AclList) (ObjectTree, error)
- func BuildEmptyDataObjectTree(treeStorage treestorage.TreeStorage, aclList list.AclList) (ObjectTree, error)
- func BuildEmptyDataTestableTree(treeStorage treestorage.TreeStorage, aclList list.AclList) (ObjectTree, error)
- func BuildKeyFilterableObjectTree(treeStorage treestorage.TreeStorage, aclList list.AclList) (ObjectTree, error)
- func BuildObjectTree(treeStorage treestorage.TreeStorage, aclList list.AclList) (ObjectTree, error)
- func BuildTestableTree(treeStorage treestorage.TreeStorage, 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 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) 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 TreeStorageCreator
- type TryLocker
- type Updater
- type ValidatorFunc
Constants ¶
This section is empty.
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 ValidateRawTree ¶
func ValidateRawTree(payload treestorage.TreeStorageCreatePayload, aclList list.AclList) (err error)
Types ¶
type AddResult ¶
type AddResult struct {
OldHeads []string
Heads []string
Added []*treechangeproto.RawTreeChangeWithId
Mode Mode
}
type AddResultSummary ¶
type AddResultSummary int
type BuildObjectTreeFunc ¶
type BuildObjectTreeFunc = func(treeStorage treestorage.TreeStorage, 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
Model interface{}
Signature []byte
DataType string
IsSnapshot bool
IsDerived bool
IsNew bool
// 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 ChangeIterateFunc ¶
type ChangeValidator ¶ added in v0.5.1
type ChangeValidator = func(change *treechangeproto.RawTreeChangeWithId) error
type DescriptionParser ¶
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 HistoryTreeParams struct {
TreeStorage treestorage.TreeStorage
AclList list.AclList
Heads []string
IncludeBeforeId bool
}
type InMemoryStorageCreator ¶ added in v0.5.13
type InMemoryStorageCreator struct{}
func (InMemoryStorageCreator) CreateTreeStorage ¶ added in v0.5.13
func (i InMemoryStorageCreator) CreateTreeStorage(payload treestorage.TreeStorageCreatePayload) (treestorage.TreeStorage, error)
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{}
func NewMockChangeCreator ¶
func NewMockChangeCreator() *MockChangeCreator
func (*MockChangeCreator) CreateDerivedRoot ¶ added in v0.3.2
func (c *MockChangeCreator) CreateDerivedRoot(id string, isDerived bool) *treechangeproto.RawTreeChangeWithId
func (*MockChangeCreator) CreateNewTreeStorage ¶
func (c *MockChangeCreator) CreateNewTreeStorage(treeId, aclHeadId string, isDerived bool) treestorage.TreeStorage
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
ChangesAfterCommonSnapshot(snapshotPath, heads []string) ([]*treechangeproto.RawTreeChangeWithId, error)
ChangesAfterCommonSnapshotLoader(snapshotPath, heads []string) (LoadIterator, error)
Storage() treestorage.TreeStorage
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(treeStorage treestorage.TreeStorage, aclList list.AclList) (ObjectTree, error)
func BuildEmptyDataObjectTree ¶
func BuildEmptyDataObjectTree(treeStorage treestorage.TreeStorage, aclList list.AclList) (ObjectTree, error)
func BuildEmptyDataTestableTree ¶
func BuildEmptyDataTestableTree(treeStorage treestorage.TreeStorage, aclList list.AclList) (ObjectTree, error)
func BuildKeyFilterableObjectTree ¶ added in v0.3.21
func BuildKeyFilterableObjectTree(treeStorage treestorage.TreeStorage, aclList list.AclList) (ObjectTree, error)
func BuildObjectTree ¶
func BuildObjectTree(treeStorage treestorage.TreeStorage, aclList list.AclList) (ObjectTree, error)
func BuildTestableTree ¶
func BuildTestableTree(treeStorage treestorage.TreeStorage, 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
}
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 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) RemoveInvalidChange ¶
RemoveInvalidChange removes all the changes that are descendants of id
func (*Tree) ResetDuplicateEvents ¶
func (t *Tree) ResetDuplicateEvents()
type TreeStorageCreator ¶ added in v0.5.13
type TreeStorageCreator interface {
CreateTreeStorage(payload treestorage.TreeStorageCreatePayload) (treestorage.TreeStorage, 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
¶
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.