[#94] rpc: Introduce ObjectService.Patch
method
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
9b90d139c5
commit
8580b49c8d
2 changed files with 39 additions and 3 deletions
|
@ -1336,7 +1336,7 @@ func (r *PatchRequestBodyPatch) StableMarshal(buf []byte) []byte {
|
|||
|
||||
var offset int
|
||||
offset += proto.NestedStructureMarshal(patchRequestBodyPatchRangeField, buf[offset:], r.Range)
|
||||
offset += proto.BytesMarshal(patchRequestBodyPatchChunkField, buf[offset:], r.Chunk)
|
||||
proto.BytesMarshal(patchRequestBodyPatchChunkField, buf[offset:], r.Chunk)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
@ -1372,7 +1372,7 @@ func (r *PatchRequestBody) StableMarshal(buf []byte) []byte {
|
|||
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)
|
||||
proto.NestedStructureMarshal(patchRequestBodyPatchField, buf[offset:], r.Patch)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
@ -1418,7 +1418,7 @@ func (r *PatchResponseBody) StableMarshal(buf []byte) []byte {
|
|||
}
|
||||
|
||||
var offset int
|
||||
offset += proto.NestedStructureMarshal(patchResponseBodyObjectIDField, buf[offset:], r.ObjectID)
|
||||
proto.NestedStructureMarshal(patchResponseBodyObjectIDField, buf[offset:], r.ObjectID)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ const (
|
|||
rpcObjectHead = "Head"
|
||||
rpcObjectDelete = "Delete"
|
||||
rpcObjectPutSingle = "PutSingle"
|
||||
rpcObjectPatch = "Patch"
|
||||
)
|
||||
|
||||
// PutRequestWriter is an object.PutRequest
|
||||
|
@ -205,3 +206,38 @@ func PutSingleObject(
|
|||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// PatchRequestWriter is an object.PatchRequest
|
||||
// message streaming component.
|
||||
type PatchRequestWriter struct {
|
||||
wc client.MessageWriterCloser
|
||||
|
||||
resp message.Message
|
||||
}
|
||||
|
||||
// Write writes req to the stream.
|
||||
func (w *PatchRequestWriter) Write(req *object.PatchRequest) error {
|
||||
return w.wc.WriteMessage(req)
|
||||
}
|
||||
|
||||
// Close closes the stream.
|
||||
func (w *PatchRequestWriter) Close() error {
|
||||
return w.wc.Close()
|
||||
}
|
||||
|
||||
// Patch executes ObjectService.Patch RPC.
|
||||
func Patch(
|
||||
cli *client.Client,
|
||||
resp *object.PatchResponse,
|
||||
opts ...client.CallOption,
|
||||
) (*PatchRequestWriter, error) {
|
||||
wc, err := client.OpenClientStream(cli, common.CallMethodInfoClientStream(serviceObject, rpcObjectPatch), resp, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PatchRequestWriter{
|
||||
wc: wc,
|
||||
resp: resp,
|
||||
}, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue