Compare commits
2 commits
master
...
feat/strea
Author | SHA1 | Date | |
---|---|---|---|
f85d218adc | |||
217d63099f |
12 changed files with 1881 additions and 491 deletions
|
@ -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)
|
||||
}
|
||||
|
|
769
api/container/grpc/service_frostfs.pb.go
generated
769
api/container/grpc/service_frostfs.pb.go
generated
|
@ -3155,3 +3155,772 @@ func (x *ListResponse) UnmarshalEasyJSON(in *jlexer.Lexer) {
|
|||
in.Consumed()
|
||||
}
|
||||
}
|
||||
|
||||
type ListStreamRequest_Body struct {
|
||||
OwnerId *grpc.OwnerID `json:"ownerId"`
|
||||
}
|
||||
|
||||
var (
|
||||
_ encoding.ProtoMarshaler = (*ListStreamRequest_Body)(nil)
|
||||
_ encoding.ProtoUnmarshaler = (*ListStreamRequest_Body)(nil)
|
||||
_ json.Marshaler = (*ListStreamRequest_Body)(nil)
|
||||
_ json.Unmarshaler = (*ListStreamRequest_Body)(nil)
|
||||
)
|
||||
|
||||
// StableSize returns the size of x in protobuf format.
|
||||
//
|
||||
// Structures with the same field values have the same binary size.
|
||||
func (x *ListStreamRequest_Body) StableSize() (size int) {
|
||||
if x == nil {
|
||||
return 0
|
||||
}
|
||||
size += proto.NestedStructureSize(1, x.OwnerId)
|
||||
return size
|
||||
}
|
||||
|
||||
// MarshalProtobuf implements the encoding.ProtoMarshaler interface.
|
||||
func (x *ListStreamRequest_Body) MarshalProtobuf(dst []byte) []byte {
|
||||
m := pool.MarshalerPool.Get()
|
||||
defer pool.MarshalerPool.Put(m)
|
||||
x.EmitProtobuf(m.MessageMarshaler())
|
||||
dst = m.Marshal(dst)
|
||||
return dst
|
||||
}
|
||||
|
||||
func (x *ListStreamRequest_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) {
|
||||
if x == nil {
|
||||
return
|
||||
}
|
||||
if x.OwnerId != nil {
|
||||
x.OwnerId.EmitProtobuf(mm.AppendMessage(1))
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface.
|
||||
func (x *ListStreamRequest_Body) UnmarshalProtobuf(src []byte) (err error) {
|
||||
var fc easyproto.FieldContext
|
||||
for len(src) > 0 {
|
||||
src, err = fc.NextField(src)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot read next field in %s", "ListStreamRequest_Body")
|
||||
}
|
||||
switch fc.FieldNum {
|
||||
case 1: // OwnerId
|
||||
data, ok := fc.MessageData()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "OwnerId")
|
||||
}
|
||||
x.OwnerId = new(grpc.OwnerID)
|
||||
if err := x.OwnerId.UnmarshalProtobuf(data); err != nil {
|
||||
return fmt.Errorf("unmarshal: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *ListStreamRequest_Body) GetOwnerId() *grpc.OwnerID {
|
||||
if x != nil {
|
||||
return x.OwnerId
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *ListStreamRequest_Body) SetOwnerId(v *grpc.OwnerID) {
|
||||
x.OwnerId = v
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface.
|
||||
func (x *ListStreamRequest_Body) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
x.MarshalEasyJSON(&w)
|
||||
return w.Buffer.BuildBytes(), w.Error
|
||||
}
|
||||
func (x *ListStreamRequest_Body) MarshalEasyJSON(out *jwriter.Writer) {
|
||||
if x == nil {
|
||||
out.RawString("null")
|
||||
return
|
||||
}
|
||||
first := true
|
||||
out.RawByte('{')
|
||||
{
|
||||
if !first {
|
||||
out.RawByte(',')
|
||||
} else {
|
||||
first = false
|
||||
}
|
||||
const prefix string = "\"ownerId\":"
|
||||
out.RawString(prefix)
|
||||
x.OwnerId.MarshalEasyJSON(out)
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface.
|
||||
func (x *ListStreamRequest_Body) UnmarshalJSON(data []byte) error {
|
||||
r := jlexer.Lexer{Data: data}
|
||||
x.UnmarshalEasyJSON(&r)
|
||||
return r.Error()
|
||||
}
|
||||
func (x *ListStreamRequest_Body) UnmarshalEasyJSON(in *jlexer.Lexer) {
|
||||
isTopLevel := in.IsStart()
|
||||
if in.IsNull() {
|
||||
if isTopLevel {
|
||||
in.Consumed()
|
||||
}
|
||||
in.Skip()
|
||||
return
|
||||
}
|
||||
in.Delim('{')
|
||||
for !in.IsDelim('}') {
|
||||
key := in.UnsafeFieldName(false)
|
||||
in.WantColon()
|
||||
if in.IsNull() {
|
||||
in.Skip()
|
||||
in.WantComma()
|
||||
continue
|
||||
}
|
||||
switch key {
|
||||
case "ownerId":
|
||||
{
|
||||
var f *grpc.OwnerID
|
||||
f = new(grpc.OwnerID)
|
||||
f.UnmarshalEasyJSON(in)
|
||||
x.OwnerId = f
|
||||
}
|
||||
}
|
||||
in.WantComma()
|
||||
}
|
||||
in.Delim('}')
|
||||
if isTopLevel {
|
||||
in.Consumed()
|
||||
}
|
||||
}
|
||||
|
||||
type ListStreamRequest struct {
|
||||
Body *ListStreamRequest_Body `json:"body"`
|
||||
MetaHeader *grpc1.RequestMetaHeader `json:"metaHeader"`
|
||||
VerifyHeader *grpc1.RequestVerificationHeader `json:"verifyHeader"`
|
||||
}
|
||||
|
||||
var (
|
||||
_ encoding.ProtoMarshaler = (*ListStreamRequest)(nil)
|
||||
_ encoding.ProtoUnmarshaler = (*ListStreamRequest)(nil)
|
||||
_ json.Marshaler = (*ListStreamRequest)(nil)
|
||||
_ json.Unmarshaler = (*ListStreamRequest)(nil)
|
||||
)
|
||||
|
||||
// StableSize returns the size of x in protobuf format.
|
||||
//
|
||||
// Structures with the same field values have the same binary size.
|
||||
func (x *ListStreamRequest) StableSize() (size int) {
|
||||
if x == nil {
|
||||
return 0
|
||||
}
|
||||
size += proto.NestedStructureSize(1, x.Body)
|
||||
size += proto.NestedStructureSize(2, x.MetaHeader)
|
||||
size += proto.NestedStructureSize(3, x.VerifyHeader)
|
||||
return size
|
||||
}
|
||||
|
||||
// ReadSignedData fills buf with signed data of x.
|
||||
// If buffer length is less than x.SignedDataSize(), new buffer is allocated.
|
||||
//
|
||||
// Returns any error encountered which did not allow writing the data completely.
|
||||
// Otherwise, returns the buffer in which the data is written.
|
||||
//
|
||||
// Structures with the same field values have the same signed data.
|
||||
func (x *ListStreamRequest) SignedDataSize() int {
|
||||
return x.GetBody().StableSize()
|
||||
}
|
||||
|
||||
// SignedDataSize returns size of the request signed data in bytes.
|
||||
//
|
||||
// Structures with the same field values have the same signed data size.
|
||||
func (x *ListStreamRequest) ReadSignedData(buf []byte) ([]byte, error) {
|
||||
return x.GetBody().MarshalProtobuf(buf), nil
|
||||
}
|
||||
|
||||
// MarshalProtobuf implements the encoding.ProtoMarshaler interface.
|
||||
func (x *ListStreamRequest) MarshalProtobuf(dst []byte) []byte {
|
||||
m := pool.MarshalerPool.Get()
|
||||
defer pool.MarshalerPool.Put(m)
|
||||
x.EmitProtobuf(m.MessageMarshaler())
|
||||
dst = m.Marshal(dst)
|
||||
return dst
|
||||
}
|
||||
|
||||
func (x *ListStreamRequest) EmitProtobuf(mm *easyproto.MessageMarshaler) {
|
||||
if x == nil {
|
||||
return
|
||||
}
|
||||
if x.Body != nil {
|
||||
x.Body.EmitProtobuf(mm.AppendMessage(1))
|
||||
}
|
||||
if x.MetaHeader != nil {
|
||||
x.MetaHeader.EmitProtobuf(mm.AppendMessage(2))
|
||||
}
|
||||
if x.VerifyHeader != nil {
|
||||
x.VerifyHeader.EmitProtobuf(mm.AppendMessage(3))
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface.
|
||||
func (x *ListStreamRequest) UnmarshalProtobuf(src []byte) (err error) {
|
||||
var fc easyproto.FieldContext
|
||||
for len(src) > 0 {
|
||||
src, err = fc.NextField(src)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot read next field in %s", "ListStreamRequest")
|
||||
}
|
||||
switch fc.FieldNum {
|
||||
case 1: // Body
|
||||
data, ok := fc.MessageData()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "Body")
|
||||
}
|
||||
x.Body = new(ListStreamRequest_Body)
|
||||
if err := x.Body.UnmarshalProtobuf(data); err != nil {
|
||||
return fmt.Errorf("unmarshal: %w", err)
|
||||
}
|
||||
case 2: // MetaHeader
|
||||
data, ok := fc.MessageData()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "MetaHeader")
|
||||
}
|
||||
x.MetaHeader = new(grpc1.RequestMetaHeader)
|
||||
if err := x.MetaHeader.UnmarshalProtobuf(data); err != nil {
|
||||
return fmt.Errorf("unmarshal: %w", err)
|
||||
}
|
||||
case 3: // VerifyHeader
|
||||
data, ok := fc.MessageData()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "VerifyHeader")
|
||||
}
|
||||
x.VerifyHeader = new(grpc1.RequestVerificationHeader)
|
||||
if err := x.VerifyHeader.UnmarshalProtobuf(data); err != nil {
|
||||
return fmt.Errorf("unmarshal: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *ListStreamRequest) GetBody() *ListStreamRequest_Body {
|
||||
if x != nil {
|
||||
return x.Body
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *ListStreamRequest) SetBody(v *ListStreamRequest_Body) {
|
||||
x.Body = v
|
||||
}
|
||||
func (x *ListStreamRequest) GetMetaHeader() *grpc1.RequestMetaHeader {
|
||||
if x != nil {
|
||||
return x.MetaHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *ListStreamRequest) SetMetaHeader(v *grpc1.RequestMetaHeader) {
|
||||
x.MetaHeader = v
|
||||
}
|
||||
func (x *ListStreamRequest) GetVerifyHeader() *grpc1.RequestVerificationHeader {
|
||||
if x != nil {
|
||||
return x.VerifyHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *ListStreamRequest) SetVerifyHeader(v *grpc1.RequestVerificationHeader) {
|
||||
x.VerifyHeader = v
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface.
|
||||
func (x *ListStreamRequest) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
x.MarshalEasyJSON(&w)
|
||||
return w.Buffer.BuildBytes(), w.Error
|
||||
}
|
||||
func (x *ListStreamRequest) MarshalEasyJSON(out *jwriter.Writer) {
|
||||
if x == nil {
|
||||
out.RawString("null")
|
||||
return
|
||||
}
|
||||
first := true
|
||||
out.RawByte('{')
|
||||
{
|
||||
if !first {
|
||||
out.RawByte(',')
|
||||
} else {
|
||||
first = false
|
||||
}
|
||||
const prefix string = "\"body\":"
|
||||
out.RawString(prefix)
|
||||
x.Body.MarshalEasyJSON(out)
|
||||
}
|
||||
{
|
||||
if !first {
|
||||
out.RawByte(',')
|
||||
} else {
|
||||
first = false
|
||||
}
|
||||
const prefix string = "\"metaHeader\":"
|
||||
out.RawString(prefix)
|
||||
x.MetaHeader.MarshalEasyJSON(out)
|
||||
}
|
||||
{
|
||||
if !first {
|
||||
out.RawByte(',')
|
||||
} else {
|
||||
first = false
|
||||
}
|
||||
const prefix string = "\"verifyHeader\":"
|
||||
out.RawString(prefix)
|
||||
x.VerifyHeader.MarshalEasyJSON(out)
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface.
|
||||
func (x *ListStreamRequest) UnmarshalJSON(data []byte) error {
|
||||
r := jlexer.Lexer{Data: data}
|
||||
x.UnmarshalEasyJSON(&r)
|
||||
return r.Error()
|
||||
}
|
||||
func (x *ListStreamRequest) UnmarshalEasyJSON(in *jlexer.Lexer) {
|
||||
isTopLevel := in.IsStart()
|
||||
if in.IsNull() {
|
||||
if isTopLevel {
|
||||
in.Consumed()
|
||||
}
|
||||
in.Skip()
|
||||
return
|
||||
}
|
||||
in.Delim('{')
|
||||
for !in.IsDelim('}') {
|
||||
key := in.UnsafeFieldName(false)
|
||||
in.WantColon()
|
||||
if in.IsNull() {
|
||||
in.Skip()
|
||||
in.WantComma()
|
||||
continue
|
||||
}
|
||||
switch key {
|
||||
case "body":
|
||||
{
|
||||
var f *ListStreamRequest_Body
|
||||
f = new(ListStreamRequest_Body)
|
||||
f.UnmarshalEasyJSON(in)
|
||||
x.Body = f
|
||||
}
|
||||
case "metaHeader":
|
||||
{
|
||||
var f *grpc1.RequestMetaHeader
|
||||
f = new(grpc1.RequestMetaHeader)
|
||||
f.UnmarshalEasyJSON(in)
|
||||
x.MetaHeader = f
|
||||
}
|
||||
case "verifyHeader":
|
||||
{
|
||||
var f *grpc1.RequestVerificationHeader
|
||||
f = new(grpc1.RequestVerificationHeader)
|
||||
f.UnmarshalEasyJSON(in)
|
||||
x.VerifyHeader = f
|
||||
}
|
||||
}
|
||||
in.WantComma()
|
||||
}
|
||||
in.Delim('}')
|
||||
if isTopLevel {
|
||||
in.Consumed()
|
||||
}
|
||||
}
|
||||
|
||||
type ListStreamResponse_Body struct {
|
||||
ContainerIds []grpc.ContainerID `json:"containerIds"`
|
||||
}
|
||||
|
||||
var (
|
||||
_ encoding.ProtoMarshaler = (*ListStreamResponse_Body)(nil)
|
||||
_ encoding.ProtoUnmarshaler = (*ListStreamResponse_Body)(nil)
|
||||
_ json.Marshaler = (*ListStreamResponse_Body)(nil)
|
||||
_ json.Unmarshaler = (*ListStreamResponse_Body)(nil)
|
||||
)
|
||||
|
||||
// StableSize returns the size of x in protobuf format.
|
||||
//
|
||||
// Structures with the same field values have the same binary size.
|
||||
func (x *ListStreamResponse_Body) StableSize() (size int) {
|
||||
if x == nil {
|
||||
return 0
|
||||
}
|
||||
for i := range x.ContainerIds {
|
||||
size += proto.NestedStructureSizeUnchecked(1, &x.ContainerIds[i])
|
||||
}
|
||||
return size
|
||||
}
|
||||
|
||||
// MarshalProtobuf implements the encoding.ProtoMarshaler interface.
|
||||
func (x *ListStreamResponse_Body) MarshalProtobuf(dst []byte) []byte {
|
||||
m := pool.MarshalerPool.Get()
|
||||
defer pool.MarshalerPool.Put(m)
|
||||
x.EmitProtobuf(m.MessageMarshaler())
|
||||
dst = m.Marshal(dst)
|
||||
return dst
|
||||
}
|
||||
|
||||
func (x *ListStreamResponse_Body) EmitProtobuf(mm *easyproto.MessageMarshaler) {
|
||||
if x == nil {
|
||||
return
|
||||
}
|
||||
for i := range x.ContainerIds {
|
||||
x.ContainerIds[i].EmitProtobuf(mm.AppendMessage(1))
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface.
|
||||
func (x *ListStreamResponse_Body) UnmarshalProtobuf(src []byte) (err error) {
|
||||
var fc easyproto.FieldContext
|
||||
for len(src) > 0 {
|
||||
src, err = fc.NextField(src)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot read next field in %s", "ListStreamResponse_Body")
|
||||
}
|
||||
switch fc.FieldNum {
|
||||
case 1: // ContainerIds
|
||||
data, ok := fc.MessageData()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "ContainerIds")
|
||||
}
|
||||
x.ContainerIds = append(x.ContainerIds, grpc.ContainerID{})
|
||||
ff := &x.ContainerIds[len(x.ContainerIds)-1]
|
||||
if err := ff.UnmarshalProtobuf(data); err != nil {
|
||||
return fmt.Errorf("unmarshal: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *ListStreamResponse_Body) GetContainerIds() []grpc.ContainerID {
|
||||
if x != nil {
|
||||
return x.ContainerIds
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *ListStreamResponse_Body) SetContainerIds(v []grpc.ContainerID) {
|
||||
x.ContainerIds = v
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface.
|
||||
func (x *ListStreamResponse_Body) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
x.MarshalEasyJSON(&w)
|
||||
return w.Buffer.BuildBytes(), w.Error
|
||||
}
|
||||
func (x *ListStreamResponse_Body) MarshalEasyJSON(out *jwriter.Writer) {
|
||||
if x == nil {
|
||||
out.RawString("null")
|
||||
return
|
||||
}
|
||||
first := true
|
||||
out.RawByte('{')
|
||||
{
|
||||
if !first {
|
||||
out.RawByte(',')
|
||||
} else {
|
||||
first = false
|
||||
}
|
||||
const prefix string = "\"containerIds\":"
|
||||
out.RawString(prefix)
|
||||
out.RawByte('[')
|
||||
for i := range x.ContainerIds {
|
||||
if i != 0 {
|
||||
out.RawByte(',')
|
||||
}
|
||||
x.ContainerIds[i].MarshalEasyJSON(out)
|
||||
}
|
||||
out.RawByte(']')
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface.
|
||||
func (x *ListStreamResponse_Body) UnmarshalJSON(data []byte) error {
|
||||
r := jlexer.Lexer{Data: data}
|
||||
x.UnmarshalEasyJSON(&r)
|
||||
return r.Error()
|
||||
}
|
||||
func (x *ListStreamResponse_Body) UnmarshalEasyJSON(in *jlexer.Lexer) {
|
||||
isTopLevel := in.IsStart()
|
||||
if in.IsNull() {
|
||||
if isTopLevel {
|
||||
in.Consumed()
|
||||
}
|
||||
in.Skip()
|
||||
return
|
||||
}
|
||||
in.Delim('{')
|
||||
for !in.IsDelim('}') {
|
||||
key := in.UnsafeFieldName(false)
|
||||
in.WantColon()
|
||||
if in.IsNull() {
|
||||
in.Skip()
|
||||
in.WantComma()
|
||||
continue
|
||||
}
|
||||
switch key {
|
||||
case "containerIds":
|
||||
{
|
||||
var f grpc.ContainerID
|
||||
var list []grpc.ContainerID
|
||||
in.Delim('[')
|
||||
for !in.IsDelim(']') {
|
||||
f = grpc.ContainerID{}
|
||||
f.UnmarshalEasyJSON(in)
|
||||
list = append(list, f)
|
||||
in.WantComma()
|
||||
}
|
||||
x.ContainerIds = list
|
||||
in.Delim(']')
|
||||
}
|
||||
}
|
||||
in.WantComma()
|
||||
}
|
||||
in.Delim('}')
|
||||
if isTopLevel {
|
||||
in.Consumed()
|
||||
}
|
||||
}
|
||||
|
||||
type ListStreamResponse struct {
|
||||
Body *ListStreamResponse_Body `json:"body"`
|
||||
MetaHeader *grpc1.ResponseMetaHeader `json:"metaHeader"`
|
||||
VerifyHeader *grpc1.ResponseVerificationHeader `json:"verifyHeader"`
|
||||
}
|
||||
|
||||
var (
|
||||
_ encoding.ProtoMarshaler = (*ListStreamResponse)(nil)
|
||||
_ encoding.ProtoUnmarshaler = (*ListStreamResponse)(nil)
|
||||
_ json.Marshaler = (*ListStreamResponse)(nil)
|
||||
_ json.Unmarshaler = (*ListStreamResponse)(nil)
|
||||
)
|
||||
|
||||
// StableSize returns the size of x in protobuf format.
|
||||
//
|
||||
// Structures with the same field values have the same binary size.
|
||||
func (x *ListStreamResponse) StableSize() (size int) {
|
||||
if x == nil {
|
||||
return 0
|
||||
}
|
||||
size += proto.NestedStructureSize(1, x.Body)
|
||||
size += proto.NestedStructureSize(2, x.MetaHeader)
|
||||
size += proto.NestedStructureSize(3, x.VerifyHeader)
|
||||
return size
|
||||
}
|
||||
|
||||
// ReadSignedData fills buf with signed data of x.
|
||||
// If buffer length is less than x.SignedDataSize(), new buffer is allocated.
|
||||
//
|
||||
// Returns any error encountered which did not allow writing the data completely.
|
||||
// Otherwise, returns the buffer in which the data is written.
|
||||
//
|
||||
// Structures with the same field values have the same signed data.
|
||||
func (x *ListStreamResponse) SignedDataSize() int {
|
||||
return x.GetBody().StableSize()
|
||||
}
|
||||
|
||||
// SignedDataSize returns size of the request signed data in bytes.
|
||||
//
|
||||
// Structures with the same field values have the same signed data size.
|
||||
func (x *ListStreamResponse) ReadSignedData(buf []byte) ([]byte, error) {
|
||||
return x.GetBody().MarshalProtobuf(buf), nil
|
||||
}
|
||||
|
||||
// MarshalProtobuf implements the encoding.ProtoMarshaler interface.
|
||||
func (x *ListStreamResponse) MarshalProtobuf(dst []byte) []byte {
|
||||
m := pool.MarshalerPool.Get()
|
||||
defer pool.MarshalerPool.Put(m)
|
||||
x.EmitProtobuf(m.MessageMarshaler())
|
||||
dst = m.Marshal(dst)
|
||||
return dst
|
||||
}
|
||||
|
||||
func (x *ListStreamResponse) EmitProtobuf(mm *easyproto.MessageMarshaler) {
|
||||
if x == nil {
|
||||
return
|
||||
}
|
||||
if x.Body != nil {
|
||||
x.Body.EmitProtobuf(mm.AppendMessage(1))
|
||||
}
|
||||
if x.MetaHeader != nil {
|
||||
x.MetaHeader.EmitProtobuf(mm.AppendMessage(2))
|
||||
}
|
||||
if x.VerifyHeader != nil {
|
||||
x.VerifyHeader.EmitProtobuf(mm.AppendMessage(3))
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface.
|
||||
func (x *ListStreamResponse) UnmarshalProtobuf(src []byte) (err error) {
|
||||
var fc easyproto.FieldContext
|
||||
for len(src) > 0 {
|
||||
src, err = fc.NextField(src)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot read next field in %s", "ListStreamResponse")
|
||||
}
|
||||
switch fc.FieldNum {
|
||||
case 1: // Body
|
||||
data, ok := fc.MessageData()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "Body")
|
||||
}
|
||||
x.Body = new(ListStreamResponse_Body)
|
||||
if err := x.Body.UnmarshalProtobuf(data); err != nil {
|
||||
return fmt.Errorf("unmarshal: %w", err)
|
||||
}
|
||||
case 2: // MetaHeader
|
||||
data, ok := fc.MessageData()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "MetaHeader")
|
||||
}
|
||||
x.MetaHeader = new(grpc1.ResponseMetaHeader)
|
||||
if err := x.MetaHeader.UnmarshalProtobuf(data); err != nil {
|
||||
return fmt.Errorf("unmarshal: %w", err)
|
||||
}
|
||||
case 3: // VerifyHeader
|
||||
data, ok := fc.MessageData()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "VerifyHeader")
|
||||
}
|
||||
x.VerifyHeader = new(grpc1.ResponseVerificationHeader)
|
||||
if err := x.VerifyHeader.UnmarshalProtobuf(data); err != nil {
|
||||
return fmt.Errorf("unmarshal: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *ListStreamResponse) GetBody() *ListStreamResponse_Body {
|
||||
if x != nil {
|
||||
return x.Body
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *ListStreamResponse) SetBody(v *ListStreamResponse_Body) {
|
||||
x.Body = v
|
||||
}
|
||||
func (x *ListStreamResponse) GetMetaHeader() *grpc1.ResponseMetaHeader {
|
||||
if x != nil {
|
||||
return x.MetaHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *ListStreamResponse) SetMetaHeader(v *grpc1.ResponseMetaHeader) {
|
||||
x.MetaHeader = v
|
||||
}
|
||||
func (x *ListStreamResponse) GetVerifyHeader() *grpc1.ResponseVerificationHeader {
|
||||
if x != nil {
|
||||
return x.VerifyHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *ListStreamResponse) SetVerifyHeader(v *grpc1.ResponseVerificationHeader) {
|
||||
x.VerifyHeader = v
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface.
|
||||
func (x *ListStreamResponse) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
x.MarshalEasyJSON(&w)
|
||||
return w.Buffer.BuildBytes(), w.Error
|
||||
}
|
||||
func (x *ListStreamResponse) MarshalEasyJSON(out *jwriter.Writer) {
|
||||
if x == nil {
|
||||
out.RawString("null")
|
||||
return
|
||||
}
|
||||
first := true
|
||||
out.RawByte('{')
|
||||
{
|
||||
if !first {
|
||||
out.RawByte(',')
|
||||
} else {
|
||||
first = false
|
||||
}
|
||||
const prefix string = "\"body\":"
|
||||
out.RawString(prefix)
|
||||
x.Body.MarshalEasyJSON(out)
|
||||
}
|
||||
{
|
||||
if !first {
|
||||
out.RawByte(',')
|
||||
} else {
|
||||
first = false
|
||||
}
|
||||
const prefix string = "\"metaHeader\":"
|
||||
out.RawString(prefix)
|
||||
x.MetaHeader.MarshalEasyJSON(out)
|
||||
}
|
||||
{
|
||||
if !first {
|
||||
out.RawByte(',')
|
||||
} else {
|
||||
first = false
|
||||
}
|
||||
const prefix string = "\"verifyHeader\":"
|
||||
out.RawString(prefix)
|
||||
x.VerifyHeader.MarshalEasyJSON(out)
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface.
|
||||
func (x *ListStreamResponse) UnmarshalJSON(data []byte) error {
|
||||
r := jlexer.Lexer{Data: data}
|
||||
x.UnmarshalEasyJSON(&r)
|
||||
return r.Error()
|
||||
}
|
||||
func (x *ListStreamResponse) UnmarshalEasyJSON(in *jlexer.Lexer) {
|
||||
isTopLevel := in.IsStart()
|
||||
if in.IsNull() {
|
||||
if isTopLevel {
|
||||
in.Consumed()
|
||||
}
|
||||
in.Skip()
|
||||
return
|
||||
}
|
||||
in.Delim('{')
|
||||
for !in.IsDelim('}') {
|
||||
key := in.UnsafeFieldName(false)
|
||||
in.WantColon()
|
||||
if in.IsNull() {
|
||||
in.Skip()
|
||||
in.WantComma()
|
||||
continue
|
||||
}
|
||||
switch key {
|
||||
case "body":
|
||||
{
|
||||
var f *ListStreamResponse_Body
|
||||
f = new(ListStreamResponse_Body)
|
||||
f.UnmarshalEasyJSON(in)
|
||||
x.Body = f
|
||||
}
|
||||
case "metaHeader":
|
||||
{
|
||||
var f *grpc1.ResponseMetaHeader
|
||||
f = new(grpc1.ResponseMetaHeader)
|
||||
f.UnmarshalEasyJSON(in)
|
||||
x.MetaHeader = f
|
||||
}
|
||||
case "verifyHeader":
|
||||
{
|
||||
var f *grpc1.ResponseVerificationHeader
|
||||
f = new(grpc1.ResponseVerificationHeader)
|
||||
f.UnmarshalEasyJSON(in)
|
||||
x.VerifyHeader = f
|
||||
}
|
||||
}
|
||||
in.WantComma()
|
||||
}
|
||||
in.Delim('}')
|
||||
if isTopLevel {
|
||||
in.Consumed()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,3 +157,41 @@ func DoFuzzJSONListResponse(data []byte) int {
|
|||
}
|
||||
return 1
|
||||
}
|
||||
func DoFuzzProtoListStreamRequest(data []byte) int {
|
||||
msg := new(ListStreamRequest)
|
||||
if err := msg.UnmarshalProtobuf(data); err != nil {
|
||||
return 0
|
||||
}
|
||||
_ = msg.MarshalProtobuf(nil)
|
||||
return 1
|
||||
}
|
||||
func DoFuzzJSONListStreamRequest(data []byte) int {
|
||||
msg := new(ListStreamRequest)
|
||||
if err := msg.UnmarshalJSON(data); err != nil {
|
||||
return 0
|
||||
}
|
||||
_, err := msg.MarshalJSON()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return 1
|
||||
}
|
||||
func DoFuzzProtoListStreamResponse(data []byte) int {
|
||||
msg := new(ListStreamResponse)
|
||||
if err := msg.UnmarshalProtobuf(data); err != nil {
|
||||
return 0
|
||||
}
|
||||
_ = msg.MarshalProtobuf(nil)
|
||||
return 1
|
||||
}
|
||||
func DoFuzzJSONListStreamResponse(data []byte) int {
|
||||
msg := new(ListStreamResponse)
|
||||
if err := msg.UnmarshalJSON(data); err != nil {
|
||||
return 0
|
||||
}
|
||||
_, err := msg.MarshalJSON()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
|
|
@ -89,3 +89,23 @@ func FuzzJSONListResponse(f *testing.F) {
|
|||
DoFuzzJSONListResponse(data)
|
||||
})
|
||||
}
|
||||
func FuzzProtoListStreamRequest(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
DoFuzzProtoListStreamRequest(data)
|
||||
})
|
||||
}
|
||||
func FuzzJSONListStreamRequest(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
DoFuzzJSONListStreamRequest(data)
|
||||
})
|
||||
}
|
||||
func FuzzProtoListStreamResponse(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
DoFuzzProtoListStreamResponse(data)
|
||||
})
|
||||
}
|
||||
func FuzzJSONListStreamResponse(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
DoFuzzJSONListStreamResponse(data)
|
||||
})
|
||||
}
|
||||
|
|
89
api/container/grpc/service_grpc.pb.go
generated
89
api/container/grpc/service_grpc.pb.go
generated
|
@ -23,6 +23,7 @@ const (
|
|||
ContainerService_Delete_FullMethodName = "/neo.fs.v2.container.ContainerService/Delete"
|
||||
ContainerService_Get_FullMethodName = "/neo.fs.v2.container.ContainerService/Get"
|
||||
ContainerService_List_FullMethodName = "/neo.fs.v2.container.ContainerService/List"
|
||||
ContainerService_ListStream_FullMethodName = "/neo.fs.v2.container.ContainerService/ListStream"
|
||||
)
|
||||
|
||||
// ContainerServiceClient is the client API for ContainerService service.
|
||||
|
@ -64,7 +65,7 @@ type ContainerServiceClient interface {
|
|||
// - **CONTAINER_ACCESS_DENIED** (3074, SECTION_CONTAINER): \
|
||||
// access to container is denied.
|
||||
Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error)
|
||||
// Returns all owner's containers from 'Container` smart contract' storage.
|
||||
// Returns all owner's containers from `Container` smart contract storage.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
|
@ -73,6 +74,16 @@ type ContainerServiceClient interface {
|
|||
// - **CONTAINER_ACCESS_DENIED** (3074, SECTION_CONTAINER): \
|
||||
// container list access denied.
|
||||
List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error)
|
||||
// Returns all owner's containers from `Container` smart contract storage
|
||||
// via stream.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// container list has been successfully read;
|
||||
// - Common failures (SECTION_FAILURE_COMMON);
|
||||
// - **CONTAINER_ACCESS_DENIED** (3074, SECTION_CONTAINER): \
|
||||
// container list access denied.
|
||||
ListStream(ctx context.Context, in *ListStreamRequest, opts ...grpc.CallOption) (ContainerService_ListStreamClient, error)
|
||||
}
|
||||
|
||||
type containerServiceClient struct {
|
||||
|
@ -119,6 +130,38 @@ func (c *containerServiceClient) List(ctx context.Context, in *ListRequest, opts
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *containerServiceClient) ListStream(ctx context.Context, in *ListStreamRequest, opts ...grpc.CallOption) (ContainerService_ListStreamClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &ContainerService_ServiceDesc.Streams[0], ContainerService_ListStream_FullMethodName, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &containerServiceListStreamClient{stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type ContainerService_ListStreamClient interface {
|
||||
Recv() (*ListStreamResponse, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type containerServiceListStreamClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *containerServiceListStreamClient) Recv() (*ListStreamResponse, error) {
|
||||
m := new(ListStreamResponse)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// ContainerServiceServer is the server API for ContainerService service.
|
||||
// All implementations should embed UnimplementedContainerServiceServer
|
||||
// for forward compatibility
|
||||
|
@ -158,7 +201,7 @@ type ContainerServiceServer interface {
|
|||
// - **CONTAINER_ACCESS_DENIED** (3074, SECTION_CONTAINER): \
|
||||
// access to container is denied.
|
||||
Get(context.Context, *GetRequest) (*GetResponse, error)
|
||||
// Returns all owner's containers from 'Container` smart contract' storage.
|
||||
// Returns all owner's containers from `Container` smart contract storage.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
|
@ -167,6 +210,16 @@ type ContainerServiceServer interface {
|
|||
// - **CONTAINER_ACCESS_DENIED** (3074, SECTION_CONTAINER): \
|
||||
// container list access denied.
|
||||
List(context.Context, *ListRequest) (*ListResponse, error)
|
||||
// Returns all owner's containers from `Container` smart contract storage
|
||||
// via stream.
|
||||
//
|
||||
// Statuses:
|
||||
// - **OK** (0, SECTION_SUCCESS): \
|
||||
// container list has been successfully read;
|
||||
// - Common failures (SECTION_FAILURE_COMMON);
|
||||
// - **CONTAINER_ACCESS_DENIED** (3074, SECTION_CONTAINER): \
|
||||
// container list access denied.
|
||||
ListStream(*ListStreamRequest, ContainerService_ListStreamServer) error
|
||||
}
|
||||
|
||||
// UnimplementedContainerServiceServer should be embedded to have forward compatible implementations.
|
||||
|
@ -185,6 +238,9 @@ func (UnimplementedContainerServiceServer) Get(context.Context, *GetRequest) (*G
|
|||
func (UnimplementedContainerServiceServer) List(context.Context, *ListRequest) (*ListResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method List not implemented")
|
||||
}
|
||||
func (UnimplementedContainerServiceServer) ListStream(*ListStreamRequest, ContainerService_ListStreamServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method ListStream not implemented")
|
||||
}
|
||||
|
||||
// UnsafeContainerServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to ContainerServiceServer will
|
||||
|
@ -269,6 +325,27 @@ func _ContainerService_List_Handler(srv interface{}, ctx context.Context, dec fu
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ContainerService_ListStream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(ListStreamRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(ContainerServiceServer).ListStream(m, &containerServiceListStreamServer{stream})
|
||||
}
|
||||
|
||||
type ContainerService_ListStreamServer interface {
|
||||
Send(*ListStreamResponse) error
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type containerServiceListStreamServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *containerServiceListStreamServer) Send(m *ListStreamResponse) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
// ContainerService_ServiceDesc is the grpc.ServiceDesc for ContainerService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
|
@ -293,6 +370,12 @@ var ContainerService_ServiceDesc = grpc.ServiceDesc{
|
|||
Handler: _ContainerService_List_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "ListStream",
|
||||
Handler: _ContainerService_ListStream_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "api/container/grpc/service.proto",
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
52
api/object/grpc/service_grpc.pb.go
generated
52
api/object/grpc/service_grpc.pb.go
generated
|
@ -42,11 +42,11 @@ type ObjectServiceClient interface {
|
|||
// chunks keeping the receiving order.
|
||||
//
|
||||
// Extended headers can change `Get` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requsted version of Network Map for object placement
|
||||
// calculation.
|
||||
// * [ __SYSTEM__NETMAP_LOOKUP_DEPTH ] \
|
||||
// - [ __SYSTEM__NETMAP_LOOKUP_DEPTH ] \
|
||||
// (`__NEOFS__NETMAP_LOOKUP_DEPTH` is deprecated) \
|
||||
// Will try older versions (starting from `__SYSTEM__NETMAP_EPOCH`
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) if specified or the latest one
|
||||
|
@ -80,7 +80,7 @@ type ObjectServiceClient interface {
|
|||
// Chunk messages SHOULD be sent in the direct order of fragmentation.
|
||||
//
|
||||
// Extended headers can change `Put` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requsted version of Network Map for object placement
|
||||
// calculation.
|
||||
|
@ -106,6 +106,7 @@ type ObjectServiceClient interface {
|
|||
// - **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.
|
||||
|
@ -114,7 +115,7 @@ type ObjectServiceClient interface {
|
|||
// guarantee. Object will be marked for removal and deleted eventually.
|
||||
//
|
||||
// Extended headers can change `Delete` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requested version of Network Map for object placement
|
||||
// calculation.
|
||||
|
@ -144,7 +145,7 @@ type ObjectServiceClient interface {
|
|||
// the very minimal information will be returned instead.
|
||||
//
|
||||
// Extended headers can change `Head` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requested version of Network Map for object placement
|
||||
// calculation.
|
||||
|
@ -173,7 +174,7 @@ type ObjectServiceClient interface {
|
|||
// Specification section for more details.
|
||||
//
|
||||
// Extended headers can change `Search` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requested version of Network Map for object placement
|
||||
// calculation.
|
||||
|
@ -199,11 +200,11 @@ type ObjectServiceClient interface {
|
|||
// receiving order.
|
||||
//
|
||||
// Extended headers can change `GetRange` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requested version of Network Map for object placement
|
||||
// calculation.
|
||||
// * [ __SYSTEM__NETMAP_LOOKUP_DEPTH ] \
|
||||
// - [ __SYSTEM__NETMAP_LOOKUP_DEPTH ] \
|
||||
// (`__NEOFS__NETMAP_LOOKUP_DEPTH` is deprecated) \
|
||||
// Will try older versions of Network Map to find an object until the depth
|
||||
// limit is reached.
|
||||
|
@ -235,11 +236,11 @@ type ObjectServiceClient interface {
|
|||
// the request. Note that hash is calculated for XORed data.
|
||||
//
|
||||
// Extended headers can change `GetRangeHash` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requested version of Network Map for object placement
|
||||
// calculation.
|
||||
// * [ __SYSTEM__NETMAP_LOOKUP_DEPTH ] \
|
||||
// - [ __SYSTEM__NETMAP_LOOKUP_DEPTH ] \
|
||||
// (`__NEOFS__NETMAP_LOOKUP_DEPTH` is deprecated) \
|
||||
// Will try older versions of Network Map to find an object until the depth
|
||||
// limit is reached.
|
||||
|
@ -268,7 +269,7 @@ type ObjectServiceClient interface {
|
|||
// an object MUST be set.
|
||||
//
|
||||
// Extended headers can change `Put` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requested version of Network Map for object placement
|
||||
// calculation.
|
||||
|
@ -294,6 +295,7 @@ type ObjectServiceClient interface {
|
|||
// - **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.
|
||||
|
@ -317,7 +319,7 @@ type ObjectServiceClient interface {
|
|||
// 3. The application of the same patches for the object a few times.
|
||||
//
|
||||
// Extended headers can change `Patch` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requsted version of Network Map for object placement
|
||||
// calculation.
|
||||
|
@ -568,11 +570,11 @@ type ObjectServiceServer interface {
|
|||
// chunks keeping the receiving order.
|
||||
//
|
||||
// Extended headers can change `Get` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requsted version of Network Map for object placement
|
||||
// calculation.
|
||||
// * [ __SYSTEM__NETMAP_LOOKUP_DEPTH ] \
|
||||
// - [ __SYSTEM__NETMAP_LOOKUP_DEPTH ] \
|
||||
// (`__NEOFS__NETMAP_LOOKUP_DEPTH` is deprecated) \
|
||||
// Will try older versions (starting from `__SYSTEM__NETMAP_EPOCH`
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) if specified or the latest one
|
||||
|
@ -606,7 +608,7 @@ type ObjectServiceServer interface {
|
|||
// Chunk messages SHOULD be sent in the direct order of fragmentation.
|
||||
//
|
||||
// Extended headers can change `Put` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requsted version of Network Map for object placement
|
||||
// calculation.
|
||||
|
@ -632,6 +634,7 @@ type ObjectServiceServer interface {
|
|||
// - **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.
|
||||
|
@ -640,7 +643,7 @@ type ObjectServiceServer interface {
|
|||
// guarantee. Object will be marked for removal and deleted eventually.
|
||||
//
|
||||
// Extended headers can change `Delete` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requested version of Network Map for object placement
|
||||
// calculation.
|
||||
|
@ -670,7 +673,7 @@ type ObjectServiceServer interface {
|
|||
// the very minimal information will be returned instead.
|
||||
//
|
||||
// Extended headers can change `Head` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requested version of Network Map for object placement
|
||||
// calculation.
|
||||
|
@ -699,7 +702,7 @@ type ObjectServiceServer interface {
|
|||
// Specification section for more details.
|
||||
//
|
||||
// Extended headers can change `Search` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requested version of Network Map for object placement
|
||||
// calculation.
|
||||
|
@ -725,11 +728,11 @@ type ObjectServiceServer interface {
|
|||
// receiving order.
|
||||
//
|
||||
// Extended headers can change `GetRange` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requested version of Network Map for object placement
|
||||
// calculation.
|
||||
// * [ __SYSTEM__NETMAP_LOOKUP_DEPTH ] \
|
||||
// - [ __SYSTEM__NETMAP_LOOKUP_DEPTH ] \
|
||||
// (`__NEOFS__NETMAP_LOOKUP_DEPTH` is deprecated) \
|
||||
// Will try older versions of Network Map to find an object until the depth
|
||||
// limit is reached.
|
||||
|
@ -761,11 +764,11 @@ type ObjectServiceServer interface {
|
|||
// the request. Note that hash is calculated for XORed data.
|
||||
//
|
||||
// Extended headers can change `GetRangeHash` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH ] \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requested version of Network Map for object placement
|
||||
// calculation.
|
||||
// * [ __SYSTEM__NETMAP_LOOKUP_DEPTH ] \
|
||||
// - [ __SYSTEM__NETMAP_LOOKUP_DEPTH ] \
|
||||
// (`__NEOFS__NETMAP_LOOKUP_DEPTH` is deprecated) \
|
||||
// Will try older versions of Network Map to find an object until the depth
|
||||
// limit is reached.
|
||||
|
@ -794,7 +797,7 @@ type ObjectServiceServer interface {
|
|||
// an object MUST be set.
|
||||
//
|
||||
// Extended headers can change `Put` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requested version of Network Map for object placement
|
||||
// calculation.
|
||||
|
@ -820,6 +823,7 @@ type ObjectServiceServer interface {
|
|||
// - **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.
|
||||
|
@ -843,7 +847,7 @@ type ObjectServiceServer interface {
|
|||
// 3. The application of the same patches for the object a few times.
|
||||
//
|
||||
// Extended headers can change `Patch` behaviour:
|
||||
// * [ __SYSTEM__NETMAP_EPOCH \
|
||||
// - [ __SYSTEM__NETMAP_EPOCH \
|
||||
// (`__NEOFS__NETMAP_EPOCH` is deprecated) \
|
||||
// Will use the requsted version of Network Map for object placement
|
||||
// calculation.
|
||||
|
|
|
@ -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, rpcContainerList), req, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &ListStreamResponseReader{
|
||||
r: wc,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
182
client/container_list_stream.go
Normal file
182
client/container_list_stream.go
Normal file
|
@ -0,0 +1,182 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/container"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs"
|
||||
rpcapi "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/client"
|
||||
v2session "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/signature"
|
||||
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
||||
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/session"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
|
||||
)
|
||||
|
||||
// PrmContainerListStream groups parameters of ContainerListStream operation.
|
||||
type PrmContainerListStream struct {
|
||||
XHeaders []string
|
||||
|
||||
Account user.ID
|
||||
|
||||
Session *session.Container
|
||||
}
|
||||
|
||||
// SetAccount sets identifier of the FrostFS account to list the containers.
|
||||
// Required parameter.
|
||||
//
|
||||
// Deprecated: Use PrmContainerListStream.Account instead.
|
||||
func (x *PrmContainerListStream) SetAccount(id user.ID) {
|
||||
x.Account = id
|
||||
}
|
||||
|
||||
func (x *PrmContainerListStream) buildRequest(c *Client) (*container.ListStreamRequest, error) {
|
||||
if x.Account.IsEmpty() {
|
||||
return nil, errorAccountNotSet
|
||||
}
|
||||
|
||||
var ownerV2 refs.OwnerID
|
||||
x.Account.WriteToV2(&ownerV2)
|
||||
|
||||
reqBody := new(container.ListStreamRequestBody)
|
||||
reqBody.SetOwnerID(&ownerV2)
|
||||
|
||||
var meta v2session.RequestMetaHeader
|
||||
writeXHeadersToMeta(x.XHeaders, &meta)
|
||||
|
||||
if x.Session != nil {
|
||||
var tokv2 v2session.Token
|
||||
x.Session.WriteToV2(&tokv2)
|
||||
|
||||
meta.SetSessionToken(&tokv2)
|
||||
}
|
||||
|
||||
var req container.ListStreamRequest
|
||||
req.SetBody(reqBody)
|
||||
c.prepareRequest(&req, &meta)
|
||||
return &req, nil
|
||||
}
|
||||
|
||||
type ResContainerListStream struct {
|
||||
statusRes
|
||||
}
|
||||
|
||||
type ContainerListReader struct {
|
||||
client *Client
|
||||
cancelCtxStream context.CancelFunc
|
||||
err error
|
||||
res ResContainerListStream
|
||||
stream interface {
|
||||
Read(resp *container.ListStreamResponse) error
|
||||
}
|
||||
tail []refs.ContainerID
|
||||
}
|
||||
|
||||
func (x *ContainerListReader) Read(buf []cid.ID) (int, bool) {
|
||||
if len(buf) == 0 {
|
||||
panic("empty buffer in ContainerListReader.ReadList")
|
||||
}
|
||||
|
||||
read := copyCnrIDBuffers(buf, x.tail)
|
||||
x.tail = x.tail[read:]
|
||||
|
||||
if len(buf) == read {
|
||||
return read, true
|
||||
}
|
||||
|
||||
for {
|
||||
var resp container.ListStreamResponse
|
||||
x.err = x.stream.Read(&resp)
|
||||
if x.err != nil {
|
||||
return read, false
|
||||
}
|
||||
|
||||
x.res.st, x.err = x.client.processResponse(&resp)
|
||||
if x.err != nil || !apistatus.IsSuccessful(x.res.st) {
|
||||
return read, false
|
||||
}
|
||||
|
||||
// read new chunk of objects
|
||||
ids := resp.GetBody().GetContainerIDs()
|
||||
if len(ids) == 0 {
|
||||
// just skip empty lists since they are not prohibited by protocol
|
||||
continue
|
||||
}
|
||||
|
||||
ln := copyCnrIDBuffers(buf[read:], ids)
|
||||
read += ln
|
||||
|
||||
if read == len(buf) {
|
||||
// save the tail
|
||||
x.tail = append(x.tail, ids[ln:]...)
|
||||
|
||||
return read, true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func copyCnrIDBuffers(dst []cid.ID, src []refs.ContainerID) int {
|
||||
var i int
|
||||
for ; i < len(dst) && i < len(src); i++ {
|
||||
_ = dst[i].ReadFromV2(src[i])
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
func (x *ContainerListReader) Iterate(f func(cid.ID) bool) error {
|
||||
buf := make([]cid.ID, 1)
|
||||
|
||||
for {
|
||||
// Do not check first return value because `len(buf) == 1`,
|
||||
// so false means nothing was read.
|
||||
_, ok := x.Read(buf)
|
||||
if !ok {
|
||||
res, err := x.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return apistatus.ErrFromStatus(res.Status())
|
||||
}
|
||||
if f(buf[0]) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ContainerListReader) Close() (*ResContainerListStream, error) {
|
||||
defer x.cancelCtxStream()
|
||||
|
||||
if x.err != nil && !errors.Is(x.err, io.EOF) {
|
||||
return nil, x.err
|
||||
}
|
||||
|
||||
return &x.res, nil
|
||||
}
|
||||
|
||||
func (c *Client) ContainerListInit(ctx context.Context, prm PrmContainerListStream) (*ContainerListReader, error) {
|
||||
req, err := prm.buildRequest(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = signature.SignServiceMessage(&c.prm.Key, req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("sign request: %w", err)
|
||||
}
|
||||
|
||||
var r ContainerListReader
|
||||
ctx, r.cancelCtxStream = context.WithCancel(ctx)
|
||||
|
||||
r.stream, err = rpcapi.ListContainersStream(&c.c, req, client.WithContext(ctx))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("open stream: %w", err)
|
||||
}
|
||||
r.client = c
|
||||
|
||||
return &r, nil
|
||||
}
|
Loading…
Reference in a new issue