[#45] api-go: Add PutSingle response wrappers
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
2cb57a8835
commit
d5b55d0926
7 changed files with 124 additions and 0 deletions
|
@ -2114,3 +2114,58 @@ func (r *PutSingleRequest) FromGRPCMessage(m grpc.Message) error {
|
|||
|
||||
return r.RequestHeaders.FromMessage(v)
|
||||
}
|
||||
|
||||
func (r *PutSingleResponseBody) ToGRPCMessage() grpc.Message {
|
||||
var b *object.PutSingleResponse_Body
|
||||
if r != nil {
|
||||
b = new(object.PutSingleResponse_Body)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (r *PutSingleResponseBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*object.PutSingleResponse_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *PutSingleResponse) ToGRPCMessage() grpc.Message {
|
||||
var m *object.PutSingleResponse
|
||||
|
||||
if r != nil {
|
||||
m = new(object.PutSingleResponse)
|
||||
|
||||
m.SetBody(r.body.ToGRPCMessage().(*object.PutSingleResponse_Body))
|
||||
r.ResponseHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *PutSingleResponse) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*object.PutSingleResponse)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
body := v.GetBody()
|
||||
if body == nil {
|
||||
r.body = nil
|
||||
} else {
|
||||
if r.body == nil {
|
||||
r.body = new(PutSingleResponseBody)
|
||||
}
|
||||
|
||||
err = r.body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return r.ResponseHeaders.FromMessage(v)
|
||||
}
|
||||
|
|
|
@ -520,3 +520,18 @@ func (m *PutSingleRequest) SetMetaHeader(v *session.RequestMetaHeader) {
|
|||
func (m *PutSingleRequest) SetVerifyHeader(v *session.RequestVerificationHeader) {
|
||||
m.VerifyHeader = v
|
||||
}
|
||||
|
||||
// SetBody sets body of the response.
|
||||
func (m *PutSingleResponse) SetBody(b *PutSingleResponse_Body) {
|
||||
m.Body = b
|
||||
}
|
||||
|
||||
// SetMetaHeader sets meta header of the response.
|
||||
func (m *PutSingleResponse) SetMetaHeader(v *session.ResponseMetaHeader) {
|
||||
m.MetaHeader = v
|
||||
}
|
||||
|
||||
// SetVerifyHeader sets verification header of the response.
|
||||
func (m *PutSingleResponse) SetVerifyHeader(v *session.ResponseVerificationHeader) {
|
||||
m.VerifyHeader = v
|
||||
}
|
||||
|
|
|
@ -1098,3 +1098,23 @@ func (r *PutSingleRequestBody) StableSize() int {
|
|||
func (r *PutSingleRequestBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(r, data, new(object.PutSingleRequest_Body))
|
||||
}
|
||||
|
||||
func (r *PutSingleResponseBody) StableMarshal(buf []byte) []byte {
|
||||
if r == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, r.StableSize())
|
||||
}
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (r *PutSingleResponseBody) StableSize() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (r *PutSingleResponseBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(r, data, new(object.PutSingleResponse_Body))
|
||||
}
|
||||
|
|
|
@ -52,5 +52,6 @@ func TestMessageConvert(t *testing.T) {
|
|||
func(empty bool) message.Message { return objecttest.GenerateGetRangeHashResponse(empty) },
|
||||
func(empty bool) message.Message { return objecttest.GenerateLock(empty) },
|
||||
func(empty bool) message.Message { return objecttest.GeneratePutSingleRequest(empty) },
|
||||
func(empty bool) message.Message { return objecttest.GeneratePutSingleResponse(empty) },
|
||||
)
|
||||
}
|
||||
|
|
|
@ -632,3 +632,13 @@ func GeneratePutSingleRequestBody(empty bool) *object.PutSingleRequestBody {
|
|||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func GeneratePutSingleResponse(empty bool) *object.PutSingleResponse {
|
||||
m := new(object.PutSingleResponse)
|
||||
if !empty {
|
||||
m.SetBody(new(object.PutSingleResponseBody))
|
||||
}
|
||||
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
||||
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
||||
return m
|
||||
}
|
||||
|
|
|
@ -312,6 +312,15 @@ type PutSingleRequest struct {
|
|||
session.RequestHeaders
|
||||
}
|
||||
|
||||
type PutSingleResponseBody struct {
|
||||
}
|
||||
|
||||
type PutSingleResponse struct {
|
||||
body *PutSingleResponseBody
|
||||
|
||||
session.ResponseHeaders
|
||||
}
|
||||
|
||||
const (
|
||||
TypeRegular Type = iota
|
||||
TypeTombstone
|
||||
|
@ -1450,3 +1459,15 @@ func (b *PutSingleRequestBody) GetCopiesNumber() []uint32 {
|
|||
func (b *PutSingleRequestBody) SetCopiesNumber(v []uint32) {
|
||||
b.copyNum = v
|
||||
}
|
||||
|
||||
func (r *PutSingleResponse) GetBody() *PutSingleResponseBody {
|
||||
if r != nil {
|
||||
return r.body
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *PutSingleResponse) SetBody(v *PutSingleResponseBody) {
|
||||
r.body = v
|
||||
}
|
||||
|
|
|
@ -89,6 +89,8 @@ func serviceMessageBody(req any) stableMarshaler {
|
|||
return v.GetBody()
|
||||
case *object.PutSingleRequest:
|
||||
return v.GetBody()
|
||||
case *object.PutSingleResponse:
|
||||
return v.GetBody()
|
||||
|
||||
/* Netmap */
|
||||
case *netmap.LocalNodeInfoRequest:
|
||||
|
|
Loading…
Reference in a new issue