forked from TrueCloudLab/frostfs-api-go
[#94] object: Generate protobufs for Patch
method
* Generate protobufs for patch method; * Create marshalers, unmarshalers, converters for gererated types; * Add unit-tests. Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
3dfa2f4fd6
commit
9b90d139c5
9 changed files with 1341 additions and 245 deletions
|
@ -2345,3 +2345,217 @@ func (r *PutSingleResponse) FromGRPCMessage(m grpc.Message) error {
|
|||
|
||||
return r.ResponseHeaders.FromMessage(v)
|
||||
}
|
||||
|
||||
func (r *PatchRequestBodyPatch) ToGRPCMessage() grpc.Message {
|
||||
var m *object.PatchRequest_Body_Patch
|
||||
|
||||
if r != nil {
|
||||
m = new(object.PatchRequest_Body_Patch)
|
||||
|
||||
m.SetSourceRange(r.Range.ToGRPCMessage().(*object.Range))
|
||||
m.SetChunk(r.Chunk)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *PatchRequestBodyPatch) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*object.PatchRequest_Body_Patch)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
srcRange := v.GetSourceRange()
|
||||
if srcRange == nil {
|
||||
r.Range = nil
|
||||
} else {
|
||||
if r.Range == nil {
|
||||
r.Range = new(Range)
|
||||
}
|
||||
|
||||
err = r.Range.FromGRPCMessage(srcRange)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
r.Chunk = v.GetChunk()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) ToGRPCMessage() grpc.Message {
|
||||
var m *object.PatchRequest_Body
|
||||
|
||||
if r != nil {
|
||||
m = new(object.PatchRequest_Body)
|
||||
|
||||
m.SetAddress(r.Address.ToGRPCMessage().(*refsGRPC.Address))
|
||||
m.SetNewAttributes(AttributesToGRPC(r.NewAttributes))
|
||||
m.SetReplaceAttributes(r.ReplaceAttributes)
|
||||
m.SetPatch(r.Patch.ToGRPCMessage().(*object.PatchRequest_Body_Patch))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*object.PatchRequest_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
addr := v.GetAddress()
|
||||
if addr == nil {
|
||||
r.Address = nil
|
||||
} else {
|
||||
if r.Address == nil {
|
||||
r.Address = new(refs.Address)
|
||||
}
|
||||
|
||||
err = r.Address.FromGRPCMessage(addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
r.NewAttributes, err = AttributesFromGRPC(v.GetNewAttributes())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
r.ReplaceAttributes = v.GetReplaceAttributes()
|
||||
|
||||
patch := v.GetPatch()
|
||||
if patch == nil {
|
||||
r.Patch = nil
|
||||
} else {
|
||||
if r.Patch == nil {
|
||||
r.Patch = new(PatchRequestBodyPatch)
|
||||
}
|
||||
|
||||
err = r.Patch.FromGRPCMessage(patch)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *PatchRequest) ToGRPCMessage() grpc.Message {
|
||||
var m *object.PatchRequest
|
||||
|
||||
if r != nil {
|
||||
m = new(object.PatchRequest)
|
||||
|
||||
m.SetBody(r.Body.ToGRPCMessage().(*object.PatchRequest_Body))
|
||||
r.RequestHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *PatchRequest) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*object.PatchRequest)
|
||||
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(PatchRequestBody)
|
||||
}
|
||||
|
||||
err = r.Body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return r.RequestHeaders.FromMessage(v)
|
||||
}
|
||||
|
||||
func (r *PatchResponseBody) ToGRPCMessage() grpc.Message {
|
||||
var m *object.PatchResponse_Body
|
||||
|
||||
if r != nil {
|
||||
m = new(object.PatchResponse_Body)
|
||||
|
||||
m.SetObjectID(r.ObjectID.ToGRPCMessage().(*refsGRPC.ObjectID))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *PatchResponseBody) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*object.PatchResponse_Body)
|
||||
if !ok {
|
||||
return message.NewUnexpectedMessageType(m, v)
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
objID := v.GetObjectId()
|
||||
if objID == nil {
|
||||
r.ObjectID = nil
|
||||
} else {
|
||||
if r.ObjectID == nil {
|
||||
r.ObjectID = new(refs.ObjectID)
|
||||
}
|
||||
|
||||
err = r.ObjectID.FromGRPCMessage(objID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *PatchResponse) ToGRPCMessage() grpc.Message {
|
||||
var m *object.PatchResponse
|
||||
|
||||
if r != nil {
|
||||
m = new(object.PatchResponse)
|
||||
|
||||
m.SetBody(r.Body.ToGRPCMessage().(*object.PatchResponse_Body))
|
||||
r.ResponseHeaders.ToMessage(m)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func (r *PatchResponse) FromGRPCMessage(m grpc.Message) error {
|
||||
v, ok := m.(*object.PatchResponse)
|
||||
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(PatchResponseBody)
|
||||
}
|
||||
|
||||
err = r.Body.FromGRPCMessage(body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return r.ResponseHeaders.FromMessage(v)
|
||||
}
|
||||
|
|
|
@ -556,3 +556,55 @@ func (m *PutSingleResponse) SetMetaHeader(v *session.ResponseMetaHeader) {
|
|||
func (m *PutSingleResponse) SetVerifyHeader(v *session.ResponseVerificationHeader) {
|
||||
m.VerifyHeader = v
|
||||
}
|
||||
|
||||
func (m *PatchRequest_Body) SetAddress(addr *refs.Address) {
|
||||
m.Address = addr
|
||||
}
|
||||
|
||||
func (m *PatchRequest_Body) SetNewAttributes(attrs []*Header_Attribute) {
|
||||
m.NewAttributes = attrs
|
||||
}
|
||||
|
||||
func (m *PatchRequest_Body) SetReplaceAttributes(replaceAttributes bool) {
|
||||
m.ReplaceAttributes = replaceAttributes
|
||||
}
|
||||
|
||||
func (m *PatchRequest_Body) SetPatch(patch *PatchRequest_Body_Patch) {
|
||||
m.Patch = patch
|
||||
}
|
||||
|
||||
func (m *PatchRequest_Body_Patch) SetSourceRange(r *Range) {
|
||||
m.SourceRange = r
|
||||
}
|
||||
|
||||
func (m *PatchRequest_Body_Patch) SetChunk(chunk []byte) {
|
||||
m.Chunk = chunk
|
||||
}
|
||||
|
||||
func (m *PatchRequest) SetBody(b *PatchRequest_Body) {
|
||||
m.Body = b
|
||||
}
|
||||
|
||||
func (m *PatchRequest) SetMetaHeader(v *session.RequestMetaHeader) {
|
||||
m.MetaHeader = v
|
||||
}
|
||||
|
||||
func (m *PatchRequest) SetVerifyHeader(v *session.RequestVerificationHeader) {
|
||||
m.VerifyHeader = v
|
||||
}
|
||||
|
||||
func (m *PatchResponse_Body) SetObjectID(objectID *refs.ObjectID) {
|
||||
m.ObjectId = objectID
|
||||
}
|
||||
|
||||
func (m *PatchResponse) SetBody(b *PatchResponse_Body) {
|
||||
m.Body = b
|
||||
}
|
||||
|
||||
func (m *PatchResponse) SetMetaHeader(v *session.ResponseMetaHeader) {
|
||||
m.MetaHeader = v
|
||||
}
|
||||
|
||||
func (m *PatchResponse) SetVerifyHeader(v *session.ResponseVerificationHeader) {
|
||||
m.VerifyHeader = v
|
||||
}
|
||||
|
|
955
object/grpc/service.pb.go
generated
955
object/grpc/service.pb.go
generated
File diff suppressed because it is too large
Load diff
157
object/grpc/service_grpc.pb.go
generated
157
object/grpc/service_grpc.pb.go
generated
|
@ -27,6 +27,7 @@ const (
|
|||
ObjectService_GetRange_FullMethodName = "/neo.fs.v2.object.ObjectService/GetRange"
|
||||
ObjectService_GetRangeHash_FullMethodName = "/neo.fs.v2.object.ObjectService/GetRangeHash"
|
||||
ObjectService_PutSingle_FullMethodName = "/neo.fs.v2.object.ObjectService/PutSingle"
|
||||
ObjectService_Patch_FullMethodName = "/neo.fs.v2.object.ObjectService/Patch"
|
||||
)
|
||||
|
||||
// ObjectServiceClient is the client API for ObjectService service.
|
||||
|
@ -299,6 +300,50 @@ type ObjectServiceClient interface {
|
|||
// - **TOKEN_EXPIRED** (4097, SECTION_SESSION): \
|
||||
// provided session token has expired.
|
||||
PutSingle(ctx context.Context, in *PutSingleRequest, opts ...grpc.CallOption) (*PutSingleResponse, error)
|
||||
// Patch the object. Request uses gRPC stream. First message must set
|
||||
// the address of the object that is going to get patched. If the object's attributes
|
||||
// are patched, then these attrubutes must be set only within the first stream message.
|
||||
//
|
||||
// If the patch request is performed by NOT the object's owner but if the actor has the permission
|
||||
// to perform the patch, then `OwnerID` of the object is changed. In this case the object's owner
|
||||
// loses the object's ownership after the patch request is successfully done.
|
||||
//
|
||||
// As objects are content-addressable the patching causes new object ID generation for the patched object.
|
||||
// This object id is set witihn `PatchResponse`. But the object id may remain unchanged in such cases:
|
||||
// 1. The chunk of the applying patch contains the same value as the object's payload within the same range;
|
||||
// 2. The patch that reverts the changes applied by preceding patch;
|
||||
// 3. The application of the same patches for the object a few times.
|
||||
//
|
||||
// Extended headers can change `Patch` behaviour:
|
||||
// - [ __SYSTEM__NETMAP_EPOCH \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requsted version of Network Map for object placement
|
||||
// calculation.
|
||||
//
|
||||
// Please refer to detailed `XHeader` description.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// object has been successfully patched and saved in the container;
|
||||
// - Common failures (SECTION_FAILURE_COMMON);
|
||||
// - **ACCESS_DENIED** (2048, SECTION_OBJECT): \
|
||||
// write access to the container is denied;
|
||||
// - **OBJECT_NOT_FOUND** (2049, SECTION_OBJECT): \
|
||||
// object not found in container;
|
||||
// - **OBJECT_ALREADY_REMOVED** (2052, SECTION_OBJECT): \
|
||||
// the requested object has been marked as deleted;
|
||||
// - **OUT_OF_RANGE** (2053, SECTION_OBJECT): \
|
||||
// the requested range is out of bounds;
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
// object storage container not found;
|
||||
// - **CONTAINER_ACCESS_DENIED** (3074, SECTION_CONTAINER): \
|
||||
// access to container is denied;
|
||||
// - **TOKEN_NOT_FOUND** (4096, SECTION_SESSION): \
|
||||
// (for trusted object preparation) session private key does not exist or
|
||||
// has been deleted;
|
||||
// - **TOKEN_EXPIRED** (4097, SECTION_SESSION): \
|
||||
// provided session token has expired.
|
||||
Patch(ctx context.Context, opts ...grpc.CallOption) (ObjectService_PatchClient, error)
|
||||
}
|
||||
|
||||
type objectServiceClient struct {
|
||||
|
@ -475,6 +520,40 @@ func (c *objectServiceClient) PutSingle(ctx context.Context, in *PutSingleReques
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *objectServiceClient) Patch(ctx context.Context, opts ...grpc.CallOption) (ObjectService_PatchClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &ObjectService_ServiceDesc.Streams[4], ObjectService_Patch_FullMethodName, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &objectServicePatchClient{stream}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type ObjectService_PatchClient interface {
|
||||
Send(*PatchRequest) error
|
||||
CloseAndRecv() (*PatchResponse, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type objectServicePatchClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *objectServicePatchClient) Send(m *PatchRequest) error {
|
||||
return x.ClientStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func (x *objectServicePatchClient) CloseAndRecv() (*PatchResponse, error) {
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
m := new(PatchResponse)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// ObjectServiceServer is the server API for ObjectService service.
|
||||
// All implementations should embed UnimplementedObjectServiceServer
|
||||
// for forward compatibility
|
||||
|
@ -745,6 +824,50 @@ type ObjectServiceServer interface {
|
|||
// - **TOKEN_EXPIRED** (4097, SECTION_SESSION): \
|
||||
// provided session token has expired.
|
||||
PutSingle(context.Context, *PutSingleRequest) (*PutSingleResponse, error)
|
||||
// Patch the object. Request uses gRPC stream. First message must set
|
||||
// the address of the object that is going to get patched. If the object's attributes
|
||||
// are patched, then these attrubutes must be set only within the first stream message.
|
||||
//
|
||||
// If the patch request is performed by NOT the object's owner but if the actor has the permission
|
||||
// to perform the patch, then `OwnerID` of the object is changed. In this case the object's owner
|
||||
// loses the object's ownership after the patch request is successfully done.
|
||||
//
|
||||
// As objects are content-addressable the patching causes new object ID generation for the patched object.
|
||||
// This object id is set witihn `PatchResponse`. But the object id may remain unchanged in such cases:
|
||||
// 1. The chunk of the applying patch contains the same value as the object's payload within the same range;
|
||||
// 2. The patch that reverts the changes applied by preceding patch;
|
||||
// 3. The application of the same patches for the object a few times.
|
||||
//
|
||||
// Extended headers can change `Patch` behaviour:
|
||||
// - [ __SYSTEM__NETMAP_EPOCH \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requsted version of Network Map for object placement
|
||||
// calculation.
|
||||
//
|
||||
// Please refer to detailed `XHeader` description.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// object has been successfully patched and saved in the container;
|
||||
// - Common failures (SECTION_FAILURE_COMMON);
|
||||
// - **ACCESS_DENIED** (2048, SECTION_OBJECT): \
|
||||
// write access to the container is denied;
|
||||
// - **OBJECT_NOT_FOUND** (2049, SECTION_OBJECT): \
|
||||
// object not found in container;
|
||||
// - **OBJECT_ALREADY_REMOVED** (2052, SECTION_OBJECT): \
|
||||
// the requested object has been marked as deleted;
|
||||
// - **OUT_OF_RANGE** (2053, SECTION_OBJECT): \
|
||||
// the requested range is out of bounds;
|
||||
// - **CONTAINER_NOT_FOUND** (3072, SECTION_CONTAINER): \
|
||||
// object storage container not found;
|
||||
// - **CONTAINER_ACCESS_DENIED** (3074, SECTION_CONTAINER): \
|
||||
// access to container is denied;
|
||||
// - **TOKEN_NOT_FOUND** (4096, SECTION_SESSION): \
|
||||
// (for trusted object preparation) session private key does not exist or
|
||||
// has been deleted;
|
||||
// - **TOKEN_EXPIRED** (4097, SECTION_SESSION): \
|
||||
// provided session token has expired.
|
||||
Patch(ObjectService_PatchServer) error
|
||||
}
|
||||
|
||||
// UnimplementedObjectServiceServer should be embedded to have forward compatible implementations.
|
||||
|
@ -775,6 +898,9 @@ func (UnimplementedObjectServiceServer) GetRangeHash(context.Context, *GetRangeH
|
|||
func (UnimplementedObjectServiceServer) PutSingle(context.Context, *PutSingleRequest) (*PutSingleResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method PutSingle not implemented")
|
||||
}
|
||||
func (UnimplementedObjectServiceServer) Patch(ObjectService_PatchServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method Patch not implemented")
|
||||
}
|
||||
|
||||
// UnsafeObjectServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to ObjectServiceServer will
|
||||
|
@ -948,6 +1074,32 @@ func _ObjectService_PutSingle_Handler(srv interface{}, ctx context.Context, dec
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ObjectService_Patch_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
return srv.(ObjectServiceServer).Patch(&objectServicePatchServer{stream})
|
||||
}
|
||||
|
||||
type ObjectService_PatchServer interface {
|
||||
SendAndClose(*PatchResponse) error
|
||||
Recv() (*PatchRequest, error)
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type objectServicePatchServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *objectServicePatchServer) SendAndClose(m *PatchResponse) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func (x *objectServicePatchServer) Recv() (*PatchRequest, error) {
|
||||
m := new(PatchRequest)
|
||||
if err := x.ServerStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// ObjectService_ServiceDesc is the grpc.ServiceDesc for ObjectService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
|
@ -993,6 +1145,11 @@ var ObjectService_ServiceDesc = grpc.ServiceDesc{
|
|||
Handler: _ObjectService_GetRange_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "Patch",
|
||||
Handler: _ObjectService_Patch_Handler,
|
||||
ClientStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "object/grpc/service.proto",
|
||||
}
|
||||
|
|
|
@ -132,6 +132,16 @@ const (
|
|||
|
||||
putSingleReqObjectField = 1
|
||||
putSingleReqCopiesNumberField = 2
|
||||
|
||||
patchRequestBodyPatchRangeField = 1
|
||||
patchRequestBodyPatchChunkField = 2
|
||||
|
||||
patchRequestBodyAddrField = 1
|
||||
patchRequestBodyNewAttrsField = 2
|
||||
patchRequestBodyReplaceAttrField = 3
|
||||
patchRequestBodyPatchField = 4
|
||||
|
||||
patchResponseBodyObjectIDField = 1
|
||||
)
|
||||
|
||||
func (h *ShortHeader) StableMarshal(buf []byte) []byte {
|
||||
|
@ -1314,3 +1324,105 @@ func (r *PutSingleResponseBody) StableSize() int {
|
|||
func (r *PutSingleResponseBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(r, data, new(object.PutSingleResponse_Body))
|
||||
}
|
||||
|
||||
func (r *PatchRequestBodyPatch) StableMarshal(buf []byte) []byte {
|
||||
if r == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, r.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
offset += proto.NestedStructureMarshal(patchRequestBodyPatchRangeField, buf[offset:], r.Range)
|
||||
offset += proto.BytesMarshal(patchRequestBodyPatchChunkField, buf[offset:], r.Chunk)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (r *PatchRequestBodyPatch) StableSize() int {
|
||||
if r == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
var size int
|
||||
size += proto.NestedStructureSize(patchRequestBodyPatchRangeField, r.Range)
|
||||
size += proto.BytesSize(patchRequestBodyPatchChunkField, r.Chunk)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (r *PatchRequestBodyPatch) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(r, data, new(object.PatchRequest_Body_Patch))
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) StableMarshal(buf []byte) []byte {
|
||||
if r == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, r.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
offset += proto.NestedStructureMarshal(patchRequestBodyAddrField, buf[offset:], r.Address)
|
||||
for i := range r.NewAttributes {
|
||||
offset += proto.NestedStructureMarshal(patchRequestBodyNewAttrsField, buf[offset:], &r.NewAttributes[i])
|
||||
}
|
||||
offset += proto.BoolMarshal(patchRequestBodyReplaceAttrField, buf[offset:], r.ReplaceAttributes)
|
||||
offset += proto.NestedStructureMarshal(patchRequestBodyPatchField, buf[offset:], r.Patch)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) StableSize() int {
|
||||
if r == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
var size int
|
||||
size += proto.NestedStructureSize(patchRequestBodyAddrField, r.Address)
|
||||
for i := range r.NewAttributes {
|
||||
size += proto.NestedStructureSize(patchRequestBodyNewAttrsField, &r.NewAttributes[i])
|
||||
}
|
||||
size += proto.BoolSize(patchRequestBodyReplaceAttrField, r.ReplaceAttributes)
|
||||
size += proto.NestedStructureSize(patchRequestBodyPatchField, r.Patch)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (r *PatchRequestBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(r, data, new(object.PatchRequest_Body))
|
||||
}
|
||||
|
||||
func (r *PatchResponseBody) StableSize() int {
|
||||
if r == nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
var size int
|
||||
size += proto.NestedStructureSize(patchResponseBodyObjectIDField, r.ObjectID)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
func (r *PatchResponseBody) StableMarshal(buf []byte) []byte {
|
||||
if r == nil {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
if buf == nil {
|
||||
buf = make([]byte, r.StableSize())
|
||||
}
|
||||
|
||||
var offset int
|
||||
offset += proto.NestedStructureMarshal(patchResponseBodyObjectIDField, buf[offset:], r.ObjectID)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
func (r *PatchResponseBody) Unmarshal(data []byte) error {
|
||||
return message.Unmarshal(r, data, new(object.PatchResponse_Body))
|
||||
}
|
||||
|
|
|
@ -56,5 +56,10 @@ func TestMessageConvert(t *testing.T) {
|
|||
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) },
|
||||
func(empty bool) message.Message { return objecttest.GeneratePatchRequestBodyPatch(empty) },
|
||||
func(empty bool) message.Message { return objecttest.GeneratePatchRequestBody(empty) },
|
||||
func(empty bool) message.Message { return objecttest.GeneratePatchRequest(empty) },
|
||||
func(empty bool) message.Message { return objecttest.GeneratePatchResponseBody(empty) },
|
||||
func(empty bool) message.Message { return objecttest.GeneratePatchResponse(empty) },
|
||||
)
|
||||
}
|
||||
|
|
|
@ -691,6 +691,63 @@ func GeneratePutSingleResponse(empty bool) *object.PutSingleResponse {
|
|||
return m
|
||||
}
|
||||
|
||||
func GeneratePatchRequestBodyPatch(empty bool) *object.PatchRequestBodyPatch {
|
||||
m := new(object.PatchRequestBodyPatch)
|
||||
|
||||
if !empty {
|
||||
m.Range = GenerateRange(false)
|
||||
m.Chunk = []byte("GeneratePatchRequestBodyPatch")
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GeneratePatchRequestBody(empty bool) *object.PatchRequestBody {
|
||||
m := new(object.PatchRequestBody)
|
||||
|
||||
if !empty {
|
||||
m.Address = refstest.GenerateAddress(empty)
|
||||
m.NewAttributes = GenerateAttributes(empty)
|
||||
m.ReplaceAttributes = false
|
||||
m.Patch = GeneratePatchRequestBodyPatch(empty)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GeneratePatchRequest(empty bool) *object.PatchRequest {
|
||||
m := new(object.PatchRequest)
|
||||
|
||||
if !empty {
|
||||
m.Body = GeneratePatchRequestBody(empty)
|
||||
}
|
||||
|
||||
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
||||
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GeneratePatchResponseBody(empty bool) *object.PatchResponseBody {
|
||||
m := new(object.PatchResponseBody)
|
||||
|
||||
if !empty {
|
||||
m.ObjectID = refstest.GenerateObjectID(empty)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func GeneratePatchResponse(empty bool) *object.PatchResponse {
|
||||
m := new(object.PatchResponse)
|
||||
|
||||
if !empty {
|
||||
m.Body = GeneratePatchResponseBody(empty)
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
func randomInt(n int) int {
|
||||
return rand.New(rand.NewSource(time.Now().UnixNano())).Intn(n)
|
||||
}
|
||||
|
|
|
@ -349,6 +349,38 @@ type PutSingleResponse struct {
|
|||
session.ResponseHeaders
|
||||
}
|
||||
|
||||
type PatchRequestBodyPatch struct {
|
||||
Range *Range
|
||||
|
||||
Chunk []byte
|
||||
}
|
||||
|
||||
type PatchRequestBody struct {
|
||||
Address *refs.Address
|
||||
|
||||
NewAttributes []Attribute
|
||||
|
||||
ReplaceAttributes bool
|
||||
|
||||
Patch *PatchRequestBodyPatch
|
||||
}
|
||||
|
||||
type PatchRequest struct {
|
||||
Body *PatchRequestBody
|
||||
|
||||
session.RequestHeaders
|
||||
}
|
||||
|
||||
type PatchResponseBody struct {
|
||||
ObjectID *refs.ObjectID
|
||||
}
|
||||
|
||||
type PatchResponse struct {
|
||||
Body *PatchResponseBody
|
||||
|
||||
session.ResponseHeaders
|
||||
}
|
||||
|
||||
const (
|
||||
TypeRegular Type = iota
|
||||
TypeTombstone
|
||||
|
|
2
util/proto/test/test.pb.go
generated
2
util/proto/test/test.pb.go
generated
|
@ -1,7 +1,7 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.33.0
|
||||
// protoc v5.27.2
|
||||
// protoc v4.25.3
|
||||
// source: util/proto/test/test.proto
|
||||
|
||||
package test
|
||||
|
|
Loading…
Reference in a new issue