Change space payload

This commit is contained in:
mcrakhman 2022-10-24 11:59:37 +02:00 committed by Mikhail Iudin
parent 453967fad8
commit 9642c11eea
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0
7 changed files with 144 additions and 91 deletions

View File

@ -5,6 +5,7 @@ import (
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/treegetter"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
)
type rpcHandler struct {
@ -23,7 +24,10 @@ func (r *rpcHandler) PushSpace(ctx context.Context, req *spacesyncproto.PushSpac
}
payload := storage.SpaceStorageCreatePayload{
RecWithId: req.AclRoot,
RecWithId: &aclrecordproto.RawACLRecordWithId{
Payload: req.AclPayload,
Id: req.AclPayloadId,
},
SpaceHeaderWithId: req.SpaceHeader,
}
st, err := r.s.spaceStorageProvider.CreateSpaceStorage(payload)

View File

@ -109,7 +109,8 @@ func (d *diffSyncer) sendPushSpaceRequest(ctx context.Context, cl spacesyncproto
_, err = cl.PushSpace(ctx, &spacesyncproto.PushSpaceRequest{
SpaceHeader: header,
AclRoot: root,
AclPayload: root.Payload,
AclPayloadId: root.Id,
})
return
}

View File

@ -23,7 +23,7 @@ import (
type pushSpaceRequestMatcher struct {
spaceId string
aclRoot *aclrecordproto.RawACLRecordWithId
aclRootId string
spaceHeader *spacesyncproto.RawSpaceHeaderWithId
}
@ -33,7 +33,7 @@ func (p pushSpaceRequestMatcher) Matches(x interface{}) bool {
return false
}
return res.AclRoot == p.aclRoot && res.SpaceHeader == p.spaceHeader
return res.AclPayloadId == p.aclRootId && res.SpaceHeader == p.spaceHeader
}
func (p pushSpaceRequestMatcher) String() string {
@ -71,11 +71,11 @@ func (m mockPeer) NewStream(ctx context.Context, rpc string, enc drpc.Encoding)
func newPushSpaceRequestMatcher(
spaceId string,
aclRoot *aclrecordproto.RawACLRecordWithId,
aclRootId string,
spaceHeader *spacesyncproto.RawSpaceHeaderWithId) *pushSpaceRequestMatcher {
return &pushSpaceRequestMatcher{
spaceId: spaceId,
aclRoot: aclRoot,
aclRootId: aclRootId,
spaceHeader: spaceHeader,
}
}
@ -95,6 +95,7 @@ func TestDiffSyncer_Sync(t *testing.T) {
return clientMock
})
spaceId := "spaceId"
aclRootId := "aclRootId"
l := logger.NewNamed(spaceId)
diffSyncer := newDiffSyncer(spaceId, diffMock, connectorMock, cacheMock, stMock, factory, l)
@ -123,7 +124,9 @@ func TestDiffSyncer_Sync(t *testing.T) {
t.Run("diff syncer sync space missing", func(t *testing.T) {
aclStorageMock := mock_aclstorage.NewMockListStorage(ctrl)
aclRoot := &aclrecordproto.RawACLRecordWithId{}
aclRoot := &aclrecordproto.RawACLRecordWithId{
Id: aclRootId,
}
spaceHeader := &spacesyncproto.RawSpaceHeaderWithId{}
connectorMock.EXPECT().
@ -142,7 +145,7 @@ func TestDiffSyncer_Sync(t *testing.T) {
Root().
Return(aclRoot, nil)
clientMock.EXPECT().
PushSpace(gomock.Any(), newPushSpaceRequestMatcher(spaceId, aclRoot, spaceHeader)).
PushSpace(gomock.Any(), newPushSpaceRequestMatcher(spaceId, aclRootId, spaceHeader)).
Return(nil, nil)
require.NoError(t, diffSyncer.Sync(ctx))

View File

@ -34,7 +34,7 @@ type service struct {
account account.Service
configurationService nodeconf.Service
storageProvider storage.SpaceStorageProvider
cache treegetter.TreeGetter
treeGetter treegetter.TreeGetter
pool pool.Pool
}
@ -43,7 +43,7 @@ func (s *service) Init(a *app.App) (err error) {
s.account = a.MustComponent(account.CName).(account.Service)
s.storageProvider = a.MustComponent(storage.CName).(storage.SpaceStorageProvider)
s.configurationService = a.MustComponent(nodeconf.CName).(nodeconf.Service)
s.cache = a.MustComponent(treegetter.CName).(treegetter.TreeGetter)
s.treeGetter = a.MustComponent(treegetter.CName).(treegetter.TreeGetter)
s.pool = a.MustComponent(pool.CName).(pool.Pool)
return nil
}
@ -90,13 +90,13 @@ func (s *service) GetSpace(ctx context.Context, id string) (Space, error) {
lastConfiguration := s.configurationService.GetLast()
confConnector := nodeconf.NewConfConnector(lastConfiguration, s.pool)
diffService := diffservice.NewDiffService(id, s.config.SyncPeriod, st, confConnector, s.cache, log)
diffService := diffservice.NewDiffService(id, s.config.SyncPeriod, st, confConnector, s.treeGetter, log)
syncService := syncservice.NewSyncService(id, confConnector)
sp := &space{
id: id,
syncService: syncService,
diffService: diffService,
cache: s.cache,
cache: s.treeGetter,
account: s.account,
configuration: lastConfiguration,
storage: st,

View File

@ -2,7 +2,6 @@ syntax = "proto3";
package anySpace;
option go_package = "commonspace/spacesyncproto";
import "pkg/acl/aclrecordproto/protos/aclrecord.proto";
enum ErrCodes {
Unexpected = 0;
@ -63,8 +62,9 @@ message ObjectSyncMessage {
// PushSpaceRequest is a request to add space on a node containing only one acl record
message PushSpaceRequest {
RawSpaceHeaderWithId spaceHeader = 2;
aclrecord.RawACLRecordWithId aclRoot = 3;
RawSpaceHeaderWithId spaceHeader = 1;
bytes aclPayload = 2;
string aclPayloadId = 3;
}
// PushSpaceResponse is an empty response

View File

@ -5,7 +5,6 @@ package spacesyncproto
import (
fmt "fmt"
aclrecordproto "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
@ -398,8 +397,9 @@ func (m *ObjectSyncMessage) GetObjectId() string {
// PushSpaceRequest is a request to add space on a node containing only one acl record
type PushSpaceRequest struct {
SpaceHeader *RawSpaceHeaderWithId `protobuf:"bytes,2,opt,name=spaceHeader,proto3" json:"spaceHeader,omitempty"`
AclRoot *aclrecordproto.RawACLRecordWithId `protobuf:"bytes,3,opt,name=aclRoot,proto3" json:"aclRoot,omitempty"`
SpaceHeader *RawSpaceHeaderWithId `protobuf:"bytes,1,opt,name=spaceHeader,proto3" json:"spaceHeader,omitempty"`
AclPayload []byte `protobuf:"bytes,2,opt,name=aclPayload,proto3" json:"aclPayload,omitempty"`
AclPayloadId string `protobuf:"bytes,3,opt,name=aclPayloadId,proto3" json:"aclPayloadId,omitempty"`
}
func (m *PushSpaceRequest) Reset() { *m = PushSpaceRequest{} }
@ -442,13 +442,20 @@ func (m *PushSpaceRequest) GetSpaceHeader() *RawSpaceHeaderWithId {
return nil
}
func (m *PushSpaceRequest) GetAclRoot() *aclrecordproto.RawACLRecordWithId {
func (m *PushSpaceRequest) GetAclPayload() []byte {
if m != nil {
return m.AclRoot
return m.AclPayload
}
return nil
}
func (m *PushSpaceRequest) GetAclPayloadId() string {
if m != nil {
return m.AclPayloadId
}
return ""
}
// PushSpaceResponse is an empty response
type PushSpaceResponse struct {
}
@ -687,52 +694,50 @@ func init() {
}
var fileDescriptor_80e49f1f4ac27799 = []byte{
// 717 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0x4f, 0x6f, 0xda, 0x48,
0x14, 0xc7, 0x84, 0x24, 0xf0, 0x20, 0x84, 0xcc, 0x66, 0xb5, 0x5e, 0x76, 0x97, 0x45, 0x3e, 0xac,
0xd0, 0x4a, 0x0b, 0x5b, 0x5a, 0xa9, 0x87, 0x5c, 0x9a, 0x26, 0x44, 0x45, 0x6d, 0x9a, 0x68, 0x68,
0x55, 0xa9, 0xea, 0x65, 0x62, 0x4f, 0xc0, 0x2d, 0xf6, 0xb8, 0x33, 0x83, 0x88, 0x0f, 0xfd, 0x08,
0x95, 0xfa, 0x15, 0xfa, 0x6d, 0x7a, 0xcc, 0x31, 0xc7, 0x2a, 0xf9, 0x22, 0xd5, 0x3c, 0x63, 0x0c,
0x29, 0xc9, 0x01, 0x33, 0xef, 0xcf, 0xef, 0xbd, 0xdf, 0xfc, 0xfc, 0x9e, 0xe1, 0x81, 0x2b, 0x82,
0x40, 0x84, 0x2a, 0x62, 0x2e, 0xef, 0xe0, 0x53, 0xc5, 0x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x9c,
0x05, 0x64, 0x21, 0xed, 0xa7, 0xa5, 0xaa, 0xdf, 0x17, 0x6c, 0x59, 0xff, 0x5b, 0x4f, 0x1f, 0x7d,
0xbb, 0x6e, 0x58, 0x97, 0xd7, 0x0d, 0xeb, 0xfb, 0x75, 0xc3, 0xfa, 0x72, 0xd3, 0xc8, 0x5d, 0xde,
0x34, 0x72, 0x57, 0x37, 0x8d, 0xdc, 0xdb, 0xfa, 0xdd, 0xdf, 0xed, 0xb3, 0x0d, 0xfc, 0x7b, 0xf8,
0x23, 0x00, 0x00, 0xff, 0xff, 0x84, 0x55, 0x32, 0xc7, 0xdc, 0x05, 0x00, 0x00,
// 685 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0xcd, 0x4e, 0xdb, 0x4a,
0x14, 0x8e, 0x4d, 0x80, 0xe4, 0x24, 0x84, 0x30, 0x97, 0xab, 0xeb, 0x9b, 0x56, 0x6e, 0xe4, 0x45,
0x15, 0x75, 0x01, 0x6d, 0xda, 0x1d, 0x9b, 0xfe, 0x10, 0xd4, 0xa8, 0xa2, 0xa0, 0x49, 0xab, 0x4a,
0x55, 0x37, 0x83, 0x3d, 0x24, 0x53, 0xc5, 0x1e, 0xd7, 0x33, 0x11, 0x78, 0xd1, 0x77, 0xe8, 0xb2,
0xdb, 0xbe, 0x4d, 0x97, 0x2c, 0x59, 0x56, 0xf0, 0x22, 0xd5, 0x9c, 0xd8, 0x71, 0x02, 0x81, 0xcd,
0x64, 0xce, 0x77, 0xfe, 0xbe, 0xf9, 0x72, 0x8e, 0xe1, 0x99, 0x2f, 0xc3, 0x50, 0x46, 0x2a, 0x66,
0x3e, 0xdf, 0xc5, 0x53, 0xa5, 0x91, 0x1f, 0x27, 0x52, 0xcb, 0x5d, 0x3c, 0x55, 0x81, 0xee, 0x20,
0x40, 0x2a, 0x2c, 0x4a, 0x07, 0x06, 0xf3, 0xfa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, 0xff,
0x0d, 0x00, 0x00, 0xff, 0xff, 0xc9, 0x45, 0x08, 0x76, 0xb8, 0x05, 0x00, 0x00,
}
func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) {
@ -1011,18 +1016,20 @@ func (m *PushSpaceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.AclRoot != nil {
{
size, err := m.AclRoot.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintSpacesync(dAtA, i, uint64(size))
}
if len(m.AclPayloadId) > 0 {
i -= len(m.AclPayloadId)
copy(dAtA[i:], m.AclPayloadId)
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.AclPayloadId)))
i--
dAtA[i] = 0x1a
}
if len(m.AclPayload) > 0 {
i -= len(m.AclPayload)
copy(dAtA[i:], m.AclPayload)
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.AclPayload)))
i--
dAtA[i] = 0x12
}
if m.SpaceHeader != nil {
{
size, err := m.SpaceHeader.MarshalToSizedBuffer(dAtA[:i])
@ -1033,7 +1040,7 @@ func (m *PushSpaceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i = encodeVarintSpacesync(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
@ -1326,8 +1333,12 @@ func (m *PushSpaceRequest) Size() (n int) {
l = m.SpaceHeader.Size()
n += 1 + l + sovSpacesync(uint64(l))
}
if m.AclRoot != nil {
l = m.AclRoot.Size()
l = len(m.AclPayload)
if l > 0 {
n += 1 + l + sovSpacesync(uint64(l))
}
l = len(m.AclPayloadId)
if l > 0 {
n += 1 + l + sovSpacesync(uint64(l))
}
return n
@ -2176,7 +2187,7 @@ func (m *PushSpaceRequest) Unmarshal(dAtA []byte) error {
return fmt.Errorf("proto: PushSpaceRequest: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 2:
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field SpaceHeader", wireType)
}
@ -2212,11 +2223,11 @@ func (m *PushSpaceRequest) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 3:
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AclRoot", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field AclPayload", wireType)
}
var msglen int
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSpacesync
@ -2226,27 +2237,57 @@ func (m *PushSpaceRequest) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
byteLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
if byteLen < 0 {
return ErrInvalidLengthSpacesync
}
postIndex := iNdEx + msglen
postIndex := iNdEx + byteLen
if postIndex < 0 {
return ErrInvalidLengthSpacesync
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.AclRoot == nil {
m.AclRoot = &aclrecordproto.RawACLRecordWithId{}
m.AclPayload = append(m.AclPayload[:0], dAtA[iNdEx:postIndex]...)
if m.AclPayload == nil {
m.AclPayload = []byte{}
}
if err := m.AclRoot.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AclPayloadId", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSpacesync
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthSpacesync
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthSpacesync
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.AclPayloadId = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex

View File

@ -4,6 +4,7 @@ import (
"context"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage"
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
)
type rpcHandler struct {
@ -22,7 +23,10 @@ func (r *rpcHandler) PushSpace(ctx context.Context, req *spacesyncproto.PushSpac
}
payload := storage.SpaceStorageCreatePayload{
RecWithId: req.AclRoot,
RecWithId: &aclrecordproto.RawACLRecordWithId{
Payload: req.AclPayload,
Id: req.AclPayloadId,
},
SpaceHeaderWithId: req.SpaceHeader,
}
st, err := r.s.spaceStorageProvider.CreateSpaceStorage(payload)