frostfs-sdk-go/api/tombstone/convert.go
Pavel Pogodaev 6ce73790ea
All checks were successful
DCO / DCO (pull_request) Successful in 38s
Tests and linters / Tests (pull_request) Successful in 1m13s
Tests and linters / Lint (pull_request) Successful in 2m36s
[#276] Merge repo with frostfs-api-go
Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
2024-10-22 14:05:12 +00:00

41 lines
897 B
Go

package tombstone
import (
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/grpc"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
tombstone "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/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
}