frostfs-api-go-pogpp/v2/tombstone/convert.go
Leonard Lyubich 1031f3122e [#263] v2: Support new rpc library
Implement `message.Message` interface on all structures and use new methods
for conversion instead of functions. make `Unmarshal` and JSON methods to
use encoding functions from `message` library. Remove all per-service
clients and implement `rpc` library of the functions which execute NeoFS API
RPC through new RPC client. Remove no longer used gRPC per-service clients.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-03-17 14:03:49 +03:00

41 lines
843 B
Go

package tombstone
import (
"github.com/nspcc-dev/neofs-api-go/rpc/grpc"
"github.com/nspcc-dev/neofs-api-go/rpc/message"
"github.com/nspcc-dev/neofs-api-go/v2/refs"
tombstone "github.com/nspcc-dev/neofs-api-go/v2/tombstone/grpc"
)
func (s *Tombstone) ToGRPCMessage() grpc.Message {
var m *tombstone.Tombstone
if s != nil {
m = new(tombstone.Tombstone)
m.SetMembers(refs.ObjectIDListToGRPCMessage(s.members))
m.SetExpirationEpoch(s.exp)
m.SetSplitId(s.splitID)
}
return m
}
func (s *Tombstone) FromGRPCMessage(m grpc.Message) error {
v, ok := m.(*tombstone.Tombstone)
if !ok {
return message.NewUnexpectedMessageType(m, v)
}
var err error
s.members, err = refs.ObjectIDListFromGRPCMessage(v.GetMembers())
if err != nil {
return err
}
s.exp = v.GetExpirationEpoch()
s.splitID = v.GetSplitId()
return nil
}