frostfs-api-go/storagegroup/convert.go
Leonard Lyubich 49bf6b24b0 [#417] storagegroup: Mark all expiration methods as deprecated
`expiration_epoch` field of `StorageGroup` message has been marked as
deprecated in previous NeoFS API protocol's release.

Mark all method related to the field as deprecated. Leave and use them
for test purposes only.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2022-09-23 10:30:59 +04:00

59 lines
1.2 KiB
Go

package storagegroup
import (
"github.com/nspcc-dev/neofs-api-go/v2/refs"
refsGRPC "github.com/nspcc-dev/neofs-api-go/v2/refs/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/rpc/grpc"
"github.com/nspcc-dev/neofs-api-go/v2/rpc/message"
sg "github.com/nspcc-dev/neofs-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
}