2021-06-09 15:37:03 +00:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
2024-11-07 14:32:10 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/grpc"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
2021-06-09 15:37:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type requestWrapper struct {
|
|
|
|
message.Message
|
|
|
|
m grpc.Message
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *requestWrapper) ToGRPCMessage() grpc.Message {
|
|
|
|
return w.m
|
|
|
|
}
|
|
|
|
|
2023-04-25 12:09:20 +00:00
|
|
|
type responseWrapper[M grpc.Message] struct {
|
|
|
|
m M
|
2021-06-09 15:37:03 +00:00
|
|
|
}
|
|
|
|
|
2023-04-25 12:09:20 +00:00
|
|
|
func (w *responseWrapper[M]) ToGRPCMessage() grpc.Message {
|
2021-06-09 15:37:03 +00:00
|
|
|
return w.m
|
|
|
|
}
|
|
|
|
|
2023-04-25 12:09:20 +00:00
|
|
|
func (w *responseWrapper[M]) FromGRPCMessage(m grpc.Message) error {
|
2021-06-09 15:37:03 +00:00
|
|
|
var ok bool
|
|
|
|
|
2023-04-25 12:09:20 +00:00
|
|
|
w.m, ok = m.(M)
|
2021-06-09 15:37:03 +00:00
|
|
|
if !ok {
|
|
|
|
return message.NewUnexpectedMessageType(m, w.m)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|