1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00

Update code to work with acl lists and new models

This commit is contained in:
mcrakhman 2022-08-20 14:28:06 +02:00 committed by Mikhail Iudin
parent 48a64edce7
commit 86118686ad
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
23 changed files with 1340 additions and 394 deletions

View file

@ -18,22 +18,19 @@ protos-go:
# Uncomment if needed
@$(eval ROOT_PKG := pkg)
@$(eval GOGO_START := GOGO_NO_UNDERSCORE=1 GOGO_EXPORT_ONEOF_INTERFACE=1)
@$(eval P_TREE_STORAGE_PATH_PB := $(ROOT_PKG)/acl/treestorage/treepb)
@$(eval P_ACL_CHANGES_PATH_PB := $(ROOT_PKG)/acl/aclchanges/aclpb)
@$(eval P_PLAINTEXT_CHANGES_PATH_PB := $(ROOT_PKG)/acl/testutils/testchanges/testchangepb)
@$(eval P_SYNC_CHANGES_PATH_PB := syncproto)
@$(eval P_TEST_CHANGES_PATH_PB := $(ROOT_PKG)/acl/testutils/testchanges)
@$(eval P_TIMESTAMP := Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types)
@$(eval P_STRUCT := Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types)
@$(eval P_ACL_CHANGES := M$(P_ACL_CHANGES_PATH_PB)/protos/aclchanges.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/$(P_ACL_CHANGES_PATH_PB))
@$(eval P_TREE_CHANGES := M$(P_TREE_STORAGE_PATH_PB)/protos/tree.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/$(P_TREE_STORAGE_PATH_PB))
# use if needed $(eval PKGMAP := $$(P_TIMESTAMP),$$(P_STRUCT))
$(GOGO_START) protoc --gogofaster_out=:. $(P_ACL_CHANGES_PATH_PB)/protos/*.proto; mv $(P_ACL_CHANGES_PATH_PB)/protos/*.go $(P_ACL_CHANGES_PATH_PB)
$(GOGO_START) protoc --gogofaster_out=:. $(P_TREE_STORAGE_PATH_PB)/protos/*.proto; mv $(P_TREE_STORAGE_PATH_PB)/protos/*.go $(P_TREE_STORAGE_PATH_PB)
$(eval PKGMAP := $$(P_ACL_CHANGES),$$(P_TREE_CHANGES))
$(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. $(P_SYNC_CHANGES_PATH_PB)/proto/*.proto
$(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. service/space/spacesync/protos/*.proto
$(GOGO_START) protoc --gogofaster_out=:. $(P_TEST_CHANGES_PATH_PB)/proto/*.proto
$(eval PKGMAP := $$(P_ACL_CHANGES))
$(GOGO_START) protoc --gogofaster_out=$(PKGMAP),plugins=grpc:. $(P_SYNC_CHANGES_PATH_PB)/proto/*.proto
build:
@$(eval FLAGS := $$(shell govvv -flags -pkg github.com/anytypeio/go-anytype-infrastructure-experiments/app))
go build -v -o bin/anytype-node -ldflags "$(FLAGS)" cmd/node/node.go
go build -o bin/anytype-node -ldflags "$(FLAGS)" cmd/node/node.go

View file

@ -5,6 +5,7 @@ import (
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
"sync"
)
@ -21,6 +22,7 @@ type ACLList interface {
Get(id string) (*Record, error)
Iterate(iterFunc IterFunc)
IterateFrom(startId string, iterFunc IterFunc)
Close() (err error)
}
type aclList struct {
@ -35,7 +37,7 @@ type aclList struct {
sync.RWMutex
}
func BuildACLListWithIdentity(acc *account.AccountData, storage Storage) (ACLList, error) {
func BuildACLListWithIdentity(acc *account.AccountData, storage storage.ListStorage) (ACLList, error) {
builder := newACLStateBuilderWithIdentity(acc.Decoder, acc)
header, err := storage.Header()
if err != nil {
@ -54,7 +56,7 @@ func BuildACLListWithIdentity(acc *account.AccountData, storage Storage) (ACLLis
records := []*Record{record}
for record.Content.PrevId != "" {
rawRecord, err = storage.GetRecord(context.Background(), record.Content.PrevId)
rawRecord, err = storage.GetRawRecord(context.Background(), record.Content.PrevId)
if err != nil {
return nil, err
}
@ -109,7 +111,7 @@ func (a *aclList) IsAfter(first string, second string) (bool, error) {
if !okFirst || !okSecond {
return false, fmt.Errorf("not all entries are there: first (%b), second (%b)", okFirst, okSecond)
}
return firstRec > secondRec, nil
return firstRec >= secondRec, nil
}
func (a *aclList) Head() *Record {
@ -143,3 +145,7 @@ func (a *aclList) IterateFrom(startId string, iterFunc IterFunc) {
}
}
}
func (a *aclList) Close() (err error) {
return nil
}

View file

@ -1,14 +0,0 @@
package list
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
)
type Storage interface {
ID() (string, error)
Head() (*aclpb.RawRecord, error)
Header() (*aclpb.Header, error)
GetRecord(ctx context.Context, id string) (*aclpb.RawRecord, error)
AddRecord(ctx context.Context, rec *aclpb.RawRecord) error
}

View file

@ -1,4 +1,4 @@
package treestorage
package storage
import (
"context"
@ -86,21 +86,21 @@ func (t *inMemoryTreeStorage) GetRawChange(ctx context.Context, changeId string)
return nil, fmt.Errorf("could not get change with id: %s", changeId)
}
type inMemoryTreeStorageProvider struct {
trees map[string]TreeStorage
type inMemoryStorageProvider struct {
objects map[string]Storage
sync.RWMutex
}
func (i *inMemoryTreeStorageProvider) TreeStorage(treeId string) (TreeStorage, error) {
func (i *inMemoryStorageProvider) Storage(id string) (Storage, error) {
i.RLock()
defer i.RUnlock()
if tree, exists := i.trees[treeId]; exists {
if tree, exists := i.objects[id]; exists {
return tree, nil
}
return nil, ErrUnknownTreeId
}
func (i *inMemoryTreeStorageProvider) CreateTreeStorage(treeId string, header *aclpb.Header, changes []*aclpb.RawChange) (TreeStorage, error) {
func (i *inMemoryStorageProvider) CreateTreeStorage(treeId string, header *aclpb.Header, changes []*aclpb.RawChange) (TreeStorage, error) {
i.Lock()
defer i.Unlock()
res, err := NewInMemoryTreeStorage(treeId, header, changes)
@ -108,12 +108,12 @@ func (i *inMemoryTreeStorageProvider) CreateTreeStorage(treeId string, header *a
return nil, err
}
i.trees[treeId] = res
i.objects[treeId] = res
return res, nil
}
func NewInMemoryTreeStorageProvider() Provider {
return &inMemoryTreeStorageProvider{
trees: make(map[string]TreeStorage),
return &inMemoryStorageProvider{
objects: make(map[string]Storage),
}
}

View file

@ -0,0 +1,14 @@
package storage
import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
)
type ListStorage interface {
Storage
Head() (*aclpb.RawRecord, error)
GetRawRecord(ctx context.Context, id string) (*aclpb.RawRecord, error)
AddRawRecord(ctx context.Context, rec *aclpb.RawRecord) error
}

View file

@ -1,4 +1,4 @@
package treestorage
package storage
import (
"errors"
@ -8,6 +8,6 @@ import (
var ErrUnknownTreeId = errors.New("tree does not exist")
type Provider interface {
TreeStorage(treeId string) (TreeStorage, error)
Storage(id string) (Storage, error)
CreateTreeStorage(treeId string, header *aclpb.Header, changes []*aclpb.RawChange) (TreeStorage, error)
}

View file

@ -0,0 +1,8 @@
package storage
import "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
type Storage interface {
ID() (string, error)
Header() (*aclpb.Header, error)
}

View file

@ -1,4 +1,4 @@
package treestorage
package storage
import (
"context"
@ -6,9 +6,7 @@ import (
)
type TreeStorage interface {
ID() (string, error)
Header() (*aclpb.Header, error)
Storage
Heads() ([]string, error)
SetHeads(heads []string) error

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,24 @@
syntax = "proto3";
package anytype;
option go_package = "testchanges";
message PlainTextChange {
message Content {
oneof value {
TextAppend textAppend = 1;
}
}
message TextAppend {
string text = 1;
}
message Snapshot {
string text = 1;
}
message Data {
repeated Content content = 1;
Snapshot snapshot = 2;
}
}

View file

@ -2,7 +2,7 @@ package tree
import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
)
type CommonTree interface {
@ -15,7 +15,7 @@ type CommonTree interface {
HasChange(string) bool
SnapshotPath() []string
ChangesAfterCommonSnapshot(snapshotPath []string) ([]*aclpb.RawChange, error)
Storage() treestorage.TreeStorage
Storage() storage.TreeStorage
DebugDump() (string, error)
Close() error
}

View file

@ -6,7 +6,7 @@ import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
@ -56,7 +56,7 @@ type DocTree interface {
}
type docTree struct {
treeStorage treestorage.TreeStorage
treeStorage storage.TreeStorage
accountData *account.AccountData
updateListener TreeUpdateListener
@ -76,7 +76,7 @@ type docTree struct {
sync.RWMutex
}
func BuildDocTreeWithIdentity(t treestorage.TreeStorage, acc *account.AccountData, listener TreeUpdateListener, aclList list.ACLList) (DocTree, error) {
func BuildDocTreeWithIdentity(t storage.TreeStorage, acc *account.AccountData, listener TreeUpdateListener, aclList list.ACLList) (DocTree, error) {
treeBuilder := newTreeBuilder(t, acc.Decoder)
validator := newTreeValidator()
@ -112,7 +112,7 @@ func BuildDocTreeWithIdentity(t treestorage.TreeStorage, acc *account.AccountDat
return docTree, nil
}
func BuildDocTree(t treestorage.TreeStorage, decoder keys.Decoder, listener TreeUpdateListener, aclList list.ACLList) (DocTree, error) {
func BuildDocTree(t storage.TreeStorage, decoder keys.Decoder, listener TreeUpdateListener, aclList list.ACLList) (DocTree, error) {
treeBuilder := newTreeBuilder(t, decoder)
validator := newTreeValidator()
@ -182,7 +182,7 @@ func (d *docTree) Header() *aclpb.Header {
return d.header
}
func (d *docTree) Storage() treestorage.TreeStorage {
func (d *docTree) Storage() storage.TreeStorage {
return d.treeStorage
}

View file

@ -5,7 +5,7 @@ import (
"errors"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice"
@ -23,10 +23,10 @@ type treeBuilder struct {
identityKeys map[string]signingkey.PubKey
signingPubKeyDecoder keys.Decoder
tree *Tree
treeStorage treestorage.TreeStorage
treeStorage storage.TreeStorage
}
func newTreeBuilder(t treestorage.TreeStorage, decoder keys.Decoder) *treeBuilder {
func newTreeBuilder(t storage.TreeStorage, decoder keys.Decoder) *treeBuilder {
return &treeBuilder{
signingPubKeyDecoder: decoder,
treeStorage: t,

View file

@ -4,7 +4,7 @@ import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid"
"github.com/gogo/protobuf/proto"
"time"
@ -14,7 +14,7 @@ import (
//func CreateNewTreeStorageWithACL(
// acc *account.AccountData,
// build func(builder list.ACLChangeBuilder) error,
// create treestorage.CreatorFunc) (treestorage.TreeStorage, error) {
// create treestorage.CreatorFunc) (treestorage.Storage, error) {
// bld := list.newACLChangeBuilder()
// bld.Init(
// list.newACLStateWithIdentity(acc.Identity, acc.EncKey, signingkey.NewEd25519PubKeyDecoder()),
@ -56,7 +56,7 @@ func CreateNewTreeStorage(
acc *account.AccountData,
aclList list.ACLList,
content proto.Marshaler,
create treestorage.CreatorFunc) (treestorage.TreeStorage, error) {
create storage.CreatorFunc) (storage.TreeStorage, error) {
state := aclList.ACLState()
change := &aclpb.Change{

View file

@ -54,7 +54,6 @@ func (s *service) Run(ctx context.Context) (err error) {
mux := http.NewServeMux()
mux.HandleFunc("/treeDump", s.treeDump)
mux.HandleFunc("/createDocumentTree", s.createDocumentTree)
mux.HandleFunc("/createACLTree", s.createACLTree)
mux.HandleFunc("/appendDocument", s.appendDocument)
s.srv.Handler = mux
@ -99,21 +98,10 @@ func (s *service) createDocumentTree(w http.ResponseWriter, req *http.Request) {
var (
query = req.URL.Query()
text = query.Get("text")
aclTreeId = query.Get("aclTreeId")
aclListId = query.Get("aclListId")
)
timeoutCtx, cancel := context.WithTimeout(context.Background(), time.Second*30)
treeId, err := s.documentService.CreateDocumentTree(timeoutCtx, aclTreeId, text)
cancel()
if err != nil {
sendText(w, http.StatusInternalServerError, err.Error())
return
}
sendText(w, http.StatusOK, treeId)
}
func (s *service) createACLTree(w http.ResponseWriter, req *http.Request) {
timeoutCtx, cancel := context.WithTimeout(context.Background(), time.Second*30)
treeId, err := s.documentService.CreateACLTree(timeoutCtx)
treeId, err := s.documentService.CreateDocumentTree(timeoutCtx, aclListId, text)
cancel()
if err != nil {
sendText(w, http.StatusInternalServerError, err.Error())

View file

@ -7,9 +7,8 @@ import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/testchanges/testchangepb"
testchanges "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/testchanges/proto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage/treepb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/node"
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/storage"
@ -35,7 +34,6 @@ type service struct {
type Service interface {
UpdateDocumentTree(ctx context.Context, id, text string) error
CreateACLTree(ctx context.Context) (id string, err error)
CreateDocumentTree(ctx context.Context, aclTreeId string, text string) (id string, err error)
}
@ -60,7 +58,7 @@ func (s *service) Name() (name string) {
}
func (s *service) Run(ctx context.Context) (err error) {
return nil
return s.importACLList(ctx)
}
func (s *service) Close(ctx context.Context) (err error) {
@ -70,7 +68,7 @@ func (s *service) Close(ctx context.Context) (err error) {
func (s *service) UpdateDocumentTree(ctx context.Context, id, text string) (err error) {
var (
ch *aclpb.RawChange
header *treepb.TreeHeader
header *aclpb.Header
snapshotPath []string
heads []string
)
@ -85,8 +83,8 @@ func (s *service) UpdateDocumentTree(ctx context.Context, id, text string) (err
docTree.Lock()
defer docTree.Unlock()
err = s.treeCache.Do(ctx, docTree.Header().AclTreeId, func(obj interface{}) error {
aclTree := obj.(tree.ACLTree)
err = s.treeCache.Do(ctx, docTree.Header().AclListId, func(obj interface{}) error {
aclTree := obj.(list.ACLList)
aclTree.RLock()
defer aclTree.RUnlock()
@ -123,69 +121,20 @@ func (s *service) UpdateDocumentTree(ctx context.Context, id, text string) (err
}, header, id))
}
func (s *service) CreateACLTree(ctx context.Context) (id string, err error) {
acc := s.account.Account()
var (
ch *aclpb.RawChange
header *treepb.TreeHeader
snapshotPath []string
heads []string
)
t, err := tree.CreateNewTreeStorageWithACL(acc, func(builder list.ACLChangeBuilder) error {
err := builder.UserAdd(acc.Identity, acc.EncKey.GetPublic(), aclpb.ACLChange_Admin)
if err != nil {
return err
}
// adding all predefined nodes to the document as admins
for _, n := range s.nodes {
err = builder.UserAdd(n.SigningKeyString, n.EncryptionKey, aclpb.ACLChange_Admin)
if err != nil {
return err
}
}
return nil
}, s.storage.CreateTreeStorage)
id, err = t.TreeID()
if err != nil {
return "", err
}
header, err = t.Header()
if err != nil {
return "", err
}
heads = []string{header.FirstChangeId}
snapshotPath = []string{header.FirstChangeId}
ch, err = t.GetChange(ctx, header.FirstChangeId)
if err != nil {
return "", err
}
if err != nil {
return "", err
}
err = s.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(&syncproto.SyncHeadUpdate{
Heads: heads,
Changes: []*aclpb.RawChange{ch},
SnapshotPath: snapshotPath,
}, header, id))
return id, nil
func (s *service) importACLList(ctx context.Context) (err error) {
panic("not implemented")
}
func (s *service) CreateDocumentTree(ctx context.Context, aclTreeId string, text string) (id string, err error) {
func (s *service) CreateDocumentTree(ctx context.Context, aclListId string, text string) (id string, err error) {
acc := s.account.Account()
var (
ch *aclpb.RawChange
header *treepb.TreeHeader
header *aclpb.Header
snapshotPath []string
heads []string
)
err = s.treeCache.Do(ctx, aclTreeId, func(obj interface{}) error {
t := obj.(tree.ACLTree)
err = s.treeCache.Do(ctx, aclListId, func(obj interface{}) error {
t := obj.(list.ACLList)
t.RLock()
defer t.RUnlock()
@ -205,9 +154,9 @@ func (s *service) CreateDocumentTree(ctx context.Context, aclTreeId string, text
return err
}
heads = []string{header.FirstChangeId}
snapshotPath = []string{header.FirstChangeId}
ch, err = doc.GetRawChange(ctx, header.FirstChangeId)
heads = []string{header.FirstId}
snapshotPath = []string{header.FirstId}
ch, err = doc.GetRawChange(ctx, header.FirstId)
if err != nil {
return err
}
@ -233,26 +182,26 @@ func (s *service) CreateDocumentTree(ctx context.Context, aclTreeId string, text
}
func createInitialTextChange(text string) proto.Marshaler {
return &testchangepb.PlainTextChangeData{
Content: []*testchangepb.PlainTextChangeContent{
return &testchanges.PlainTextChangeData{
Content: []*testchanges.PlainTextChangeContent{
createAppendTextChangeContent(text),
},
Snapshot: &testchangepb.PlainTextChangeSnapshot{Text: text},
Snapshot: &testchanges.PlainTextChangeSnapshot{Text: text},
}
}
func createAppendTextChange(text string) proto.Marshaler {
return &testchangepb.PlainTextChangeData{
Content: []*testchangepb.PlainTextChangeContent{
return &testchanges.PlainTextChangeData{
Content: []*testchanges.PlainTextChangeContent{
createAppendTextChangeContent(text),
},
}
}
func createAppendTextChangeContent(text string) *testchangepb.PlainTextChangeContent {
return &testchangepb.PlainTextChangeContent{
Value: &testchangepb.PlainTextChangeContentValueOfTextAppend{
TextAppend: &testchangepb.PlainTextChangeTextAppend{
func createAppendTextChangeContent(text string) *testchanges.PlainTextChangeContent {
return &testchanges.PlainTextChangeContent{
Value: &testchanges.PlainTextChangeContentValueOfTextAppend{
TextAppend: &testchanges.PlainTextChangeTextAppend{
Text: text,
},
},

View file

@ -4,14 +4,13 @@ import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage/treepb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
)
var CName = "storage"
type Service interface {
treestorage.Provider
storage.Provider
}
func New() app.Component {
@ -19,19 +18,19 @@ func New() app.Component {
}
type service struct {
storageProvider treestorage.Provider
storageProvider storage.Provider
}
func (s *service) Init(ctx context.Context, a *app.App) (err error) {
s.storageProvider = treestorage.NewInMemoryTreeStorageProvider()
s.storageProvider = storage.NewInMemoryTreeStorageProvider()
return nil
}
func (s *service) TreeStorage(treeId string) (treestorage.TreeStorage, error) {
return s.storageProvider.TreeStorage(treeId)
func (s *service) Storage(treeId string) (storage.Storage, error) {
return s.storageProvider.Storage(treeId)
}
func (s *service) CreateTreeStorage(treeId string, header *treepb.TreeHeader, changes []*aclpb.RawChange) (treestorage.TreeStorage, error) {
func (s *service) CreateTreeStorage(treeId string, header *aclpb.Header, changes []*aclpb.RawChange) (storage.TreeStorage, error) {
return s.storageProvider.CreateTreeStorage(treeId, header, changes)
}

View file

@ -119,6 +119,6 @@ func msgInfo(content *syncproto.Sync) (syncMethod string) {
case msg.GetHeadUpdate() != nil:
syncMethod = "HeadUpdate"
}
syncMethod = fmt.Sprintf("method: %s, treeType: %s", syncMethod, content.TreeHeader.Type.String())
syncMethod = fmt.Sprintf("method: %s, treeType: %s", syncMethod, content.TreeHeader.DocType.String())
return
}

View file

@ -6,9 +6,9 @@ import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage/treepb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/account"
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/treecache"
"github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto"
@ -77,7 +77,7 @@ func (r *requestHandler) HandleHeadUpdate(
ctx context.Context,
senderId string,
update *syncproto.SyncHeadUpdate,
header *treepb.TreeHeader,
header *aclpb.Header,
treeId string) (err error) {
var (
@ -88,81 +88,41 @@ func (r *requestHandler) HandleHeadUpdate(
log.With(zap.String("peerId", senderId), zap.String("treeId", treeId)).
Debug("processing head update")
updateACLTree := func() {
err = r.treeCache.Do(ctx, treeId, func(obj interface{}) error {
t := obj.(tree.ACLTree)
t.Lock()
defer t.Unlock()
err = r.treeCache.Do(ctx, treeId, func(obj interface{}) error {
docTree := obj.(tree.DocTree)
docTree.Lock()
defer docTree.Unlock()
if slice.UnsortedEquals(update.Heads, t.Heads()) {
return nil
}
if slice.UnsortedEquals(update.Heads, docTree.Heads()) {
return nil
}
return r.treeCache.Do(ctx, docTree.Header().AclListId, func(obj interface{}) error {
aclTree := obj.(list.ACLList)
aclTree.RLock()
defer aclTree.RUnlock()
// TODO: check if we already have those changes
result, err = t.AddRawChanges(ctx, update.Changes...)
result, err = docTree.AddRawChanges(ctx, aclTree, update.Changes...)
if err != nil {
return err
}
log.With(zap.Strings("update heads", update.Heads), zap.Strings("tree heads", t.Heads())).
log.With(zap.Strings("update heads", update.Heads), zap.Strings("tree heads", docTree.Heads())).
Debug("comparing heads after head update")
shouldFullSync := !slice.UnsortedEquals(update.Heads, t.Heads())
snapshotPath = t.SnapshotPath()
shouldFullSync := !slice.UnsortedEquals(update.Heads, docTree.Heads())
snapshotPath = docTree.SnapshotPath()
if shouldFullSync {
fullRequest, err = r.prepareFullSyncRequest(treeId, header, update.SnapshotPath, t)
fullRequest, err = r.prepareFullSyncRequest(update.SnapshotPath, docTree)
if err != nil {
return err
}
}
return nil
})
}
updateDocTree := func() {
err = r.treeCache.Do(ctx, treeId, func(obj interface{}) error {
docTree := obj.(tree.DocTree)
docTree.Lock()
defer docTree.Unlock()
if slice.UnsortedEquals(update.Heads, docTree.Heads()) {
return nil
}
return r.treeCache.Do(ctx, docTree.Header().AclTreeId, func(obj interface{}) error {
aclTree := obj.(tree.ACLTree)
aclTree.RLock()
defer aclTree.RUnlock()
// TODO: check if we already have those changes
result, err = docTree.AddRawChanges(ctx, aclTree, update.Changes...)
if err != nil {
return err
}
log.With(zap.Strings("update heads", update.Heads), zap.Strings("tree heads", docTree.Heads())).
Debug("comparing heads after head update")
shouldFullSync := !slice.UnsortedEquals(update.Heads, docTree.Heads())
snapshotPath = docTree.SnapshotPath()
if shouldFullSync {
fullRequest, err = r.prepareFullSyncRequest(treeId, header, update.SnapshotPath, docTree)
if err != nil {
return err
}
}
return nil
})
})
}
switch header.Type {
case treepb.TreeHeader_ACLTree:
updateACLTree()
case treepb.TreeHeader_DocTree:
updateDocTree()
default:
return ErrIncorrectDocType
}
})
// if there are no such tree
if err == treestorage.ErrUnknownTreeId {
if err == storage.ErrUnknownTreeId {
// TODO: maybe we can optimize this by sending the header and stuff right away, so when the tree is created we are able to add it on first request
fullRequest = &syncproto.SyncFullRequest{}
}
@ -188,7 +148,7 @@ func (r *requestHandler) HandleFullSyncRequest(
ctx context.Context,
senderId string,
request *syncproto.SyncFullRequest,
header *treepb.TreeHeader,
header *aclpb.Header,
treeId string) (err error) {
var (
@ -199,74 +159,36 @@ func (r *requestHandler) HandleFullSyncRequest(
log.With(zap.String("peerId", senderId), zap.String("treeId", treeId)).
Debug("processing full sync request")
requestACLTree := func() {
err = r.treeCache.Do(ctx, treeId, func(obj interface{}) error {
t := obj.(tree.ACLTree)
t.Lock()
defer t.Unlock()
//if slice.UnsortedEquals(request.Heads, t.Heads()) {
// return nil
//}
log.Info("getting doc tree from treeCache", zap.String("treeId", treeId))
err = r.treeCache.Do(ctx, treeId, func(obj interface{}) error {
docTree := obj.(tree.DocTree)
docTree.Lock()
defer docTree.Unlock()
//if slice.UnsortedEquals(request.Heads, docTree.Heads()) {
// return nil
//}
log.Info("getting tree from treeCache", zap.String("aclId", docTree.Header().AclListId))
return r.treeCache.Do(ctx, docTree.Header().AclListId, func(obj interface{}) error {
aclTree := obj.(list.ACLList)
aclTree.RLock()
defer aclTree.RUnlock()
// TODO: check if we already have those changes
// if we have non-empty request
if len(request.Heads) != 0 {
result, err = t.AddRawChanges(ctx, request.Changes...)
result, err = docTree.AddRawChanges(ctx, aclTree, request.Changes...)
if err != nil {
return err
}
}
snapshotPath = t.SnapshotPath()
fullResponse, err = r.prepareFullSyncResponse(treeId, request.SnapshotPath, request.Changes, t)
snapshotPath = docTree.SnapshotPath()
fullResponse, err = r.prepareFullSyncResponse(treeId, request.SnapshotPath, request.Changes, docTree)
if err != nil {
return err
}
return nil
})
}
requestDocTree := func() {
log.Info("getting doc tree from treeCache", zap.String("treeId", treeId))
err = r.treeCache.Do(ctx, treeId, func(obj interface{}) error {
docTree := obj.(tree.DocTree)
docTree.Lock()
defer docTree.Unlock()
//if slice.UnsortedEquals(request.Heads, docTree.Heads()) {
// return nil
//}
log.Info("getting tree from treeCache", zap.String("aclId", docTree.Header().AclTreeId))
return r.treeCache.Do(ctx, docTree.Header().AclTreeId, func(obj interface{}) error {
aclTree := obj.(tree.ACLTree)
aclTree.RLock()
defer aclTree.RUnlock()
// TODO: check if we already have those changes
// if we have non-empty request
if len(request.Heads) != 0 {
result, err = docTree.AddRawChanges(ctx, aclTree, request.Changes...)
if err != nil {
return err
}
}
snapshotPath = docTree.SnapshotPath()
fullResponse, err = r.prepareFullSyncResponse(treeId, request.SnapshotPath, request.Changes, docTree)
if err != nil {
return err
}
return nil
})
})
}
switch header.Type {
case treepb.TreeHeader_ACLTree:
requestACLTree()
case treepb.TreeHeader_DocTree:
requestDocTree()
default:
return ErrIncorrectDocType
}
})
if err != nil {
return err
@ -290,7 +212,7 @@ func (r *requestHandler) HandleFullSyncResponse(
ctx context.Context,
senderId string,
response *syncproto.SyncFullResponse,
header *treepb.TreeHeader,
header *aclpb.Header,
treeId string) (err error) {
var (
@ -300,66 +222,35 @@ func (r *requestHandler) HandleFullSyncResponse(
log.With(zap.String("peerId", senderId), zap.String("treeId", treeId)).
Debug("processing full sync response")
responseACLTree := func() {
err = r.treeCache.Do(ctx, treeId, func(obj interface{}) error {
t := obj.(tree.ACLTree)
t.Lock()
defer t.Unlock()
err = r.treeCache.Do(ctx, treeId, func(obj interface{}) error {
docTree := obj.(tree.DocTree)
docTree.Lock()
defer docTree.Unlock()
if slice.UnsortedEquals(response.Heads, t.Heads()) {
return nil
}
if slice.UnsortedEquals(response.Heads, docTree.Heads()) {
return nil
}
return r.treeCache.Do(ctx, docTree.Header().AclListId, func(obj interface{}) error {
aclTree := obj.(list.ACLList)
aclTree.RLock()
defer aclTree.RUnlock()
// TODO: check if we already have those changes
result, err = t.AddRawChanges(ctx, response.Changes...)
result, err = docTree.AddRawChanges(ctx, aclTree, response.Changes...)
if err != nil {
return err
}
snapshotPath = t.SnapshotPath()
snapshotPath = docTree.SnapshotPath()
return nil
})
}
responseDocTree := func() {
err = r.treeCache.Do(ctx, treeId, func(obj interface{}) error {
docTree := obj.(tree.DocTree)
docTree.Lock()
defer docTree.Unlock()
if slice.UnsortedEquals(response.Heads, docTree.Heads()) {
return nil
}
return r.treeCache.Do(ctx, docTree.Header().AclTreeId, func(obj interface{}) error {
aclTree := obj.(tree.ACLTree)
aclTree.RLock()
defer aclTree.RUnlock()
// TODO: check if we already have those changes
result, err = docTree.AddRawChanges(ctx, aclTree, response.Changes...)
if err != nil {
return err
}
snapshotPath = docTree.SnapshotPath()
return nil
})
})
}
switch header.Type {
case treepb.TreeHeader_ACLTree:
responseACLTree()
case treepb.TreeHeader_DocTree:
responseDocTree()
default:
return ErrIncorrectDocType
}
})
// if error or nothing has changed
if (err != nil || len(result.Added) == 0) && err != treestorage.ErrUnknownTreeId {
if (err != nil || len(result.Added) == 0) && err != storage.ErrUnknownTreeId {
return err
}
// if we have a new tree
if err == treestorage.ErrUnknownTreeId {
if err == storage.ErrUnknownTreeId {
err = r.createTree(ctx, response, header, treeId)
if err != nil {
return err
@ -379,7 +270,7 @@ func (r *requestHandler) HandleFullSyncResponse(
return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate, header, treeId))
}
func (r *requestHandler) prepareFullSyncRequest(treeId string, header *treepb.TreeHeader, theirPath []string, t tree.CommonTree) (*syncproto.SyncFullRequest, error) {
func (r *requestHandler) prepareFullSyncRequest(theirPath []string, t tree.CommonTree) (*syncproto.SyncFullRequest, error) {
ourChanges, err := t.ChangesAfterCommonSnapshot(theirPath)
if err != nil {
return nil, err
@ -426,7 +317,7 @@ func (r *requestHandler) prepareFullSyncResponse(
func (r *requestHandler) createTree(
ctx context.Context,
response *syncproto.SyncFullResponse,
header *treepb.TreeHeader,
header *aclpb.Header,
treeId string) error {
return r.treeCache.Add(

View file

@ -7,6 +7,7 @@ import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list"
aclstorage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree"
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache"
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/account"
@ -17,13 +18,13 @@ import (
const CName = "treecache"
// TODO: add context
type TreeFunc = func(tree interface{}) error
type ObjFunc = func(obj interface{}) error
var log = logger.NewNamed("treecache")
type Service interface {
Do(ctx context.Context, treeId string, f TreeFunc) error
Add(ctx context.Context, treeId string, header *aclpb.Header, changes []*aclpb.RawChange, f TreeFunc) error
Do(ctx context.Context, treeId string, f ObjFunc) error
Add(ctx context.Context, treeId string, header *aclpb.Header, changes []*aclpb.RawChange, f ObjFunc) error
}
type service struct {
@ -36,7 +37,7 @@ func New() app.ComponentRunnable {
return &service{}
}
func (s *service) Do(ctx context.Context, treeId string, f TreeFunc) error {
func (s *service) Do(ctx context.Context, treeId string, f ObjFunc) error {
log.
With(zap.String("treeId", treeId)).
Debug("requesting tree from cache to perform operation")
@ -49,7 +50,7 @@ func (s *service) Do(ctx context.Context, treeId string, f TreeFunc) error {
return f(t)
}
func (s *service) Add(ctx context.Context, treeId string, header *treepb.TreeHeader, changes []*aclpb.RawChange, f TreeFunc) error {
func (s *service) Add(ctx context.Context, treeId string, header *aclpb.Header, changes []*aclpb.RawChange, f ObjFunc) error {
log.
With(zap.String("treeId", treeId), zap.Int("len(changes)", len(changes))).
Debug("adding tree with changes")
@ -82,7 +83,7 @@ func (s *service) Close(ctx context.Context) (err error) {
}
func (s *service) loadTree(ctx context.Context, id string) (ocache.Object, error) {
t, err := s.storage.TreeStorage(id)
t, err := s.storage.Storage(id)
if err != nil {
return nil, err
}
@ -93,7 +94,7 @@ func (s *service) loadTree(ctx context.Context, id string) (ocache.Object, error
switch header.DocType {
case aclpb.Header_ACL:
return list.BuildACLListWithIdentity(acc)
return list.BuildACLListWithIdentity(s.account.Account(), t.(aclstorage.ListStorage))
case aclpb.Header_DocTree:
break
default:
@ -101,13 +102,13 @@ func (s *service) loadTree(ctx context.Context, id string) (ocache.Object, error
}
log.Info("got header", zap.String("header", header.String()))
var docTree tree.DocTree
// TODO: it is a question if we need to use ACLTree on the first tree build, because we can think that the tree is already validated
err = s.Do(ctx, header.AclTreeId, func(obj interface{}) error {
aclTree := obj.(tree.ACLTree)
// TODO: it is a question if we need to use ACLList on the first tree build, because we can think that the tree is already validated
err = s.Do(ctx, header.AclListId, func(obj interface{}) error {
aclTree := obj.(list.ACLList)
aclTree.RLock()
defer aclTree.RUnlock()
docTree, err = tree.BuildDocTreeWithIdentity(t, s.account.Account(), nil, aclTree)
docTree, err = tree.BuildDocTreeWithIdentity(t.(aclstorage.TreeStorage), s.account.Account(), nil, aclTree)
if err != nil {
return err
}

View file

@ -1,6 +1,6 @@
package syncproto
import "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage/treepb"
import "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage/treepb"
func WrapHeadUpdate(update *SyncHeadUpdate, header *treepb.TreeHeader, treeId string) *Sync {
return &Sync{

View file

@ -3,7 +3,6 @@ package anytype;
option go_package = "/syncproto";
import "pkg/acl/aclchanges/aclpb/protos/aclchanges.proto";
import "pkg/acl/treestorage/treepb/protos/tree.proto";
message Message {
Header header = 1;
@ -53,7 +52,7 @@ message System {
message Sync {
string spaceId = 1;
ContentValue message = 2;
tree.TreeHeader treeHeader = 3;
acl.Header treeHeader = 3;
string treeId = 4;
message ContentValue {

View file

@ -6,7 +6,6 @@ package syncproto
import (
fmt "fmt"
aclpb "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
treepb "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage/treepb"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
@ -590,10 +589,10 @@ func (m *SubscriptionUnsubscribeSpace) GetSpaceId() string {
}
type Sync struct {
SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"`
Message *SyncContentValue `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
TreeHeader *treepb.TreeHeader `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"`
TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"`
SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"`
Message *SyncContentValue `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
TreeHeader *aclpb.Header `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"`
TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"`
}
func (m *Sync) Reset() { *m = Sync{} }
@ -643,7 +642,7 @@ func (m *Sync) GetMessage() *SyncContentValue {
return nil
}
func (m *Sync) GetTreeHeader() *treepb.TreeHeader {
func (m *Sync) GetTreeHeader() *aclpb.Header {
if m != nil {
return m.TreeHeader
}
@ -996,61 +995,60 @@ func init() {
func init() { proto.RegisterFile("syncproto/proto/sync.proto", fileDescriptor_4b28dfdd48a89166) }
var fileDescriptor_4b28dfdd48a89166 = []byte{
// 858 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0xd1, 0x8e, 0xda, 0x46,
0x14, 0xc5, 0x60, 0x20, 0x5c, 0x10, 0xeb, 0x4e, 0x92, 0xd6, 0x75, 0x22, 0x84, 0x50, 0xda, 0x5a,
0x69, 0xe4, 0x8d,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x03, 0x00, 0x00, 0xff, 0xff,
0x34, 0xaa, 0x76, 0x9b, 0x6f, 0x07, 0x00, 0x00,
}
func (m *Message) Marshal() (dAtA []byte, err error) {
@ -3328,7 +3326,7 @@ func (m *Sync) Unmarshal(dAtA []byte) error {
return io.ErrUnexpectedEOF
}
if m.TreeHeader == nil {
m.TreeHeader = &treepb.TreeHeader{}
m.TreeHeader = &aclpb.Header{}
}
if err := m.TreeHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err