[#279] pool: Count errors in object search
Signed-off-by: Marina Biryukova <m.biryukova@yadro.com>
This commit is contained in:
parent
05aa3becae
commit
5361f0eceb
2 changed files with 12 additions and 5 deletions
|
@ -220,7 +220,7 @@ func (x *ObjectListReader) Close() (*ResObjectSearch, error) {
|
||||||
defer x.cancelCtxStream()
|
defer x.cancelCtxStream()
|
||||||
|
|
||||||
if x.err != nil && !errors.Is(x.err, io.EOF) {
|
if x.err != nil && !errors.Is(x.err, io.EOF) {
|
||||||
return nil, x.err
|
return &x.res, x.err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &x.res, nil
|
return &x.res, nil
|
||||||
|
|
13
pool/pool.go
13
pool/pool.go
|
@ -1092,7 +1092,7 @@ func (c *clientWrapper) objectSearch(ctx context.Context, prm PrmObjectSearch) (
|
||||||
return ResObjectSearch{}, fmt.Errorf("init object searching on client: %w", err)
|
return ResObjectSearch{}, fmt.Errorf("init object searching on client: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResObjectSearch{r: res}, nil
|
return ResObjectSearch{r: res, handleError: c.handleError}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// sessionCreate invokes sdkClient.SessionCreate parse response status to error and return result as is.
|
// sessionCreate invokes sdkClient.SessionCreate parse response status to error and return result as is.
|
||||||
|
@ -1278,7 +1278,7 @@ func needCountError(ctx context.Context, err error) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if errors.Is(ctx.Err(), context.Canceled) {
|
if ctx != nil && errors.Is(ctx.Err(), context.Canceled) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2765,17 +2765,24 @@ func (p *Pool) ObjectRange(ctx context.Context, prm PrmObjectRange) (ResObjectRa
|
||||||
// Must be initialized using Pool.SearchObjects, any other usage is unsafe.
|
// Must be initialized using Pool.SearchObjects, any other usage is unsafe.
|
||||||
type ResObjectSearch struct {
|
type ResObjectSearch struct {
|
||||||
r *sdkClient.ObjectListReader
|
r *sdkClient.ObjectListReader
|
||||||
|
handleError func(context.Context, apistatus.Status, error) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read reads another list of the object identifiers.
|
// Read reads another list of the object identifiers.
|
||||||
func (x *ResObjectSearch) Read(buf []oid.ID) (int, error) {
|
func (x *ResObjectSearch) Read(buf []oid.ID) (int, error) {
|
||||||
n, ok := x.r.Read(buf)
|
n, ok := x.r.Read(buf)
|
||||||
if !ok {
|
if !ok {
|
||||||
_, err := x.r.Close()
|
res, err := x.r.Close()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return n, io.EOF
|
return n, io.EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var status apistatus.Status
|
||||||
|
if res != nil {
|
||||||
|
status = res.Status()
|
||||||
|
}
|
||||||
|
err = x.handleError(nil, status, err)
|
||||||
|
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue