Generate drpc and some fixes
This commit is contained in:
parent
7a62b348cd
commit
5599277bf2
4
Makefile
4
Makefile
@ -26,11 +26,11 @@ proto:
|
||||
@$(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))
|
||||
|
||||
# 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_ACL_CHANGES_PATH_PB)/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):. $(P_SYNC_CHANGES_PATH_PB)/proto/*.proto
|
||||
$(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. common/commonspace/spacesyncproto/protos/*.proto
|
||||
$(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. common/commonspace/spacesyncproto/protos/*.proto
|
||||
|
||||
build:
|
||||
@$(eval FLAGS := $$(shell govvv -flags -pkg github.com/anytypeio/go-anytype-infrastructure-experiments/app))
|
||||
|
||||
@ -14,11 +14,6 @@ service Space {
|
||||
rpc Stream(stream ObjectSyncMessage) returns (stream ObjectSyncMessage);
|
||||
}
|
||||
|
||||
// TODO: temporary mock message
|
||||
message Msg {
|
||||
string spaceId = 1;
|
||||
}
|
||||
|
||||
// HeadSyncRange presenting a request for one range
|
||||
message HeadSyncRange {
|
||||
uint64 from = 1;
|
||||
|
||||
@ -45,51 +45,6 @@ func (ErrCodes) EnumDescriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{0}
|
||||
}
|
||||
|
||||
// TODO: temporary mock message
|
||||
type Msg struct {
|
||||
SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Msg) Reset() { *m = Msg{} }
|
||||
func (m *Msg) String() string { return proto.CompactTextString(m) }
|
||||
func (*Msg) ProtoMessage() {}
|
||||
func (*Msg) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{0}
|
||||
}
|
||||
func (m *Msg) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Msg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Msg.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *Msg) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Msg.Merge(m, src)
|
||||
}
|
||||
func (m *Msg) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Msg) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Msg.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Msg proto.InternalMessageInfo
|
||||
|
||||
func (m *Msg) GetSpaceId() string {
|
||||
if m != nil {
|
||||
return m.SpaceId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// HeadSyncRange presenting a request for one range
|
||||
type HeadSyncRange struct {
|
||||
From uint64 `protobuf:"varint,1,opt,name=from,proto3" json:"from,omitempty"`
|
||||
@ -101,7 +56,7 @@ func (m *HeadSyncRange) Reset() { *m = HeadSyncRange{} }
|
||||
func (m *HeadSyncRange) String() string { return proto.CompactTextString(m) }
|
||||
func (*HeadSyncRange) ProtoMessage() {}
|
||||
func (*HeadSyncRange) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{1}
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{0}
|
||||
}
|
||||
func (m *HeadSyncRange) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -162,7 +117,7 @@ func (m *HeadSyncResult) Reset() { *m = HeadSyncResult{} }
|
||||
func (m *HeadSyncResult) String() string { return proto.CompactTextString(m) }
|
||||
func (*HeadSyncResult) ProtoMessage() {}
|
||||
func (*HeadSyncResult) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{2}
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{1}
|
||||
}
|
||||
func (m *HeadSyncResult) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -222,7 +177,7 @@ func (m *HeadSyncResultElement) Reset() { *m = HeadSyncResultElement{} }
|
||||
func (m *HeadSyncResultElement) String() string { return proto.CompactTextString(m) }
|
||||
func (*HeadSyncResultElement) ProtoMessage() {}
|
||||
func (*HeadSyncResultElement) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{3}
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{2}
|
||||
}
|
||||
func (m *HeadSyncResultElement) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -275,7 +230,7 @@ func (m *HeadSyncRequest) Reset() { *m = HeadSyncRequest{} }
|
||||
func (m *HeadSyncRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*HeadSyncRequest) ProtoMessage() {}
|
||||
func (*HeadSyncRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{4}
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{3}
|
||||
}
|
||||
func (m *HeadSyncRequest) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -327,7 +282,7 @@ func (m *HeadSyncResponse) Reset() { *m = HeadSyncResponse{} }
|
||||
func (m *HeadSyncResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*HeadSyncResponse) ProtoMessage() {}
|
||||
func (*HeadSyncResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{5}
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{4}
|
||||
}
|
||||
func (m *HeadSyncResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -375,7 +330,7 @@ func (m *ObjectSyncMessage) Reset() { *m = ObjectSyncMessage{} }
|
||||
func (m *ObjectSyncMessage) String() string { return proto.CompactTextString(m) }
|
||||
func (*ObjectSyncMessage) ProtoMessage() {}
|
||||
func (*ObjectSyncMessage) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{6}
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{5}
|
||||
}
|
||||
func (m *ObjectSyncMessage) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -445,7 +400,7 @@ func (m *ObjectSyncContentValue) Reset() { *m = ObjectSyncContentValue{}
|
||||
func (m *ObjectSyncContentValue) String() string { return proto.CompactTextString(m) }
|
||||
func (*ObjectSyncContentValue) ProtoMessage() {}
|
||||
func (*ObjectSyncContentValue) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{7}
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{6}
|
||||
}
|
||||
func (m *ObjectSyncContentValue) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -542,7 +497,7 @@ func (m *ObjectHeadUpdate) Reset() { *m = ObjectHeadUpdate{} }
|
||||
func (m *ObjectHeadUpdate) String() string { return proto.CompactTextString(m) }
|
||||
func (*ObjectHeadUpdate) ProtoMessage() {}
|
||||
func (*ObjectHeadUpdate) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{8}
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{7}
|
||||
}
|
||||
func (m *ObjectHeadUpdate) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -602,7 +557,7 @@ func (m *ObjectFullSyncRequest) Reset() { *m = ObjectFullSyncRequest{} }
|
||||
func (m *ObjectFullSyncRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*ObjectFullSyncRequest) ProtoMessage() {}
|
||||
func (*ObjectFullSyncRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{9}
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{8}
|
||||
}
|
||||
func (m *ObjectFullSyncRequest) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -656,7 +611,7 @@ func (m *ObjectFullSyncResponse) Reset() { *m = ObjectFullSyncResponse{}
|
||||
func (m *ObjectFullSyncResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*ObjectFullSyncResponse) ProtoMessage() {}
|
||||
func (*ObjectFullSyncResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{10}
|
||||
return fileDescriptor_5855f4ef9cf24cdb, []int{9}
|
||||
}
|
||||
func (m *ObjectFullSyncResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -708,7 +663,6 @@ func (m *ObjectFullSyncResponse) GetSnapshotPath() []string {
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("anySpace.ErrCodes", ErrCodes_name, ErrCodes_value)
|
||||
proto.RegisterType((*Msg)(nil), "anySpace.Msg")
|
||||
proto.RegisterType((*HeadSyncRange)(nil), "anySpace.HeadSyncRange")
|
||||
proto.RegisterType((*HeadSyncResult)(nil), "anySpace.HeadSyncResult")
|
||||
proto.RegisterType((*HeadSyncResultElement)(nil), "anySpace.HeadSyncResultElement")
|
||||
@ -726,80 +680,49 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptor_5855f4ef9cf24cdb = []byte{
|
||||
// 674 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x4d, 0x6f, 0xd3, 0x40,
|
||||
0x10, 0xf5, 0x26, 0x6d, 0x92, 0x4e, 0xfa, 0x11, 0x56, 0xb4, 0x98, 0x20, 0xa5, 0xc1, 0xa7, 0x88,
|
||||
0x43, 0x52, 0x85, 0x0b, 0xa2, 0x5c, 0x68, 0xd5, 0x2a, 0x11, 0x2a, 0x1f, 0x5b, 0x0a, 0x12, 0xe2,
|
||||
0xb2, 0xb5, 0xb7, 0x49, 0xc0, 0xf1, 0x1a, 0xef, 0x86, 0xd2, 0x1b, 0x27, 0xce, 0x88, 0x9f, 0xc2,
|
||||
0xaf, 0xe0, 0xd8, 0x23, 0x47, 0xd4, 0xfe, 0x0d, 0x0e, 0x68, 0xc7, 0x76, 0x92, 0x06, 0xa7, 0xdc,
|
||||
0x38, 0xc4, 0xde, 0x99, 0x7d, 0xf3, 0xf6, 0xbd, 0x59, 0x8f, 0x02, 0x0f, 0x5c, 0x39, 0x1c, 0xca,
|
||||
0xa0, 0x15, 0xbf, 0x54, 0xc8, 0x5d, 0xd1, 0xc2, 0xa7, 0x3a, 0x0b, 0xdc, 0x30, 0x92, 0x5a, 0xb6,
|
||||
0xf0, 0xa9, 0x26, 0xd9, 0x26, 0x26, 0x68, 0x89, 0x07, 0x67, 0x87, 0x26, 0x57, 0xdd, 0x0a, 0xdf,
|
||||
0xf7, 0x5a, 0xdc, 0xf5, 0xcd, 0xcf, 0xed, 0xf3, 0xa0, 0x27, 0x94, 0x59, 0x86, 0xc7, 0x69, 0xe9,
|
||||
0x24, 0x1f, 0xd7, 0x3a, 0x9b, 0x90, 0x3f, 0x50, 0x3d, 0x6a, 0x43, 0x11, 0x59, 0xbb, 0x9e, 0x4d,
|
||||
0xea, 0xa4, 0xb1, 0xc4, 0xd2, 0xd0, 0xe9, 0xc2, 0x4a, 0x47, 0x70, 0xef, 0xf0, 0x2c, 0x70, 0x99,
|
||||
0x29, 0xa4, 0x14, 0x16, 0x4e, 0x22, 0x39, 0x44, 0xdc, 0x02, 0xc3, 0x35, 0x5d, 0x85, 0x9c, 0x96,
|
||||
0x76, 0x0e, 0x33, 0x39, 0x2d, 0xe9, 0x4d, 0x58, 0xf4, 0x07, 0xc3, 0x81, 0xb6, 0xf3, 0x75, 0xd2,
|
||||
0x58, 0x61, 0x71, 0xe0, 0x9c, 0xc2, 0xea, 0x98, 0x4a, 0xa8, 0x91, 0xaf, 0x0d, 0x57, 0x9f, 0xab,
|
||||
0x3e, 0x72, 0x2d, 0x33, 0x5c, 0xd3, 0x6d, 0x28, 0x09, 0x5f, 0x0c, 0x45, 0xa0, 0x95, 0x9d, 0xab,
|
||||
0xe7, 0x1b, 0xe5, 0xf6, 0x66, 0x33, 0x35, 0xd8, 0xbc, 0x5a, 0xbf, 0x17, 0xe3, 0xd8, 0xb8, 0xc0,
|
||||
0x1c, 0xec, 0xca, 0x51, 0x30, 0x3e, 0x18, 0x03, 0x67, 0x1b, 0xd6, 0x33, 0x0b, 0x8d, 0xee, 0x41,
|
||||
0xea, 0x38, 0x37, 0xf0, 0x50, 0x8f, 0xe0, 0x1e, 0x3a, 0x59, 0x62, 0xb8, 0x76, 0xde, 0xc2, 0xda,
|
||||
0xa4, 0xf8, 0xc3, 0x48, 0x28, 0x3d, 0xbf, 0x5b, 0xb4, 0x05, 0x85, 0x08, 0xdb, 0x9b, 0x48, 0xbf,
|
||||
0x95, 0x21, 0xdd, 0xec, 0xb3, 0x04, 0xe6, 0xec, 0x43, 0x65, 0x4a, 0x5a, 0x28, 0x03, 0x25, 0x68,
|
||||
0x1b, 0x8a, 0x11, 0xca, 0x54, 0x36, 0x41, 0x16, 0x7b, 0x5e, 0x03, 0x58, 0x0a, 0x74, 0xbe, 0x13,
|
||||
0xb8, 0xf1, 0xec, 0xf8, 0x9d, 0x70, 0xb5, 0xd9, 0x3d, 0x10, 0x4a, 0xf1, 0x9e, 0xb8, 0x46, 0xe8,
|
||||
0x43, 0x28, 0xba, 0x32, 0xd0, 0x22, 0xd0, 0x68, 0xb6, 0xdc, 0xae, 0x4f, 0xce, 0x98, 0xf0, 0xec,
|
||||
0xc6, 0x90, 0x57, 0xdc, 0x1f, 0x09, 0x96, 0x16, 0xd0, 0x16, 0x80, 0x8e, 0x84, 0x30, 0x52, 0x44,
|
||||
0x84, 0x9d, 0x2e, 0xb7, 0xd7, 0x9a, 0xdc, 0xf5, 0x9b, 0x2f, 0xc7, 0x69, 0x36, 0x05, 0xa1, 0x1b,
|
||||
0x50, 0x30, 0x51, 0xd7, 0xb3, 0x17, 0x50, 0x45, 0x12, 0x39, 0xbf, 0x09, 0x6c, 0x64, 0x1f, 0x46,
|
||||
0x1f, 0x01, 0x98, 0xee, 0x1f, 0x85, 0x1e, 0xd7, 0x02, 0xc5, 0x97, 0xdb, 0xd5, 0x59, 0x89, 0x9d,
|
||||
0x31, 0xa2, 0x63, 0xb1, 0x29, 0x3c, 0x7d, 0x02, 0x6b, 0x27, 0x23, 0xdf, 0x9f, 0xba, 0xb3, 0xc4,
|
||||
0xe5, 0xe6, 0x2c, 0xc5, 0xfe, 0x55, 0x58, 0xc7, 0x62, 0xb3, 0x95, 0xf4, 0x29, 0x54, 0x26, 0xa9,
|
||||
0xf8, 0x8a, 0x12, 0xd3, 0xf5, 0xf9, 0x6c, 0x31, 0xae, 0x63, 0xb1, 0xbf, 0x6a, 0x77, 0x8a, 0xb0,
|
||||
0xf8, 0xd1, 0x78, 0x74, 0x3e, 0x13, 0xa8, 0xcc, 0x1a, 0x31, 0x5f, 0xb0, 0x31, 0x12, 0x5f, 0xfd,
|
||||
0x12, 0x8b, 0x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x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Msg) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *Msg) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Msg) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.SpaceId) > 0 {
|
||||
i -= len(m.SpaceId)
|
||||
copy(dAtA[i:], m.SpaceId)
|
||||
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SpaceId)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
// 666 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x4f, 0x6f, 0xd3, 0x4e,
|
||||
0x10, 0xf5, 0xa6, 0x6d, 0x92, 0x4e, 0xfa, 0x27, 0xbf, 0xd5, 0xaf, 0xc5, 0x04, 0x29, 0x0d, 0x3e,
|
||||
0x45, 0x1c, 0x92, 0x2a, 0x5c, 0x10, 0xe5, 0x42, 0xab, 0x56, 0x89, 0x10, 0xff, 0xb6, 0x14, 0x24,
|
||||
0xc4, 0x65, 0x6b, 0x4f, 0x9b, 0x80, 0x63, 0x1b, 0xef, 0x86, 0xd2, 0x1b, 0x27, 0xce, 0x88, 0x8f,
|
||||
0xc2, 0xa7, 0xe0, 0xd8, 0x23, 0x47, 0xd4, 0x7e, 0x0d, 0x0e, 0x68, 0xc7, 0x76, 0x92, 0x06, 0xb7,
|
||||
0xdc, 0x38, 0x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0xe0, 0xd1, 0xe9, 0x8b, 0xa2, 0x30, 0xf0, 0x48, 0x0f, 0x4a, 0x8f, 0x3a, 0x59, 0x14, 0xb4, 0x76,
|
||||
0xde, 0xc0, 0xea, 0x04, 0xfc, 0x7e, 0x84, 0x4a, 0x73, 0x1b, 0x4a, 0x64, 0x71, 0x2f, 0xc3, 0x66,
|
||||
0x21, 0x6f, 0x43, 0x31, 0x26, 0xf7, 0x52, 0xe9, 0x37, 0x72, 0xa4, 0x9b, 0x7d, 0x91, 0x96, 0x39,
|
||||
0x7b, 0x50, 0x9d, 0x92, 0x16, 0x85, 0x81, 0x42, 0xde, 0x81, 0x52, 0x4c, 0x32, 0x95, 0xcd, 0x88,
|
||||
0xc5, 0xbe, 0xca, 0x00, 0x91, 0x15, 0x3a, 0xdf, 0x18, 0xfc, 0xf7, 0xf4, 0xf0, 0x2d, 0xba, 0xda,
|
||||
0xec, 0x3e, 0x46, 0xa5, 0xe4, 0x31, 0x5e, 0x23, 0xf4, 0x3e, 0x94, 0xdc, 0x30, 0xd0, 0x18, 0x68,
|
||||
0x6a, 0xb6, 0xd2, 0x69, 0x4c, 0xce, 0x98, 0xf0, 0xec, 0x24, 0x25, 0x2f, 0xa5, 0x3f, 0x42, 0x91,
|
||||
0x01, 0x78, 0x1b, 0x40, 0xc7, 0x88, 0x46, 0x0a, 0xc6, 0xe4, 0x74, 0xa5, 0xb3, 0xda, 0x92, 0xae,
|
||||
0xdf, 0x7a, 0x31, 0x4e, 0x8b, 0xa9, 0x12, 0xbe, 0x0e, 0x45, 0x13, 0xf5, 0x3c, 0x7b, 0x9e, 0x54,
|
||||
0xa4, 0x91, 0xf3, 0x8b, 0xc1, 0x7a, 0xfe, 0x61, 0xfc, 0x01, 0x80, 0x71, 0xff, 0x20, 0xf2, 0xa4,
|
||||
0x46, 0x12, 0x5f, 0xe9, 0xd4, 0x66, 0x25, 0x76, 0xc7, 0x15, 0x5d, 0x4b, 0x4c, 0xd5, 0xf3, 0x47,
|
||||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e, 0x2b,
|
||||
0x6f, 0x88, 0xd2, 0x61, 0xac, 0x5d, 0xb7, 0xd9, 0x64, 0x9b, 0x6c, 0x7b, 0xeb, 0xfb, 0x79, 0x9d,
|
||||
0x9d, 0x9d, 0xd7, 0xd9, 0xcf, 0xf3, 0x3a, 0xfb, 0x72, 0x51, 0xb7, 0xce, 0x2e, 0xea, 0xd6, 0x8f,
|
||||
0x8b, 0xba, 0xf5, 0xfa, 0xf6, 0x5f, 0xff, 0xfa, 0x0f, 0x8b, 0xf4, 0xba, 0xfb, 0x3b, 0x00, 0x00,
|
||||
0xff, 0xff, 0xcf, 0x4f, 0x53, 0x3d, 0x26, 0x06, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) {
|
||||
@ -1325,19 +1248,6 @@ func encodeVarintSpacesync(dAtA []byte, offset int, v uint64) int {
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *Msg) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.SpaceId)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovSpacesync(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *HeadSyncRange) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
@ -1583,88 +1493,6 @@ func sovSpacesync(x uint64) (n int) {
|
||||
func sozSpacesync(x uint64) (n int) {
|
||||
return sovSpacesync(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *Msg) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSpacesync
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Msg: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Msg: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", 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.SpaceId = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipSpacesync(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthSpacesync
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *HeadSyncRange) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
||||
@ -74,27 +74,27 @@ func (c *drpcSpaceClient) Stream(ctx context.Context) (DRPCSpace_StreamClient, e
|
||||
|
||||
type DRPCSpace_StreamClient interface {
|
||||
drpc.Stream
|
||||
Send(*Msg) error
|
||||
Recv() (*Msg, error)
|
||||
Send(*ObjectSyncMessage) error
|
||||
Recv() (*ObjectSyncMessage, error)
|
||||
}
|
||||
|
||||
type drpcSpace_StreamClient struct {
|
||||
drpc.Stream
|
||||
}
|
||||
|
||||
func (x *drpcSpace_StreamClient) Send(m *Msg) error {
|
||||
func (x *drpcSpace_StreamClient) Send(m *ObjectSyncMessage) error {
|
||||
return x.MsgSend(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{})
|
||||
}
|
||||
|
||||
func (x *drpcSpace_StreamClient) Recv() (*Msg, error) {
|
||||
m := new(Msg)
|
||||
func (x *drpcSpace_StreamClient) Recv() (*ObjectSyncMessage, error) {
|
||||
m := new(ObjectSyncMessage)
|
||||
if err := x.MsgRecv(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (x *drpcSpace_StreamClient) RecvMsg(m *Msg) error {
|
||||
func (x *drpcSpace_StreamClient) RecvMsg(m *ObjectSyncMessage) error {
|
||||
return x.MsgRecv(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{})
|
||||
}
|
||||
|
||||
@ -163,26 +163,26 @@ func (x *drpcSpace_HeadSyncStream) SendAndClose(m *HeadSyncResponse) error {
|
||||
|
||||
type DRPCSpace_StreamStream interface {
|
||||
drpc.Stream
|
||||
Send(*Msg) error
|
||||
Recv() (*Msg, error)
|
||||
Send(*ObjectSyncMessage) error
|
||||
Recv() (*ObjectSyncMessage, error)
|
||||
}
|
||||
|
||||
type drpcSpace_StreamStream struct {
|
||||
drpc.Stream
|
||||
}
|
||||
|
||||
func (x *drpcSpace_StreamStream) Send(m *Msg) error {
|
||||
func (x *drpcSpace_StreamStream) Send(m *ObjectSyncMessage) error {
|
||||
return x.MsgSend(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{})
|
||||
}
|
||||
|
||||
func (x *drpcSpace_StreamStream) Recv() (*Msg, error) {
|
||||
m := new(Msg)
|
||||
func (x *drpcSpace_StreamStream) Recv() (*ObjectSyncMessage, error) {
|
||||
m := new(ObjectSyncMessage)
|
||||
if err := x.MsgRecv(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (x *drpcSpace_StreamStream) RecvMsg(m *Msg) error {
|
||||
func (x *drpcSpace_StreamStream) RecvMsg(m *ObjectSyncMessage) error {
|
||||
return x.MsgRecv(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{})
|
||||
}
|
||||
|
||||
291
common/commonspace/syncservice/syncservice.go
Normal file
291
common/commonspace/syncservice/syncservice.go
Normal file
@ -0,0 +1,291 @@
|
||||
package syncservice
|
||||
|
||||
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/common/account"
|
||||
"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/service/treecache"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type syncService struct {
|
||||
treeCache treecache.Service
|
||||
account account.Service
|
||||
messageService MessageSender
|
||||
}
|
||||
|
||||
var log = logger.NewNamed("requesthandler")
|
||||
|
||||
func New() app.Component {
|
||||
return &syncService{}
|
||||
}
|
||||
|
||||
type SyncService interface {
|
||||
HandleSyncMessage(ctx context.Context, senderId string, request *syncproto.Sync) (err error)
|
||||
}
|
||||
|
||||
type MessageSender interface {
|
||||
SendMessageAsync(peerId string, msg *syncproto.Sync) error
|
||||
SendToSpaceAsync(spaceId string, msg *syncproto.Sync) error
|
||||
}
|
||||
|
||||
const CName = "SyncRequestHandler"
|
||||
|
||||
func (r *syncService) Init(a *app.App) (err error) {
|
||||
r.treeCache = a.MustComponent(treecache.CName).(treecache.Service)
|
||||
r.account = a.MustComponent(account.CName).(account.Service)
|
||||
r.messageService = a.MustComponent("MessageService").(MessageSender)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *syncService) Name() (name string) {
|
||||
return CName
|
||||
}
|
||||
|
||||
func (r *syncService) Run(ctx context.Context) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *syncService) Close(ctx context.Context) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *syncService) HandleSyncMessage(ctx context.Context, senderId string, content *syncproto.Sync) error {
|
||||
msg := content.GetMessage()
|
||||
switch {
|
||||
case msg.GetFullSyncRequest() != nil:
|
||||
return r.HandleFullSyncRequest(ctx, senderId, msg.GetFullSyncRequest(), content.GetTreeHeader(), content.GetTreeId())
|
||||
case msg.GetFullSyncResponse() != nil:
|
||||
return r.HandleFullSyncResponse(ctx, senderId, msg.GetFullSyncResponse(), content.GetTreeHeader(), content.GetTreeId())
|
||||
case msg.GetHeadUpdate() != nil:
|
||||
return r.HandleHeadUpdate(ctx, senderId, msg.GetHeadUpdate(), content.GetTreeHeader(), content.GetTreeId())
|
||||
case msg.GetAclList() != nil:
|
||||
return r.HandleACLList(ctx, senderId, msg.GetAclList(), content.GetTreeHeader(), content.GetTreeId())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *syncService) HandleHeadUpdate(
|
||||
ctx context.Context,
|
||||
senderId string,
|
||||
update *syncproto.SyncHeadUpdate,
|
||||
header *aclpb.Header,
|
||||
treeId string) (err error) {
|
||||
|
||||
var (
|
||||
fullRequest *syncproto.SyncFullRequest
|
||||
snapshotPath []string
|
||||
result tree.AddResult
|
||||
)
|
||||
log.With(zap.String("peerId", senderId), zap.String("treeId", treeId)).
|
||||
Debug("processing head update")
|
||||
|
||||
err = r.treeCache.Do(ctx, treeId, func(obj any) error {
|
||||
objTree := obj.(tree.ObjectTree)
|
||||
objTree.Lock()
|
||||
defer objTree.Unlock()
|
||||
|
||||
if slice.UnsortedEquals(update.Heads, objTree.Heads()) {
|
||||
return nil
|
||||
}
|
||||
|
||||
result, err = objTree.AddRawChanges(ctx, update.Changes...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// if we couldn't add all the changes
|
||||
shouldFullSync := len(update.Changes) != len(result.Added)
|
||||
snapshotPath = objTree.SnapshotPath()
|
||||
if shouldFullSync {
|
||||
fullRequest, err = r.prepareFullSyncRequest(objTree)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
// if there are no such tree
|
||||
if err == storage.ErrUnknownTreeId {
|
||||
fullRequest = &syncproto.SyncFullRequest{}
|
||||
}
|
||||
// if we have incompatible heads, or we haven't seen the tree at all
|
||||
if fullRequest != nil {
|
||||
return r.messageService.SendMessageAsync(senderId, syncproto.WrapFullRequest(fullRequest, header, treeId))
|
||||
}
|
||||
// if error or nothing has changed
|
||||
if err != nil || len(result.Added) == 0 {
|
||||
return err
|
||||
}
|
||||
|
||||
// otherwise sending heads update message
|
||||
newUpdate := &syncproto.SyncHeadUpdate{
|
||||
Heads: result.Heads,
|
||||
Changes: result.Added,
|
||||
SnapshotPath: snapshotPath,
|
||||
}
|
||||
return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate, header, treeId))
|
||||
}
|
||||
|
||||
func (r *syncService) HandleFullSyncRequest(
|
||||
ctx context.Context,
|
||||
senderId string,
|
||||
request *syncproto.SyncFullRequest,
|
||||
header *aclpb.Header,
|
||||
treeId string) (err error) {
|
||||
|
||||
var fullResponse *syncproto.SyncFullResponse
|
||||
err = r.treeCache.Do(ctx, treeId, func(obj any) error {
|
||||
objTree := obj.(tree.ObjectTree)
|
||||
objTree.Lock()
|
||||
defer objTree.Unlock()
|
||||
|
||||
fullResponse, err = r.prepareFullSyncResponse(treeId, request.SnapshotPath, request.Heads, objTree)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return r.messageService.SendMessageAsync(senderId, syncproto.WrapFullResponse(fullResponse, header, treeId))
|
||||
}
|
||||
|
||||
func (r *syncService) HandleFullSyncResponse(
|
||||
ctx context.Context,
|
||||
senderId string,
|
||||
response *syncproto.SyncFullResponse,
|
||||
header *aclpb.Header,
|
||||
treeId string) (err error) {
|
||||
|
||||
var (
|
||||
snapshotPath []string
|
||||
result tree.AddResult
|
||||
)
|
||||
|
||||
err = r.treeCache.Do(ctx, treeId, func(obj interface{}) error {
|
||||
objTree := obj.(tree.ObjectTree)
|
||||
objTree.Lock()
|
||||
defer objTree.Unlock()
|
||||
|
||||
// if we already have the heads for whatever reason
|
||||
if slice.UnsortedEquals(response.Heads, objTree.Heads()) {
|
||||
return nil
|
||||
}
|
||||
|
||||
result, err = objTree.AddRawChanges(ctx, response.Changes...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
snapshotPath = objTree.SnapshotPath()
|
||||
return nil
|
||||
})
|
||||
|
||||
// if error or nothing has changed
|
||||
if (err != nil || len(result.Added) == 0) && err != storage.ErrUnknownTreeId {
|
||||
return err
|
||||
}
|
||||
// if we have a new tree
|
||||
if err == storage.ErrUnknownTreeId {
|
||||
err = r.createTree(ctx, response, header, treeId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result = tree.AddResult{
|
||||
OldHeads: []string{},
|
||||
Heads: response.Heads,
|
||||
Added: response.Changes,
|
||||
}
|
||||
}
|
||||
// sending heads update message
|
||||
newUpdate := &syncproto.SyncHeadUpdate{
|
||||
Heads: result.Heads,
|
||||
Changes: result.Added,
|
||||
SnapshotPath: snapshotPath,
|
||||
}
|
||||
return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate, header, treeId))
|
||||
}
|
||||
|
||||
func (r *syncService) HandleACLList(
|
||||
ctx context.Context,
|
||||
senderId string,
|
||||
req *syncproto.SyncACLList,
|
||||
header *aclpb.Header,
|
||||
id string) (err error) {
|
||||
|
||||
err = r.treeCache.Do(ctx, id, func(obj interface{}) error {
|
||||
return nil
|
||||
})
|
||||
// do nothing if already added
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
// if not found then add to storage
|
||||
if err == storage.ErrUnknownTreeId {
|
||||
return r.createACLList(ctx, req, header, id)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *syncService) prepareFullSyncRequest(t tree.ObjectTree) (*syncproto.SyncFullRequest, error) {
|
||||
return &syncproto.SyncFullRequest{
|
||||
Heads: t.Heads(),
|
||||
SnapshotPath: t.SnapshotPath(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *syncService) prepareFullSyncResponse(
|
||||
treeId string,
|
||||
theirPath, theirHeads []string,
|
||||
t tree.ObjectTree) (*syncproto.SyncFullResponse, error) {
|
||||
ourChanges, err := t.ChangesAfterCommonSnapshot(theirPath, theirHeads)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &syncproto.SyncFullResponse{
|
||||
Heads: t.Heads(),
|
||||
Changes: ourChanges,
|
||||
SnapshotPath: t.SnapshotPath(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *syncService) createTree(
|
||||
ctx context.Context,
|
||||
response *syncproto.SyncFullResponse,
|
||||
header *aclpb.Header,
|
||||
treeId string) error {
|
||||
|
||||
return r.treeCache.Add(
|
||||
ctx,
|
||||
treeId,
|
||||
storage.TreeStorageCreatePayload{
|
||||
TreeId: treeId,
|
||||
Header: header,
|
||||
Changes: response.Changes,
|
||||
Heads: response.Heads,
|
||||
})
|
||||
}
|
||||
|
||||
func (r *syncService) createACLList(
|
||||
ctx context.Context,
|
||||
req *syncproto.SyncACLList,
|
||||
header *aclpb.Header,
|
||||
treeId string) error {
|
||||
|
||||
return r.treeCache.Add(
|
||||
ctx,
|
||||
treeId,
|
||||
storage.ACLListStorageCreatePayload{
|
||||
ListId: treeId,
|
||||
Header: header,
|
||||
Records: req.Records,
|
||||
})
|
||||
}
|
||||
@ -1332,73 +1332,73 @@ func init() {
|
||||
var fileDescriptor_37a022c841a51877 = []byte{
|
||||
// 1078 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcd, 0x6e, 0x23, 0x45,
|
||||
0x10, 0xf6, 0x8c, 0xe3, 0x38, 0x2e, 0x3b, 0x8e, 0xd3, 0x1b, 0xed, 0x8e, 0xa2, 0xc8, 0x44, 0x23,
|
||||
0x04, 0x51, 0x40, 0x5e, 0x08, 0x2b, 0xf1, 0x77, 0x00, 0xc7, 0x8b, 0xb0, 0x37, 0x11, 0xac, 0x3a,
|
||||
0x61, 0x57, 0xe2, 0xd6, 0x99, 0xe9, 0x4d, 0x9a, 0xb5, 0x67, 0x46, 0xd3, 0x9d, 0x44, 0x3e, 0xf2,
|
||||
0x06, 0x3c, 0x02, 0x1c, 0x79, 0x02, 0x5e, 0x01, 0x89, 0xcb, 0x1e, 0x91, 0xb8, 0xa0, 0xe4, 0x04,
|
||||
0x27, 0x1e, 0x01, 0xf5, 0xcf, 0xcc, 0xf4, 0xd8, 0x4e, 0xf8, 0xd1, 0x0a, 0x89, 0xc3, 0x48, 0xdd,
|
||||
0x5f, 0x55, 0x75, 0x57, 0x7d, 0x55, 0x53, 0x5d, 0xf0, 0x56, 0xf2, 0xfc, 0xf4, 0x3e, 0x09, 0xc6,
|
||||
0xf2, 0x0b, 0xce, 0x48, 0x74, 0x4a, 0xb9, 0x5c, 0x26, 0x27, 0xf7, 0x93, 0x34, 0x16, 0x31, 0xb7,
|
||||
0xf0, 0x9e, 0x42, 0x50, 0x95, 0x04, 0x63, 0xff, 0x09, 0xb4, 0x30, 0xb9, 0xec, 0x0f, 0x0e, 0x31,
|
||||
0x0d, 0xe2, 0x34, 0x44, 0x1e, 0xd4, 0x13, 0x32, 0x1d, 0xc7, 0x24, 0xf4, 0x9c, 0x6d, 0x67, 0xa7,
|
||||
0x85, 0xb3, 0x2d, 0xda, 0x82, 0x06, 0x67, 0xa7, 0x11, 0x11, 0xe7, 0x29, 0xf5, 0x5c, 0x25, 0x2b,
|
||||
0x00, 0xd4, 0x06, 0x97, 0x85, 0x5e, 0x75, 0xdb, 0xd9, 0x69, 0x60, 0x97, 0x85, 0xfe, 0x1f, 0x2e,
|
||||
0xac, 0xf5, 0x07, 0x87, 0x83, 0x38, 0x12, 0x34, 0x12, 0x4f, 0xc8, 0xf8, 0x9c, 0xa2, 0x37, 0xa0,
|
||||
0x7e, 0xce, 0x69, 0xda, 0x0f, 0xf5, 0xd9, 0xcd, 0xbd, 0xb5, 0x1e, 0x09, 0xc6, 0xbd, 0xfe, 0xe0,
|
||||
0xf0, 0x0b, 0x0d, 0x0f, 0x2b, 0x38, 0xd3, 0x40, 0x0f, 0x00, 0xe4, 0x12, 0xd3, 0x49, 0x7c, 0xa1,
|
||||
0xef, 0x6b, 0xee, 0x21, 0x5b, 0x5f, 0x4b, 0x86, 0x15, 0x6c, 0xe9, 0x21, 0x0c, 0x1b, 0x72, 0xf7,
|
||||
0x98, 0xa6, 0x13, 0xc6, 0x39, 0x8b, 0xa3, 0x81, 0x0a, 0x59, 0x39, 0xd6, 0xdc, 0xdb, 0xb2, 0xed,
|
||||
0x67, 0x75, 0x86, 0x15, 0xbc, 0xd0, 0x36, 0xf3, 0x64, 0x14, 0x5d, 0x30, 0x41, 0xbd, 0xa5, 0x79,
|
||||
0x4f, 0xb4, 0x24, 0xf3, 0x44, 0xef, 0x50, 0x0f, 0x56, 0xe4, 0xee, 0x51, 0xcc, 0x22, 0xaf, 0xa6,
|
||||
0x6c, 0x3a, 0xb6, 0x8d, 0xc4, 0x87, 0x15, 0x9c, 0xeb, 0xa0, 0x77, 0xa1, 0x29, 0xd7, 0x83, 0x38,
|
||||
0x7a, 0xc6, 0xd2, 0x89, 0xb7, 0xac, 0x4c, 0xee, 0xd8, 0x26, 0x46, 0x34, 0xac, 0x60, 0x5b, 0x73,
|
||||
0xbf, 0x0e, 0xb5, 0x0b, 0x49, 0xaf, 0xff, 0x11, 0xd4, 0xfb, 0x83, 0xc3, 0x87, 0x44, 0x10, 0xe9,
|
||||
0x32, 0x09, 0xc6, 0x86, 0x7c, 0xcf, 0xd9, 0xae, 0xee, 0x34, 0xf7, 0x36, 0xb2, 0xb3, 0xec, 0x9c,
|
||||
0x60, 0x4b, 0xcf, 0xff, 0xcd, 0x81, 0x95, 0xfe, 0xe0, 0xf0, 0x48, 0x10, 0x41, 0xd1, 0xab, 0xb0,
|
||||
0x9a, 0x52, 0x12, 0x1e, 0xd0, 0xe9, 0x90, 0xf0, 0x33, 0xca, 0xd5, 0x29, 0x4b, 0xb8, 0x0c, 0xa2,
|
||||
0xb7, 0x35, 0x37, 0xca, 0x84, 0x7b, 0xae, 0xba, 0x68, 0xdd, 0x76, 0x5a, 0x49, 0xb0, 0xa5, 0x84,
|
||||
0x10, 0xf6, 0x8c, 0xe3, 0x38, 0x2e, 0x3b, 0x8e, 0xd3, 0x1b, 0xed, 0x8e, 0xa2, 0xc8, 0x8a, 0x46,
|
||||
0x08, 0xa2, 0x80, 0xbc, 0x60, 0x56, 0xe2, 0xef, 0x00, 0x8e, 0x17, 0x61, 0x6f, 0x22, 0x58, 0x75,
|
||||
0xc2, 0xae, 0xc4, 0xad, 0x33, 0xd3, 0x9b, 0x34, 0x6b, 0xcf, 0x8c, 0xa6, 0x3b, 0x89, 0x7c, 0xe4,
|
||||
0x0d, 0x78, 0x04, 0x38, 0xf2, 0x04, 0xbc, 0x02, 0x12, 0x97, 0x3d, 0x22, 0x71, 0x41, 0xc9, 0x09,
|
||||
0x4e, 0x3c, 0x02, 0xea, 0x9f, 0x99, 0xe9, 0xb1, 0x93, 0xf0, 0xa3, 0x15, 0xd2, 0x1e, 0x46, 0xea,
|
||||
0xfe, 0xaa, 0xaa, 0xbb, 0xea, 0xab, 0x9a, 0xea, 0x82, 0xb7, 0x93, 0xe7, 0x27, 0xf7, 0x49, 0x30,
|
||||
0x91, 0x5f, 0x70, 0x4a, 0xa2, 0x13, 0xca, 0xe5, 0x32, 0x39, 0xbe, 0x9f, 0xa4, 0xb1, 0x88, 0xb9,
|
||||
0x85, 0xf7, 0x14, 0x82, 0xaa, 0x24, 0x98, 0xf8, 0x4f, 0xa0, 0x85, 0xc9, 0xc5, 0x60, 0x78, 0x80,
|
||||
0x69, 0x10, 0xa7, 0x21, 0xf2, 0xa0, 0x9e, 0x90, 0xd9, 0x24, 0x26, 0xa1, 0xe7, 0x6c, 0x3b, 0x3b,
|
||||
0x2d, 0x9c, 0x6d, 0xd1, 0x16, 0x34, 0x38, 0x3b, 0x89, 0x88, 0x38, 0x4b, 0xa9, 0xe7, 0x2a, 0x59,
|
||||
0x01, 0xa0, 0x36, 0xb8, 0x2c, 0xf4, 0xaa, 0xdb, 0xce, 0x4e, 0x03, 0xbb, 0x2c, 0xf4, 0xff, 0x74,
|
||||
0x61, 0x6d, 0x30, 0x3c, 0x18, 0xc6, 0x91, 0xa0, 0x91, 0x78, 0x42, 0x26, 0x67, 0x14, 0xbd, 0x09,
|
||||
0xf5, 0x33, 0x4e, 0xd3, 0x41, 0xa8, 0xcf, 0x6e, 0xf6, 0xd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x5b, 0xd0, 0x30, 0xfd, 0x62, 0x14, 0x2a, 0xc7, 0x1b, 0xb8, 0x00,
|
||||
0xfc, 0xdf, 0x1d, 0x58, 0x2d, 0x15, 0x00, 0xda, 0x81, 0x35, 0x12, 0x04, 0x34, 0x11, 0x8f, 0xcf,
|
||||
0x4f, 0xc6, 0x2c, 0x38, 0xa0, 0xd9, 0x91, 0xb3, 0x30, 0xda, 0x85, 0x8e, 0x89, 0xab, 0x50, 0xd5,
|
||||
0xcc, 0xcc, 0xe1, 0xff, 0x5d, 0xe2, 0x25, 0x15, 0x2a, 0x90, 0x91, 0xce, 0x7a, 0x03, 0xe7, 0x7b,
|
||||
0xff, 0x27, 0x07, 0x9a, 0x56, 0x6f, 0x79, 0x09, 0x39, 0xcf, 0xc9, 0x3a, 0xca, 0xdb, 0x7e, 0xd5,
|
||||
0x26, 0x2b, 0x87, 0x91, 0x0f, 0xad, 0xa2, 0xf3, 0x8d, 0x42, 0x15, 0x53, 0x03, 0x97, 0xb0, 0xc5,
|
||||
0x24, 0xd5, 0x6e, 0x20, 0xc9, 0x9f, 0xe4, 0x99, 0x33, 0x8d, 0xfd, 0xb6, 0x70, 0x3e, 0x86, 0x35,
|
||||
0xd3, 0x95, 0x30, 0x4d, 0xc6, 0x24, 0xc8, 0x3b, 0xcb, 0xdd, 0x8c, 0x55, 0x5c, 0x12, 0xe3, 0x59,
|
||||
0x75, 0xff, 0x6b, 0x07, 0xd6, 0xe7, 0xd4, 0x5e, 0x02, 0x85, 0x45, 0x15, 0xe5, 0xb1, 0x19, 0x0e,
|
||||
0xe7, 0x70, 0x3f, 0x81, 0x7b, 0x37, 0xbc, 0x4c, 0xb7, 0x3a, 0x32, 0x53, 0x4e, 0xee, 0x3f, 0xf8,
|
||||
0xd7, 0xbe, 0x73, 0xa0, 0x51, 0xbc, 0xfc, 0x77, 0x61, 0x39, 0x49, 0xe9, 0xc5, 0x28, 0x34, 0x4d,
|
||||
0xd5, 0xec, 0x4a, 0x97, 0xb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90, 0xb1, 0xce, 0x7a, 0x03, 0xe7, 0x7b,
|
||||
0xff, 0x67, 0x07, 0x9a, 0x56, 0x6f, 0x79, 0x09, 0x39, 0xcf, 0xc9, 0x3a, 0xcc, 0xdb, 0x7e, 0xd5,
|
||||
0x26, 0x2b, 0x87, 0x91, 0x0f, 0xad, 0xa2, 0xf3, 0x8d, 0x43, 0x15, 0x53, 0x03, 0x97, 0xb0, 0xeb,
|
||||
0x49, 0xaa, 0xdd, 0x40, 0x92, 0x3f, 0xcd, 0x33, 0x67, 0x1a, 0xfb, 0x6d, 0xe1, 0x7c, 0x02, 0x6b,
|
||||
0xa6, 0x2b, 0x61, 0x9a, 0x4c, 0x48, 0x90, 0x77, 0x96, 0xbb, 0x19, 0xab, 0xb8, 0x24, 0xc6, 0xf3,
|
||||
0xea, 0xfe, 0x37, 0x0e, 0xac, 0x2f, 0xa8, 0xbd, 0x04, 0x0a, 0x8b, 0x2a, 0xca, 0x63, 0x33, 0x1c,
|
||||
0x2e, 0xe0, 0x7e, 0x02, 0xf7, 0x6e, 0x78, 0x99, 0x6e, 0x75, 0x64, 0xae, 0x9c, 0xdc, 0x7f, 0xf1,
|
||||
0xaf, 0x7d, 0xef, 0x40, 0xa3, 0x78, 0xf9, 0xef, 0xc2, 0x72, 0x92, 0xd2, 0xf3, 0x71, 0x68, 0x9a,
|
||||
0xaa, 0xd9, 0x95, 0x2e, 0x77, 0xe7, 0x2e, 0x47, 0xb0, 0x14, 0x12, 0x41, 0x4c, 0x4c, 0x6a, 0x8d,
|
||||
0x7a, 0x80, 0x82, 0xb3, 0x34, 0xa5, 0x91, 0xc0, 0xc5, 0x53, 0xa1, 0x4a, 0x62, 0x09, 0x5f, 0x23,
|
||||
0x91, 0xff, 0xb0, 0x60, 0x53, 0xca, 0x05, 0x99, 0x26, 0xaa, 0xaa, 0xab, 0xb8, 0x00, 0xfc, 0x81,
|
||||
0x72, 0x71, 0x44, 0x49, 0x48, 0x53, 0x39, 0x9c, 0x3c, 0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56, 0x54, 0xfb, 0xee, 0x43, 0x40, 0x8b, 0xbf, 0x19,
|
||||
0x6a, 0x40, 0x6d, 0x10, 0x4e, 0x59, 0xd4, 0xa9, 0x20, 0x80, 0xe5, 0xa7, 0x29, 0x13, 0x34, 0xed,
|
||||
0x38, 0x72, 0x8d, 0xd5, 0x55, 0x1d, 0x17, 0x35, 0xa1, 0xae, 0x5b, 0x5b, 0xd8, 0xa9, 0xee, 0xbe,
|
||||
0x01, 0xed, 0xb2, 0x5f, 0x52, 0xf5, 0x8b, 0xe3, 0xaf, 0x69, 0x20, 0x3a, 0x15, 0x79, 0xda, 0x61,
|
||||
0x42, 0x02, 0xda, 0x71, 0xf6, 0xfa, 0x3f, 0x5d, 0x76, 0x9d, 0x17, 0x97, 0x5d, 0xe7, 0xb7, 0xcb,
|
||||
0xae, 0xf3, 0xed, 0x55, 0xb7, 0xf2, 0xe2, 0xaa, 0x5b, 0xf9, 0xe5, 0xaa, 0x5b, 0xf9, 0xca, 0xbb,
|
||||
0x69, 0xfe, 0x3f, 0x5e, 0x56, 0xe3, 0xfe, 0xbb, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x0c, 0x62,
|
||||
0x40, 0x97, 0x22, 0x0c, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *RawACLRecord) Marshal() (dAtA []byte, err error) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
syntax = "proto3";
|
||||
package acl;
|
||||
option go_package = "aclpb";
|
||||
option go_package = "pkg/acl/aclchanges/aclpb";
|
||||
|
||||
// ACL protos
|
||||
|
||||
|
||||
@ -213,11 +213,12 @@ func (st *ACLState) applyChangeContent(ch *aclpb.ACLContentValue) error {
|
||||
|
||||
func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLUserPermissionChange) error {
|
||||
chIdentity := string(ch.Identity)
|
||||
if _, exists := st.userStates[chIdentity]; !exists {
|
||||
state, exists := st.userStates[chIdentity]
|
||||
if !exists {
|
||||
return ErrNoSuchUser
|
||||
}
|
||||
|
||||
st.userStates[chIdentity].Permissions = ch.Permissions
|
||||
state.Permissions = ch.Permissions
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -339,12 +340,12 @@ func (st *ACLState) applyUserRemove(ch *aclpb.ACLUserRemove) error {
|
||||
|
||||
func (st *ACLState) applyUserConfirm(ch *aclpb.ACLUserConfirm) error {
|
||||
chIdentity := string(ch.Identity)
|
||||
if _, exists := st.userStates[chIdentity]; !exists {
|
||||
state, exists := st.userStates[chIdentity]
|
||||
if !exists {
|
||||
return ErrNoSuchUser
|
||||
}
|
||||
|
||||
userState := st.userStates[chIdentity]
|
||||
userState.IsConfirmed = true
|
||||
state.IsConfirmed = true
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ func (c *changeBuilder) ConvertFromRaw(rawIdChange *aclpb.RawTreeChangeWithId, v
|
||||
}
|
||||
}
|
||||
|
||||
raw := &aclpb.RawTreeChange{}
|
||||
raw := &aclpb.RawTreeChange{} // TODO: sync pool
|
||||
err = proto.Unmarshal(rawIdChange.GetRawChange(), raw)
|
||||
if err != nil {
|
||||
return
|
||||
|
||||
@ -58,7 +58,7 @@ type ObjectTree interface {
|
||||
Storage() storage.TreeStorage
|
||||
DebugDump() (string, error)
|
||||
|
||||
AddContent(ctx context.Context, content SignableChangeContent) (*aclpb.RawTreeChangeWithId, error)
|
||||
AddContent(ctx context.Context, content SignableChangeContent) (AddResult, error)
|
||||
AddRawChanges(ctx context.Context, changes ...*aclpb.RawTreeChangeWithId) (AddResult, error)
|
||||
|
||||
Close() error
|
||||
@ -67,11 +67,11 @@ type ObjectTree interface {
|
||||
type objectTree struct {
|
||||
treeStorage storage.TreeStorage
|
||||
changeBuilder ChangeBuilder
|
||||
updateListener ObjectTreeUpdateListener
|
||||
validator ObjectTreeValidator
|
||||
rawChangeLoader *rawChangeLoader
|
||||
treeBuilder *treeBuilder
|
||||
aclList list.ACLList
|
||||
updateListener ObjectTreeUpdateListener
|
||||
|
||||
id string
|
||||
header *aclpb.TreeHeader
|
||||
@ -148,7 +148,7 @@ func (ot *objectTree) Storage() storage.TreeStorage {
|
||||
return ot.treeStorage
|
||||
}
|
||||
|
||||
func (ot *objectTree) AddContent(ctx context.Context, content SignableChangeContent) (rawChange *aclpb.RawTreeChangeWithId, err error) {
|
||||
func (ot *objectTree) AddContent(ctx context.Context, content SignableChangeContent) (res AddResult, err error) {
|
||||
defer func() {
|
||||
if err == nil && ot.updateListener != nil {
|
||||
ot.updateListener.Update(ot)
|
||||
@ -160,9 +160,13 @@ func (ot *objectTree) AddContent(ctx context.Context, content SignableChangeCont
|
||||
return
|
||||
}
|
||||
|
||||
// saving old heads
|
||||
oldHeads := make([]string, 0, len(ot.tree.Heads()))
|
||||
oldHeads = append(oldHeads, ot.tree.Heads()...)
|
||||
|
||||
objChange, rawChange, err := ot.changeBuilder.BuildContent(payload)
|
||||
if content.IsSnapshot {
|
||||
// clearing tree, because we already fixed everything in the last snapshot
|
||||
// clearing tree, because we already saved everything in the last snapshot
|
||||
ot.tree = &Tree{}
|
||||
}
|
||||
err = ot.tree.AddMergedHead(objChange)
|
||||
@ -176,6 +180,16 @@ func (ot *objectTree) AddContent(ctx context.Context, content SignableChangeCont
|
||||
}
|
||||
|
||||
err = ot.treeStorage.SetHeads([]string{objChange.Id})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = AddResult{
|
||||
OldHeads: oldHeads,
|
||||
Heads: []string{objChange.Id},
|
||||
Added: []*aclpb.RawTreeChangeWithId{rawChange},
|
||||
Mode: Append,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user