From c3e67dbf540b8180a3275b9b5d98271add56b60a Mon Sep 17 00:00:00 2001 From: Airat Arifullin Date: Wed, 24 Jul 2024 17:45:30 +0300 Subject: [PATCH] [#XX] rpc: Introduce `ObjectService.Patch` method Signed-off-by: Airat Arifullin --- rpc/object.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/rpc/object.go b/rpc/object.go index 1eca922..6d7af31 100644 --- a/rpc/object.go +++ b/rpc/object.go @@ -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 +}