2022-04-22 13:22:40 +00:00
|
|
|
package pilorama
|
|
|
|
|
|
|
|
import cidSDK "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
|
|
|
|
|
|
|
// Forest represents CRDT tree.
|
|
|
|
type Forest interface {
|
|
|
|
// TreeMove moves node in the tree.
|
|
|
|
// If the parent of the move operation is TrashID, the node is removed.
|
|
|
|
// If the child of the move operation is RootID, new ID is generated and added to a tree.
|
|
|
|
TreeMove(cid cidSDK.ID, treeID string, m *Move) (*LogMove, error)
|
|
|
|
// TreeAddByPath adds new node in the tree using provided path.
|
|
|
|
// The path is constructed by descending from the root using the values of the attr in meta.
|
2022-05-23 11:32:24 +00:00
|
|
|
// Internal nodes in path should have exactly one attribute, otherwise a new node is created.
|
2022-04-22 13:22:40 +00:00
|
|
|
TreeAddByPath(cid cidSDK.ID, treeID string, attr string, path []string, meta []KeyValue) ([]LogMove, error)
|
|
|
|
// TreeApply applies replicated operation from another node.
|
|
|
|
TreeApply(cid cidSDK.ID, treeID string, m *Move) error
|
|
|
|
// TreeGetByPath returns all nodes corresponding to the path.
|
|
|
|
// The path is constructed by descending from the root using the values of the
|
|
|
|
// AttributeFilename in meta.
|
|
|
|
// The last argument determines whether only the node with the latest timestamp is returned.
|
2022-05-04 09:47:11 +00:00
|
|
|
// Should return ErrTreeNotFound if the tree is not found, and empty result if the path is not in the tree.
|
2022-04-22 13:22:40 +00:00
|
|
|
TreeGetByPath(cid cidSDK.ID, treeID string, attr string, path []string, latest bool) ([]Node, error)
|
|
|
|
// TreeGetMeta returns meta information of the node with the specified ID.
|
2022-05-04 09:47:11 +00:00
|
|
|
// Should return ErrTreeNotFound if the tree is not found, and empty result if the node is not in the tree.
|
2022-05-20 08:41:37 +00:00
|
|
|
TreeGetMeta(cid cidSDK.ID, treeID string, nodeID Node) (Meta, Node, error)
|
2022-04-29 10:06:10 +00:00
|
|
|
// TreeGetChildren returns children of the node with the specified ID. The order is arbitrary.
|
2022-05-04 09:47:11 +00:00
|
|
|
// Should return ErrTreeNotFound if the tree is not found, and empty result if the node is not in the tree.
|
2022-04-29 10:06:10 +00:00
|
|
|
TreeGetChildren(cid cidSDK.ID, treeID string, nodeID Node) ([]uint64, error)
|
2022-04-22 13:22:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ForestStorage interface {
|
|
|
|
Init() error
|
|
|
|
Open() error
|
|
|
|
Close() error
|
|
|
|
Forest
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
AttributeFilename = "FileName"
|
|
|
|
AttributeVersion = "Version"
|
|
|
|
)
|