diff --git a/storagegroup/convert.go b/storagegroup/convert.go deleted file mode 100644 index 898d493..0000000 --- a/storagegroup/convert.go +++ /dev/null @@ -1,59 +0,0 @@ -package storagegroup - -import ( - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs" - refsGRPC "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/grpc" - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/grpc" - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message" - sg "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup/grpc" -) - -func (s *StorageGroup) ToGRPCMessage() grpc.Message { - m := new(sg.StorageGroup) - - if s != nil { - m = new(sg.StorageGroup) - - m.SetMembers(refs.ObjectIDListToGRPCMessage(s.members)) - //nolint:staticcheck - m.SetExpirationEpoch(s.exp) - m.SetValidationDataSize(s.size) - m.SetValidationHash(s.hash.ToGRPCMessage().(*refsGRPC.Checksum)) - } - - return m -} - -func (s *StorageGroup) FromGRPCMessage(m grpc.Message) error { - v, ok := m.(*sg.StorageGroup) - if !ok { - return message.NewUnexpectedMessageType(m, v) - } - - var err error - - hash := v.GetValidationHash() - if hash == nil { - s.hash = nil - } else { - if s.hash == nil { - s.hash = new(refs.Checksum) - } - - err = s.hash.FromGRPCMessage(hash) - if err != nil { - return err - } - } - - s.members, err = refs.ObjectIDListFromGRPCMessage(v.GetMembers()) - if err != nil { - return err - } - - //nolint:staticcheck - s.exp = v.GetExpirationEpoch() - s.size = v.GetValidationDataSize() - - return nil -} diff --git a/storagegroup/grpc/types.go b/storagegroup/grpc/types.go deleted file mode 100644 index 9be5c24..0000000 --- a/storagegroup/grpc/types.go +++ /dev/null @@ -1,27 +0,0 @@ -package storagegroup - -import ( - refs "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/grpc" -) - -// SetValidationDataSize sets the total size of the payloads of the storage group. -func (m *StorageGroup) SetValidationDataSize(v uint64) { - m.ValidationDataSize = v -} - -// SetValidationHash sets total homomorphic hash of the storage group payloads. -func (m *StorageGroup) SetValidationHash(v *refs.Checksum) { - m.ValidationHash = v -} - -// SetExpirationEpoch sets number of the last epoch of the storage group lifetime. -// -// Deprecated: do not use, `expiration_epoch` field is deprecated in protocol. -func (m *StorageGroup) SetExpirationEpoch(v uint64) { - m.ExpirationEpoch = v -} - -// SetMembers sets list of the identifiers of the storage group members. -func (m *StorageGroup) SetMembers(v []*refs.ObjectID) { - m.Members = v -} diff --git a/storagegroup/grpc/types.pb.go b/storagegroup/grpc/types.pb.go deleted file mode 100644 index 75f5b46..0000000 Binary files a/storagegroup/grpc/types.pb.go and /dev/null differ diff --git a/storagegroup/json.go b/storagegroup/json.go deleted file mode 100644 index b122893..0000000 --- a/storagegroup/json.go +++ /dev/null @@ -1,14 +0,0 @@ -package storagegroup - -import ( - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message" - storagegroup "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup/grpc" -) - -func (s *StorageGroup) MarshalJSON() ([]byte, error) { - return message.MarshalJSON(s) -} - -func (s *StorageGroup) UnmarshalJSON(data []byte) error { - return message.UnmarshalJSON(s, data, new(storagegroup.StorageGroup)) -} diff --git a/storagegroup/marshal.go b/storagegroup/marshal.go deleted file mode 100644 index 3f8171a..0000000 --- a/storagegroup/marshal.go +++ /dev/null @@ -1,54 +0,0 @@ -package storagegroup - -import ( - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs" - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message" - storagegroup "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup/grpc" - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto" -) - -const ( - sizeField = 1 - hashField = 2 - expirationField = 3 - objectIDsField = 4 -) - -// StableMarshal marshals unified storage group structure in a protobuf -// compatible way without field order shuffle. -func (s *StorageGroup) StableMarshal(buf []byte) []byte { - if s == nil { - return []byte{} - } - - if buf == nil { - buf = make([]byte, s.StableSize()) - } - - var offset int - - offset += proto.UInt64Marshal(sizeField, buf[offset:], s.size) - offset += proto.NestedStructureMarshal(hashField, buf[offset:], s.hash) - offset += proto.UInt64Marshal(expirationField, buf[offset:], s.exp) - refs.ObjectIDNestedListMarshal(objectIDsField, buf[offset:], s.members) - - return buf -} - -// StableSize of storage group structure marshalled by StableMarshal function. -func (s *StorageGroup) StableSize() (size int) { - if s == nil { - return 0 - } - - size += proto.UInt64Size(sizeField, s.size) - size += proto.NestedStructureSize(hashField, s.hash) - size += proto.UInt64Size(expirationField, s.exp) - size += refs.ObjectIDNestedListSize(objectIDsField, s.members) - - return size -} - -func (s *StorageGroup) Unmarshal(data []byte) error { - return message.Unmarshal(s, data, new(storagegroup.StorageGroup)) -} diff --git a/storagegroup/message_test.go b/storagegroup/message_test.go deleted file mode 100644 index e4ed367..0000000 --- a/storagegroup/message_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package storagegroup_test - -import ( - "testing" - - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message" - messagetest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/message/test" - storagegrouptest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup/test" -) - -func TestMessageConvert(t *testing.T) { - messagetest.TestRPCMessage(t, - func(empty bool) message.Message { return storagegrouptest.GenerateStorageGroup(empty) }, - ) -} diff --git a/storagegroup/test/generate.go b/storagegroup/test/generate.go deleted file mode 100644 index b53f199..0000000 --- a/storagegroup/test/generate.go +++ /dev/null @@ -1,21 +0,0 @@ -package storagegrouptest - -import ( - refstest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/test" - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/storagegroup" -) - -func GenerateStorageGroup(empty bool) *storagegroup.StorageGroup { - m := new(storagegroup.StorageGroup) - - if !empty { - m.SetValidationDataSize(44) - //nolint:staticcheck - m.SetExpirationEpoch(55) - m.SetMembers(refstest.GenerateObjectIDs(false)) - } - - m.SetValidationHash(refstest.GenerateChecksum(empty)) - - return m -} diff --git a/storagegroup/types.go b/storagegroup/types.go deleted file mode 100644 index b5a3a5b..0000000 --- a/storagegroup/types.go +++ /dev/null @@ -1,79 +0,0 @@ -package storagegroup - -import ( - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs" -) - -// StorageGroup is a unified structure of StorageGroup -// message from proto definition. -type StorageGroup struct { - size uint64 - - hash *refs.Checksum - - exp uint64 - - members []refs.ObjectID -} - -// GetValidationDataSize of unified storage group structure. -func (s *StorageGroup) GetValidationDataSize() uint64 { - if s != nil { - return s.size - } - - return 0 -} - -// SetValidationDataSize into unified storage group structure. -func (s *StorageGroup) SetValidationDataSize(v uint64) { - s.size = v -} - -// GetValidationHash of unified storage group structure. -func (s *StorageGroup) GetValidationHash() *refs.Checksum { - if s != nil { - return s.hash - } - - return nil -} - -// SetValidationHash into unified storage group structure. -func (s *StorageGroup) SetValidationHash(v *refs.Checksum) { - s.hash = v -} - -// GetExpirationEpoch of unified storage group structure. -// -// Deprecated: Do not use. -func (s *StorageGroup) GetExpirationEpoch() uint64 { - if s != nil { - return s.exp - } - - return 0 -} - -// SetExpirationEpoch into unified storage group structure. -// -// Deprecated: Do not use. -func (s *StorageGroup) SetExpirationEpoch(v uint64) { - s.exp = v -} - -// GetMembers of unified storage group structure. Members are objects of -// storage group. -func (s *StorageGroup) GetMembers() []refs.ObjectID { - if s != nil { - return s.members - } - - return nil -} - -// SetMembers into unified storage group structure. Members are objects of -// storage group. -func (s *StorageGroup) SetMembers(v []refs.ObjectID) { - s.members = v -}