From e3026d3f4c2cf6652ed8364773d5b0d0192588fe Mon Sep 17 00:00:00 2001 From: Ekaterina Lebedeva Date: Fri, 15 Nov 2024 16:25:38 +0300 Subject: [PATCH] [#291] container: Add ListStream to api Since api was moved from `TrueCloudLab/frostfs-api-go` to sdk, moving changes from TrueCloudLab/frostfs-api-go#125 here. Signed-off-by: Ekaterina Lebedeva --- api/apemanager/grpc/service_grpc.pb.go | Bin 9917 -> 10001 bytes api/container/convert.go | 135 +++++++++++++++++++++ api/container/grpc/service_frostfs.pb.go | Bin 76792 -> 95872 bytes api/container/grpc/service_frostfs_fuzz.go | 38 ++++++ api/container/grpc/service_frostfs_test.go | 20 +++ api/container/grpc/service_grpc.pb.go | Bin 11737 -> 14646 bytes api/container/marshal.go | 62 ++++++++++ api/container/types.go | 68 +++++++++++ api/object/grpc/service_grpc.pb.go | Bin 45844 -> 46656 bytes api/rpc/container.go | 25 ++++ api/signature/body.go | 4 + 11 files changed, 352 insertions(+) diff --git a/api/apemanager/grpc/service_grpc.pb.go b/api/apemanager/grpc/service_grpc.pb.go index eb11f3fde9dc04cfb3eba36f2dc60edc0e6d9d2e..bf76cc4bcd6aad2133a57f8899c801972c17956d 100644 GIT binary patch delta 265 zcmdn%JJD~$4Hia)$&7*;lk3@)Cd;#O19=xX4H*?CaoJ7YFQ^XW+H<%~o*<^ZS&Pkp z5w2Drr@G1OI4(hz^^5A@Qf9vSE|)4B+&KJJPu61N+8iguMx^z;lUGYPO`gEUI+;f_ Nj(}4(PY}};007m@NFe|K delta 215 zcmbQ}x7T;W4VKB9MAauVvuaO1#BMM-iPd&;3YY5S`C_h<~7 CCrC&D diff --git a/api/container/convert.go b/api/container/convert.go index c91bdfd..5a9a805 100644 --- a/api/container/convert.go +++ b/api/container/convert.go @@ -762,3 +762,138 @@ func (r *ListResponse) FromGRPCMessage(m grpc.Message) error { return r.ResponseHeaders.FromMessage(v) } + +func (r *ListStreamRequestBody) ToGRPCMessage() grpc.Message { + var m *container.ListStreamRequest_Body + + if r != nil { + m = new(container.ListStreamRequest_Body) + + m.SetOwnerId(r.ownerID.ToGRPCMessage().(*refsGRPC.OwnerID)) + } + + return m +} + +func (r *ListStreamRequestBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.ListStreamRequest_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + ownerID := v.GetOwnerId() + if ownerID == nil { + r.ownerID = nil + } else { + if r.ownerID == nil { + r.ownerID = new(refs.OwnerID) + } + + err = r.ownerID.FromGRPCMessage(ownerID) + } + + return err +} + +func (r *ListStreamRequest) ToGRPCMessage() grpc.Message { + var m *container.ListStreamRequest + + if r != nil { + m = new(container.ListStreamRequest) + + m.SetBody(r.body.ToGRPCMessage().(*container.ListStreamRequest_Body)) + r.RequestHeaders.ToMessage(m) + } + + return m +} + +func (r *ListStreamRequest) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.ListStreamRequest) + 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(ListStreamRequestBody) + } + + err = r.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return r.RequestHeaders.FromMessage(v) +} + +func (r *ListStreamResponseBody) ToGRPCMessage() grpc.Message { + var m *container.ListStreamResponse_Body + + if r != nil { + m = new(container.ListStreamResponse_Body) + + m.SetContainerIds(refs.ContainerIDsToGRPCMessage(r.cidList)) + } + + return m +} + +func (r *ListStreamResponseBody) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.ListStreamResponse_Body) + if !ok { + return message.NewUnexpectedMessageType(m, v) + } + + var err error + + r.cidList, err = refs.ContainerIDsFromGRPCMessage(v.GetContainerIds()) + + return err +} + +func (r *ListStreamResponse) ToGRPCMessage() grpc.Message { + var m *container.ListStreamResponse + + if r != nil { + m = new(container.ListStreamResponse) + + m.SetBody(r.body.ToGRPCMessage().(*container.ListStreamResponse_Body)) + r.ResponseHeaders.ToMessage(m) + } + + return m +} + +func (r *ListStreamResponse) FromGRPCMessage(m grpc.Message) error { + v, ok := m.(*container.ListStreamResponse) + 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(ListStreamResponseBody) + } + + err = r.body.FromGRPCMessage(body) + if err != nil { + return err + } + } + + return r.ResponseHeaders.FromMessage(v) +} diff --git a/api/container/grpc/service_frostfs.pb.go b/api/container/grpc/service_frostfs.pb.go index 07438240cec6d58629892f69a6f99c4f93142bbd..038829344fcd6129193131d9ca50dbdd823d71a7 100644 GIT binary patch delta 1411 zcmZ`&Ye@TI~*WH5B3fy_wiCS;L5&a)8RrmsMl_)FX!aroOUgLTjNg_R|2&-ZU*~*rsnW z?}O7`D#t04(ceFW+{_ckIAGGCyRwe3g!WmjjKRG@J$sH-sd2HY7klRv%=NC?n7B46 z)|N$XAaa;JpUe2w=9cgnBBroxE|pPc+1c*|#@)YrSfKmqdqNaC|9GXw6H^BXgmH@^ zldtStl0DReLLW8tEN!vXaj5QGlOao+y;eL1FCN{9ToEBRM3KLAWzwWeUG{J+tG52R ziJ}E7(mqCOc`OS_L|yt_LKMbB6Vl+zyKfLkJT8YCspWtzh1X_F`Gk;d7zml~RKYb? zi_V!(Ak;ZE8=Y&|P0m&4+=~7l4_!v>t786j41APy8$S?Tu{;*y*6PdMhV5705FBUU z9uynnfMXnfDju#ft+t#Uyek13n5}D6V@ZD#jbC+%ZJS}4#baPK$GW=>J|BlCz=%rr$IzoT*Ddx=H@PL@yXzT2nYw2WU4aj1kbX0W zbk{T3Jr#poCw61A4t(R1PvM8KFN6Wd`rOFQZX^s3<4v`IP0s$X>rBhjgS8ZI3o+D4 z5jKPYR)8?ic(SMx-LkJn7TO`*o%9C!pBwj{%V1&{B}2yBNZ^zl3m&_Sm7JpFX2}*0 zmlUg#!SER;A~|j`^COGYLYYLlVQIQtEY1+?eraX4pb;4DIe)9dkj^P3-72U$G3JS} zsVbzA3}?U1udX6NU1fyWp-PVXICgHH=qoek8oWzpME{7%V#y>dOp?bTc_Q6S`RZyB zRS~ittP_Xn4oBn2Sk*0JtQHi)vY#W$rX*u2)gU)V%=MCPl3J0Fux6|)O}y&p$EC;` zURLf{>?&WB)v~T&se)6-A<5W>DtzlXJ)yC>>10d#I|ccO(lR(&T1n$|Yt!r}Cs7OK z*hX}(wQAC!#Cu>kF$6D#Wp}QRQqYhS|09v4@ez+sS}Tg3xcGmnit`z0ZuCZ(m=>Sr z827VLB~%!WK3JQnaN$?qfc-wc5QP0iy1!B7mRJcNEH(iKvC4)HiL)7xUhVe&gD#kr z;x*lOCu8^M*w8J9osr>`IHXIAf%&%GNvNso94Xh_?cNTW9}=nveu{(FJQ-=3qh!mO z)MP8yRlv4^t1%wZtT9KOJ_4&%nJdGaW*xb;D%^``dS!*lYsVkuAN0kMWbDw?aBHHC z7Sc84rOVb-i0vs!vky{V0@w44ymL+$r--T0ehKU+@HVnVIY$5eu-K@*m|^}K1%0JR f4CaJjjq-r6%UOq!uSv JPiC?-0RY3Ab5#HU diff --git a/api/container/marshal.go b/api/container/marshal.go index 2b16669..89a6661 100644 --- a/api/container/marshal.go +++ b/api/container/marshal.go @@ -343,3 +343,65 @@ func (r *ListResponseBody) StableSize() (size int) { func (r *ListResponseBody) Unmarshal(data []byte) error { return message.Unmarshal(r, data, new(container.ListResponse_Body)) } + +func (r *ListStreamRequestBody) StableMarshal(buf []byte) []byte { + if r == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, r.StableSize()) + } + + protoutil.NestedStructureMarshal(listReqBodyOwnerField, buf, r.ownerID) + + return buf +} + +func (r *ListStreamRequestBody) StableSize() (size int) { + if r == nil { + return 0 + } + + size += protoutil.NestedStructureSize(listReqBodyOwnerField, r.ownerID) + + return size +} + +func (r *ListStreamRequestBody) Unmarshal(data []byte) error { + return message.Unmarshal(r, data, new(container.ListStreamRequest_Body)) +} + +func (r *ListStreamResponseBody) StableMarshal(buf []byte) []byte { + if r == nil { + return []byte{} + } + + if buf == nil { + buf = make([]byte, r.StableSize()) + } + + var offset int + + for i := range r.cidList { + offset += protoutil.NestedStructureMarshal(listRespBodyIDsField, buf[offset:], &r.cidList[i]) + } + + return buf +} + +func (r *ListStreamResponseBody) StableSize() (size int) { + if r == nil { + return 0 + } + + for i := range r.cidList { + size += protoutil.NestedStructureSize(listRespBodyIDsField, &r.cidList[i]) + } + + return size +} + +func (r *ListStreamResponseBody) Unmarshal(data []byte) error { + return message.Unmarshal(r, data, new(container.ListStreamResponse_Body)) +} diff --git a/api/container/types.go b/api/container/types.go index 92c4706..4da3f87 100644 --- a/api/container/types.go +++ b/api/container/types.go @@ -109,6 +109,26 @@ type ListResponse struct { session.ResponseHeaders } +type ListStreamRequestBody struct { + ownerID *refs.OwnerID +} + +type ListStreamRequest struct { + body *ListStreamRequestBody + + session.RequestHeaders +} + +type ListStreamResponseBody struct { + cidList []refs.ContainerID +} + +type ListStreamResponse struct { + body *ListStreamResponseBody + + session.ResponseHeaders +} + func (a *Attribute) GetKey() string { if a != nil { return a.key @@ -444,3 +464,51 @@ func (r *ListResponse) GetBody() *ListResponseBody { func (r *ListResponse) SetBody(v *ListResponseBody) { r.body = v } + +func (r *ListStreamRequestBody) GetOwnerID() *refs.OwnerID { + if r != nil { + return r.ownerID + } + + return nil +} + +func (r *ListStreamRequestBody) SetOwnerID(v *refs.OwnerID) { + r.ownerID = v +} + +func (r *ListStreamRequest) GetBody() *ListStreamRequestBody { + if r != nil { + return r.body + } + + return nil +} + +func (r *ListStreamRequest) SetBody(v *ListStreamRequestBody) { + r.body = v +} + +func (r *ListStreamResponseBody) GetContainerIDs() []refs.ContainerID { + if r != nil { + return r.cidList + } + + return nil +} + +func (r *ListStreamResponseBody) SetContainerIDs(v []refs.ContainerID) { + r.cidList = v +} + +func (r *ListStreamResponse) GetBody() *ListStreamResponseBody { + if r != nil { + return r.body + } + + return nil +} + +func (r *ListStreamResponse) SetBody(v *ListStreamResponseBody) { + r.body = v +} diff --git a/api/object/grpc/service_grpc.pb.go b/api/object/grpc/service_grpc.pb.go index eb53afe94b898709fcb9ea22b0fcbe53853d7f5c..2054f89a89c72e6de3fa5ff637893227f2b6a8a7 100644 GIT binary patch delta 2418 zcmbR8jOoA|rVVNw%nAy+lNF^^CJU(=O`c@!HMyx!h(!S;*r=lo6cm}fPe*m~LmjEf z{+xP1zSiVdQL2-9qkS0_CR^!70Lg`78j~k-X#!b_&4xfSu-SBSVvIIOM%-fZ!5CE_ zD^b>NvSO?`kTp@lZt}%EB_QjdozrBae2}bxh}q<(2CdD8yh%(@_ef1XkidcDrdXgd zh(+>~?yveXA|Q*EOtpY4 zgvE;e7Lys<{1p`xG7^iqIQ8{GSRpAjHBTWWH7B(sHN_e%0&}AJ=57%=MwB3PQuPJ~ z8M5lB6#hSPRCmZM{ zfgBD@O51fUCvV{5!mx3IIw)SzlawL59xR6HO(rMR>p)$FJ&EaW{;zq7Ojo&LxM)M2 zI*N-7h;V`F=4t~ImN}JW!%S~fE44QFX9dF&IHXoVv5YDu*5vncY@4^|>*KM9 t%u?%BaS1j<2e{PAtC~-ytEf|M|?4AGs delta 1977 zcmX@`hH1((rVVNwj9Qa7N~=tsl4LMBSW$4YzJU4U5E%g`1+B@6_1ZvTp~(yCRVP1G zlb9UKsR!h1Or8*XSET%1-_#!!beZ7nwOuR+3kqyvf{ja!I=C<^nCU0orKyyVj z+<0z58MyHi1$8GIX6sIVFX%P-af;&PI3YVATYmChA%n^9g|xv|ZJDS6x9Y91`DABv zU-pc|VlGa7{mB<62}7;d-27EUiV-CMJb|8vS?dM2^1Zk=*hgox947N;D}b#}$kxH> zD{HA@T*eyZ>%oovTp}|0UcM61fwfpZ6qm6oO1enKT7X?;z{d&xuS z-(+u$-$IVf%MGm{79yuHN&>7BDDC-AatwolL-pxnK=BwZLYl~JCvH|GT7GM18@{kzZPx# diff --git a/api/rpc/container.go b/api/rpc/container.go index 9ba5c99..a759bd5 100644 --- a/api/rpc/container.go +++ b/api/rpc/container.go @@ -13,6 +13,7 @@ const ( rpcContainerGet = "Get" rpcContainerDel = "Delete" rpcContainerList = "List" + rpcContainerStream = "ListStream" rpcContainerGetEACL = "GetExtendedACL" rpcContainerUsedSpace = "AnnounceUsedSpace" ) @@ -80,3 +81,27 @@ func ListContainers( return resp, nil } + +type ListStreamResponseReader struct { + r client.MessageReader +} + +func (r *ListStreamResponseReader) Read(resp *container.ListStreamResponse) error { + return r.r.ReadMessage(resp) +} + +// ListContainersStream executes ContainerService.ListStream RPC. +func ListContainersStream( + cli *client.Client, + req *container.ListStreamRequest, + opts ...client.CallOption, +) (*ListStreamResponseReader, error) { + wc, err := client.OpenServerStream(cli, common.CallMethodInfoServerStream(serviceContainer, rpcContainerStream), req, opts...) + if err != nil { + return nil, err + } + + return &ListStreamResponseReader{ + r: wc, + }, nil +} diff --git a/api/signature/body.go b/api/signature/body.go index 50a09e9..2467dc0 100644 --- a/api/signature/body.go +++ b/api/signature/body.go @@ -46,6 +46,10 @@ func serviceMessageBody(req any) stableMarshaler { return v.GetBody() case *container.ListResponse: return v.GetBody() + case *container.ListStreamRequest: + return v.GetBody() + case *container.ListStreamResponse: + return v.GetBody() /* Object */ case *object.PutRequest: