2021-06-09 15:37:03 +00:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/grpc"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/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
|
|
|
|
}
|