Airat Arifullin
9b13a18aac
* Update version within go.mod; * Fix deprecated frostfs-api-go/v2 package and use frostfs-sdk-go/api instead. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
39 lines
749 B
Go
39 lines
749 B
Go
package control
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/grpc"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/message"
|
|
)
|
|
|
|
type requestWrapper struct {
|
|
message.Message
|
|
m grpc.Message
|
|
}
|
|
|
|
func (w *requestWrapper) ToGRPCMessage() grpc.Message {
|
|
return w.m
|
|
}
|
|
|
|
type responseWrapper[T grpc.Message] struct {
|
|
message *T
|
|
}
|
|
|
|
func newResponseWrapper[T grpc.Message]() *responseWrapper[T] {
|
|
return &responseWrapper[T]{
|
|
message: new(T),
|
|
}
|
|
}
|
|
|
|
func (w *responseWrapper[T]) ToGRPCMessage() grpc.Message {
|
|
return w.message
|
|
}
|
|
|
|
func (w *responseWrapper[T]) FromGRPCMessage(m grpc.Message) error {
|
|
response, ok := m.(*T)
|
|
if !ok {
|
|
return message.NewUnexpectedMessageType(m, w.message)
|
|
}
|
|
|
|
w.message = response
|
|
return nil
|
|
}
|