[#XX] rpc: Introduce ObjectService.Patch
method
Some checks failed
DCO action / DCO (pull_request) Failing after 51s
Tests and linters / Tests (1.19) (pull_request) Successful in 1m5s
Tests and linters / Lint (pull_request) Failing after 2m1s
Tests and linters / Tests (1.20) (pull_request) Successful in 2m3s
Tests and linters / Tests with -race (pull_request) Successful in 2m2s
Some checks failed
DCO action / DCO (pull_request) Failing after 51s
Tests and linters / Tests (1.19) (pull_request) Successful in 1m5s
Tests and linters / Lint (pull_request) Failing after 2m1s
Tests and linters / Tests (1.20) (pull_request) Successful in 2m3s
Tests and linters / Tests with -race (pull_request) Successful in 2m2s
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
66e98505ef
commit
c3e67dbf54
1 changed files with 36 additions and 0 deletions
|
@ -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