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

consensus: use strings for ids

This commit is contained in:
Sergey Cherepanov 2023-07-03 16:19:24 +02:00
parent 92cbfb1cb3
commit b12a056dd9
No known key found for this signature in database
GPG key ID: 87F8EDE8FBDF637C
5 changed files with 121 additions and 127 deletions

View file

@ -38,11 +38,11 @@ type Service interface {
// AddLog adds new log to consensus servers
AddLog(ctx context.Context, clog *consensusproto.Log) (err error)
// AddRecord adds new record to consensus servers
AddRecord(ctx context.Context, logId []byte, clog *consensusproto.RawRecord) (record *consensusproto.RawRecordWithId, err error)
AddRecord(ctx context.Context, logId string, clog *consensusproto.RawRecord) (record *consensusproto.RawRecordWithId, err error)
// Watch starts watching to given logId and calls watcher when any relative event received
Watch(logId []byte, w Watcher) (err error)
Watch(logId string, w Watcher) (err error)
// UnWatch stops watching given logId and removes watcher
UnWatch(logId []byte) (err error)
UnWatch(logId string) (err error)
app.ComponentRunnable
}
@ -97,7 +97,7 @@ func (s *service) AddLog(ctx context.Context, clog *consensusproto.Log) (err err
})
}
func (s *service) AddRecord(ctx context.Context, logId []byte, clog *consensusproto.RawRecord) (record *consensusproto.RawRecordWithId, err error) {
func (s *service) AddRecord(ctx context.Context, logId string, clog *consensusproto.RawRecord) (record *consensusproto.RawRecordWithId, err error) {
err = s.doClient(ctx, func(cl consensusproto.DRPCConsensusClient) error {
if record, err = cl.RecordAdd(ctx, &consensusproto.RecordAddRequest{
LogId: logId,
@ -110,30 +110,30 @@ func (s *service) AddRecord(ctx context.Context, logId []byte, clog *consensuspr
return
}
func (s *service) Watch(logId []byte, w Watcher) (err error) {
func (s *service) Watch(logId string, w Watcher) (err error) {
s.mu.Lock()
defer s.mu.Unlock()
if _, ok := s.watchers[string(logId)]; ok {
if _, ok := s.watchers[logId]; ok {
return ErrWatcherExists
}
s.watchers[string(logId)] = w
s.watchers[logId] = w
if s.stream != nil {
if wErr := s.stream.WatchIds([][]byte{logId}); wErr != nil {
if wErr := s.stream.WatchIds([]string{logId}); wErr != nil {
log.Warn("WatchIds error", zap.Error(wErr))
}
}
return
}
func (s *service) UnWatch(logId []byte) (err error) {
func (s *service) UnWatch(logId string) (err error) {
s.mu.Lock()
defer s.mu.Unlock()
if _, ok := s.watchers[string(logId)]; !ok {
if _, ok := s.watchers[logId]; !ok {
return ErrWatcherNotExists
}
delete(s.watchers, string(logId))
delete(s.watchers, logId)
if s.stream != nil {
if wErr := s.stream.UnwatchIds([][]byte{logId}); wErr != nil {
if wErr := s.stream.UnwatchIds([]string{logId}); wErr != nil {
log.Warn("UnWatchIds error", zap.Error(wErr))
}
}
@ -182,9 +182,9 @@ func (s *service) streamWatcher() {
// collect ids and setup stream
s.mu.Lock()
var logIds = make([][]byte, 0, len(s.watchers))
var logIds = make([]string, 0, len(s.watchers))
for id := range s.watchers {
logIds = append(logIds, []byte(id))
logIds = append(logIds, id)
}
s.stream = st
s.mu.Unlock()
@ -213,14 +213,14 @@ func (s *service) streamReader() error {
return s.stream.Err()
}
for _, e := range events {
if w, ok := s.watchers[string(e.LogId)]; ok {
if w, ok := s.watchers[e.LogId]; ok {
if e.Error == nil {
w.AddConsensusRecords(e.Records)
} else {
w.AddConsensusError(rpcerr.Err(uint64(e.Error.Error)))
}
} else {
log.Warn("received unexpected log id", zap.Binary("logId", e.LogId))
log.Warn("received unexpected log id", zap.String("logId", e.LogId))
}
}
}

View file

@ -24,13 +24,13 @@ func TestService_Watch(t *testing.T) {
t.Run("not found error", func(t *testing.T) {
fx := newFixture(t).run(t)
defer fx.Finish()
var logId = []byte{'1'}
var logId = "1"
w := &testWatcher{ready: make(chan struct{})}
require.NoError(t, fx.Watch(logId, w))
st := fx.testServer.waitStream(t)
req, err := st.Recv()
require.NoError(t, err)
assert.Equal(t, [][]byte{logId}, req.WatchIds)
assert.Equal(t, []string{logId}, req.WatchIds)
require.NoError(t, st.Send(&consensusproto.LogWatchEvent{
LogId: logId,
Error: &consensusproto.Err{
@ -44,7 +44,7 @@ func TestService_Watch(t *testing.T) {
t.Run("watcherExists error", func(t *testing.T) {
fx := newFixture(t).run(t)
defer fx.Finish()
var logId = []byte{'1'}
var logId = "1"
w := &testWatcher{}
require.NoError(t, fx.Watch(logId, w))
require.Error(t, fx.Watch(logId, w))
@ -55,20 +55,20 @@ func TestService_Watch(t *testing.T) {
t.Run("watch", func(t *testing.T) {
fx := newFixture(t).run(t)
defer fx.Finish()
var logId1 = []byte{'1'}
var logId1 = "1"
w := &testWatcher{}
require.NoError(t, fx.Watch(logId1, w))
st := fx.testServer.waitStream(t)
req, err := st.Recv()
require.NoError(t, err)
assert.Equal(t, [][]byte{logId1}, req.WatchIds)
assert.Equal(t, []string{logId1}, req.WatchIds)
var logId2 = []byte{'2'}
var logId2 = "2"
w = &testWatcher{}
require.NoError(t, fx.Watch(logId2, w))
req, err = st.Recv()
require.NoError(t, err)
assert.Equal(t, [][]byte{logId2}, req.WatchIds)
assert.Equal(t, []string{logId2}, req.WatchIds)
fx.testServer.releaseStream <- nil
})
@ -78,14 +78,14 @@ func TestService_UnWatch(t *testing.T) {
t.Run("no watcher", func(t *testing.T) {
fx := newFixture(t).run(t)
defer fx.Finish()
require.Error(t, fx.UnWatch([]byte{'1'}))
require.Error(t, fx.UnWatch("1"))
})
t.Run("success", func(t *testing.T) {
fx := newFixture(t).run(t)
defer fx.Finish()
w := &testWatcher{}
require.NoError(t, fx.Watch([]byte{'1'}, w))
assert.NoError(t, fx.UnWatch([]byte{'1'}))
require.NoError(t, fx.Watch("1", w))
assert.NoError(t, fx.UnWatch("1"))
})
}
@ -119,7 +119,7 @@ func TestService_AddLog(t *testing.T) {
func TestService_AddRecord(t *testing.T) {
fx := newFixture(t).run(t)
defer fx.Finish()
rec, err := fx.AddRecord(ctx, []byte{'1'}, &consensusproto.RawRecord{})
rec, err := fx.AddRecord(ctx, "1", &consensusproto.RawRecord{})
require.NoError(t, err)
assert.NotEmpty(t, rec)
}

View file

@ -23,13 +23,13 @@ type stream struct {
err error
}
func (s *stream) WatchIds(logIds [][]byte) (err error) {
func (s *stream) WatchIds(logIds []string) (err error) {
return s.rpcStream.Send(&consensusproto.LogWatchRequest{
WatchIds: logIds,
})
}
func (s *stream) UnwatchIds(logIds [][]byte) (err error) {
func (s *stream) UnwatchIds(logIds []string) (err error) {
return s.rpcStream.Send(&consensusproto.LogWatchRequest{
UnwatchIds: logIds,
})

View file

@ -57,7 +57,7 @@ func (ErrCodes) EnumDescriptor() ([]byte, []int) {
}
type Log struct {
Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Payload []byte `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"`
Records []*RawRecordWithId `protobuf:"bytes,3,rep,name=records,proto3" json:"records,omitempty"`
}
@ -95,11 +95,11 @@ func (m *Log) XXX_DiscardUnknown() {
var xxx_messageInfo_Log proto.InternalMessageInfo
func (m *Log) GetId() []byte {
func (m *Log) GetId() string {
if m != nil {
return m.Id
}
return nil
return ""
}
func (m *Log) GetPayload() []byte {
@ -388,7 +388,7 @@ func (m *LogAddRequest) GetLog() *Log {
}
type RecordAddRequest struct {
LogId []byte `protobuf:"bytes,1,opt,name=logId,proto3" json:"logId,omitempty"`
LogId string `protobuf:"bytes,1,opt,name=logId,proto3" json:"logId,omitempty"`
Record *RawRecord `protobuf:"bytes,2,opt,name=record,proto3" json:"record,omitempty"`
}
@ -425,11 +425,11 @@ func (m *RecordAddRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_RecordAddRequest proto.InternalMessageInfo
func (m *RecordAddRequest) GetLogId() []byte {
func (m *RecordAddRequest) GetLogId() string {
if m != nil {
return m.LogId
}
return nil
return ""
}
func (m *RecordAddRequest) GetRecord() *RawRecord {
@ -440,8 +440,8 @@ func (m *RecordAddRequest) GetRecord() *RawRecord {
}
type LogWatchRequest struct {
WatchIds [][]byte `protobuf:"bytes,1,rep,name=watchIds,proto3" json:"watchIds,omitempty"`
UnwatchIds [][]byte `protobuf:"bytes,2,rep,name=unwatchIds,proto3" json:"unwatchIds,omitempty"`
WatchIds []string `protobuf:"bytes,1,rep,name=watchIds,proto3" json:"watchIds,omitempty"`
UnwatchIds []string `protobuf:"bytes,2,rep,name=unwatchIds,proto3" json:"unwatchIds,omitempty"`
}
func (m *LogWatchRequest) Reset() { *m = LogWatchRequest{} }
@ -477,14 +477,14 @@ func (m *LogWatchRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_LogWatchRequest proto.InternalMessageInfo
func (m *LogWatchRequest) GetWatchIds() [][]byte {
func (m *LogWatchRequest) GetWatchIds() []string {
if m != nil {
return m.WatchIds
}
return nil
}
func (m *LogWatchRequest) GetUnwatchIds() [][]byte {
func (m *LogWatchRequest) GetUnwatchIds() []string {
if m != nil {
return m.UnwatchIds
}
@ -492,7 +492,7 @@ func (m *LogWatchRequest) GetUnwatchIds() [][]byte {
}
type LogWatchEvent struct {
LogId []byte `protobuf:"bytes,1,opt,name=logId,proto3" json:"logId,omitempty"`
LogId string `protobuf:"bytes,1,opt,name=logId,proto3" json:"logId,omitempty"`
Records []*RawRecordWithId `protobuf:"bytes,2,rep,name=records,proto3" json:"records,omitempty"`
Error *Err `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"`
}
@ -530,11 +530,11 @@ func (m *LogWatchEvent) XXX_DiscardUnknown() {
var xxx_messageInfo_LogWatchEvent proto.InternalMessageInfo
func (m *LogWatchEvent) GetLogId() []byte {
func (m *LogWatchEvent) GetLogId() string {
if m != nil {
return m.LogId
}
return nil
return ""
}
func (m *LogWatchEvent) GetRecords() []*RawRecordWithId {
@ -614,46 +614,46 @@ func init() {
}
var fileDescriptor_b8d7f1c16b400059 = []byte{
// 618 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcf, 0x6e, 0xd3, 0x4e,
0x10, 0xce, 0xda, 0x6d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5d, 0xb8,
0xe4, 0xfc, 0xc2, 0x25, 0x3f, 0x2e, 0x5c, 0xf2, 0xe5, 0xd2, 0xad, 0x9c, 0x5f, 0xba, 0x95, 0xef,
0x97, 0x6e, 0xe5, 0xad, 0x33, 0xef, 0x7b, 0xf8, 0xa1, 0xaa, 0xff, 0x1e, 0xfd, 0x0e, 0x00, 0x00,
0xff, 0xff, 0xbc, 0x83, 0xcb, 0xc1, 0x32, 0x05, 0x00, 0x00,
// 617 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcb, 0x6e, 0xd3, 0x4c,
0x14, 0xce, 0xd8, 0x6d, 0x1a, 0x9f, 0xfc, 0x4d, 0xfd, 0x1f, 0x10, 0x32, 0x11, 0x75, 0x23, 0x4b,
0x48, 0xa1, 0x42, 0x29, 0x04, 0x81, 0x84, 0xba, 0x82, 0x2a, 0x48, 0x91, 0x42, 0x8b, 0x8c, 0x50,
0x25, 0xd8, 0x60, 0x3c, 0x53, 0xd7, 0x34, 0xf5, 0x84, 0x99, 0x49, 0x2f, 0xcf, 0xc0, 0x86, 0x17,
0xe0, 0x7d, 0x58, 0x76, 0xc9, 0x12, 0xb5, 0x1b, 0x1e, 0x80, 0x07, 0x40, 0x19, 0xc7, 0x8e, 0x9b,
0x0b, 0x88, 0x4d, 0x32, 0xe7, 0x3b, 0xb7, 0xef, 0x7c, 0xe7, 0xc8, 0xb0, 0x15, 0xf2, 0x44, 0xb2,
0x44, 0x0e, 0xe5, 0xe4, 0x35, 0x10, 0x5c, 0xf1, 0x2d, 0xfd, 0x5b, 0x40, 0x5b, 0x1a, 0xc0, 0x5a,
0x0e, 0xbc, 0x1a, 0xd9, 0xde, 0x47, 0x30, 0x7b, 0x3c, 0xc2, 0x1a, 0x18, 0x31, 0x75, 0x48, 0x83,
0x34, 0x2d, 0xdf, 0x88, 0x29, 0x3a, 0xb0, 0x32, 0x08, 0xce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x64, 0xca, 0xfe, 0x65, 0xb6,
0x7f, 0x12, 0xb0, 0x76, 0x32, 0x12, 0xb8, 0x0d, 0xe5, 0xf4, 0x30, 0x70, 0x7d, 0xce, 0x11, 0x4c,
0xb6, 0x5e, 0xc7, 0x69, 0xf7, 0xde, 0x11, 0xee, 0x82, 0x95, 0x5f, 0x07, 0x36, 0x66, 0x54, 0x9c,
0x3a, 0x9c, 0xfa, 0xdf, 0x74, 0xc6, 0x5d, 0xa8, 0x64, 0x0b, 0xc4, 0x8d, 0x39, 0x74, 0x8a, 0xa7,
0x52, 0x5f, 0x5f, 0x14, 0xa0, 0x77, 0xdf, 0x24, 0x0f, 0xc8, 0xf3, 0xf6, 0xb7, 0x4b, 0x97, 0x5c,
0x5c, 0xba, 0xe4, 0xc7, 0xa5, 0x4b, 0xbe, 0x5c, 0xb9, 0xa5, 0x8b, 0x2b, 0xb7, 0xf4, 0xfd, 0xca,
0x2d, 0xbd, 0x75, 0x16, 0x7d, 0x0f, 0x3f, 0x94, 0xf5, 0xdf, 0xa3, 0xdf, 0x01, 0x00, 0x00, 0xff,
0xff, 0xa3, 0xfa, 0x07, 0x78, 0x32, 0x05, 0x00, 0x00,
}
func (m *Log) Marshal() (dAtA []byte, err error) {
@ -1215,14 +1215,14 @@ func (m *LogWatchRequest) Size() (n int) {
var l int
_ = l
if len(m.WatchIds) > 0 {
for _, b := range m.WatchIds {
l = len(b)
for _, s := range m.WatchIds {
l = len(s)
n += 1 + l + sovConsensus(uint64(l))
}
}
if len(m.UnwatchIds) > 0 {
for _, b := range m.UnwatchIds {
l = len(b)
for _, s := range m.UnwatchIds {
l = len(s)
n += 1 + l + sovConsensus(uint64(l))
}
}
@ -1303,7 +1303,7 @@ func (m *Log) Unmarshal(dAtA []byte) error {
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType)
}
var byteLen int
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsensus
@ -1313,25 +1313,23 @@ func (m *Log) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthConsensus
}
postIndex := iNdEx + byteLen
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthConsensus
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Id = append(m.Id[:0], dAtA[iNdEx:postIndex]...)
if m.Id == nil {
m.Id = []byte{}
}
m.Id = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
@ -2062,7 +2060,7 @@ func (m *RecordAddRequest) Unmarshal(dAtA []byte) error {
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field LogId", wireType)
}
var byteLen int
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsensus
@ -2072,25 +2070,23 @@ func (m *RecordAddRequest) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthConsensus
}
postIndex := iNdEx + byteLen
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthConsensus
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.LogId = append(m.LogId[:0], dAtA[iNdEx:postIndex]...)
if m.LogId == nil {
m.LogId = []byte{}
}
m.LogId = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
@ -2182,7 +2178,7 @@ func (m *LogWatchRequest) Unmarshal(dAtA []byte) error {
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field WatchIds", wireType)
}
var byteLen int
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsensus
@ -2192,29 +2188,29 @@ func (m *LogWatchRequest) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthConsensus
}
postIndex := iNdEx + byteLen
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthConsensus
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.WatchIds = append(m.WatchIds, make([]byte, postIndex-iNdEx))
copy(m.WatchIds[len(m.WatchIds)-1], dAtA[iNdEx:postIndex])
m.WatchIds = append(m.WatchIds, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field UnwatchIds", wireType)
}
var byteLen int
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsensus
@ -2224,23 +2220,23 @@ func (m *LogWatchRequest) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthConsensus
}
postIndex := iNdEx + byteLen
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthConsensus
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.UnwatchIds = append(m.UnwatchIds, make([]byte, postIndex-iNdEx))
copy(m.UnwatchIds[len(m.UnwatchIds)-1], dAtA[iNdEx:postIndex])
m.UnwatchIds = append(m.UnwatchIds, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
default:
iNdEx = preIndex
@ -2296,7 +2292,7 @@ func (m *LogWatchEvent) Unmarshal(dAtA []byte) error {
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field LogId", wireType)
}
var byteLen int
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowConsensus
@ -2306,25 +2302,23 @@ func (m *LogWatchEvent) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= int(b&0x7F) << shift
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthConsensus
}
postIndex := iNdEx + byteLen
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthConsensus
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.LogId = append(m.LogId[:0], dAtA[iNdEx:postIndex]...)
if m.LogId == nil {
m.LogId = []byte{}
}
m.LogId = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {

View file

@ -13,7 +13,7 @@ enum ErrCodes {
message Log {
bytes id = 1;
string id = 1;
bytes payload = 2;
repeated RawRecordWithId records = 3;
}
@ -57,17 +57,17 @@ message LogAddRequest {
}
message RecordAddRequest {
bytes logId = 1;
string logId = 1;
RawRecord record = 2;
}
message LogWatchRequest {
repeated bytes watchIds = 1;
repeated bytes unwatchIds = 2;
repeated string watchIds = 1;
repeated string unwatchIds = 2;
}
message LogWatchEvent {
bytes logId = 1;
string logId = 1;
repeated RawRecordWithId records = 2;
Err error = 3;
}