Method to take raw client (#388)

close #379
This commit is contained in:
Roman Khimov 2023-04-15 14:29:38 +03:00 committed by GitHub
commit 3d42ae62d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View file

@ -8,6 +8,7 @@ import (
"github.com/google/uuid"
sessionv2 "github.com/nspcc-dev/neofs-api-go/v2/session"
"github.com/nspcc-dev/neofs-sdk-go/accounting"
sdkClient "github.com/nspcc-dev/neofs-sdk-go/client"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
"github.com/nspcc-dev/neofs-sdk-go/container"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
@ -187,3 +188,7 @@ func (m *mockClient) restartIfUnhealthy(ctx context.Context) (healthy bool, chan
}
return
}
func (m *mockClient) getClient() (*sdkClient.Client, error) {
return nil, errors.New("now supported to return sdkClient from mockClient")
}

View file

@ -76,6 +76,8 @@ type client interface {
dial(ctx context.Context) error
// see clientWrapper.restartIfUnhealthy.
restartIfUnhealthy(ctx context.Context) (bool, bool)
getClient() (*sdkClient.Client, error)
}
// clientStatus provide access to some metrics for connection.
@ -2104,6 +2106,16 @@ func (p *Pool) DeleteObject(ctx context.Context, prm PrmObjectDelete) error {
})
}
// RawClient returns single client instance to have possibility to work with exact one.
func (p *Pool) RawClient() (*sdkClient.Client, error) {
conn, err := p.connection()
if err != nil {
return nil, err
}
return conn.getClient()
}
type objectReadCloser struct {
reader *sdkClient.ObjectReader
elapsedTimeCallback func(time.Duration)