[#132] Update NeoFS SDK to v1.0.0-rc.3

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-03-16 11:10:56 +03:00 committed by Kirillov Denis
parent acd8bbb34b
commit 6d362894ad
7 changed files with 29 additions and 29 deletions

2
app.go
View file

@ -25,7 +25,7 @@ import (
type ( type (
app struct { app struct {
log *zap.Logger log *zap.Logger
pool pool.Pool pool *pool.Pool
cfg *viper.Viper cfg *viper.Viper
auxiliaryLog logger.Logger auxiliaryLog logger.Logger
webServer *fasthttp.Server webServer *fasthttp.Server

View file

@ -84,7 +84,7 @@ func readContentType(maxSize uint64, rInit func(uint64) (io.Reader, error)) (str
return http.DetectContentType(buf), buf, err // to not lose io.EOF return http.DetectContentType(buf), buf, err // to not lose io.EOF
} }
func (r request) receiveFile(clnt pool.Object, objectAddress *address.Address) { func (r request) receiveFile(clnt *pool.Pool, objectAddress *address.Address) {
var ( var (
err error err error
dis = "inline" dis = "inline"
@ -229,7 +229,7 @@ func (r *request) handleNeoFSErr(err error, start time.Time) {
// Downloader is a download request handler. // Downloader is a download request handler.
type Downloader struct { type Downloader struct {
log *zap.Logger log *zap.Logger
pool pool.Pool pool *pool.Pool
settings Settings settings Settings
} }
@ -238,7 +238,7 @@ type Settings struct {
} }
// New creates an instance of Downloader using specified options. // New creates an instance of Downloader using specified options.
func New(log *zap.Logger, settings Settings, conns pool.Pool) (*Downloader, error) { func New(log *zap.Logger, settings Settings, conns *pool.Pool) (*Downloader, error) {
var err error var err error
d := &Downloader{log: log, pool: conns, settings: settings} d := &Downloader{log: log, pool: conns, settings: settings}
if err != nil { if err != nil {
@ -261,7 +261,7 @@ func (d *Downloader) DownloadByAddress(c *fasthttp.RequestCtx) {
// byAddress is wrapper for function (e.g. request.headObject, request.receiveFile) that // byAddress is wrapper for function (e.g. request.headObject, request.receiveFile) that
// prepares request and object address to it. // prepares request and object address to it.
func (d *Downloader) byAddress(c *fasthttp.RequestCtx, f func(request, pool.Object, *address.Address)) { func (d *Downloader) byAddress(c *fasthttp.RequestCtx, f func(request, *pool.Pool, *address.Address)) {
var ( var (
addr = address.NewAddress() addr = address.NewAddress()
idCnr, _ = c.UserValue("cid").(string) idCnr, _ = c.UserValue("cid").(string)
@ -284,7 +284,7 @@ func (d *Downloader) DownloadByAttribute(c *fasthttp.RequestCtx) {
} }
// byAttribute is wrapper similar to byAddress. // byAttribute is wrapper similar to byAddress.
func (d *Downloader) byAttribute(c *fasthttp.RequestCtx, f func(request, pool.Object, *address.Address)) { func (d *Downloader) byAttribute(c *fasthttp.RequestCtx, f func(request, *pool.Pool, *address.Address)) {
var ( var (
httpStatus = fasthttp.StatusBadRequest httpStatus = fasthttp.StatusBadRequest
scid, _ = c.UserValue("cid").(string) scid, _ = c.UserValue("cid").(string)

View file

@ -25,7 +25,7 @@ const (
hdrContainerID = "X-Container-Id" hdrContainerID = "X-Container-Id"
) )
func (r request) headObject(clnt pool.Object, objectAddress *address.Address) { func (r request) headObject(clnt *pool.Pool, objectAddress *address.Address) {
var start = time.Now() var start = time.Now()
if err := tokens.StoreBearerToken(r.RequestCtx); err != nil { if err := tokens.StoreBearerToken(r.RequestCtx); err != nil {
r.log.Error("could not fetch and store bearer token", zap.Error(err)) r.log.Error("could not fetch and store bearer token", zap.Error(err))

4
go.mod
View file

@ -9,8 +9,8 @@ require (
github.com/gorilla/mux v1.8.0 // indirect github.com/gorilla/mux v1.8.0 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/nspcc-dev/neo-go v0.98.0 github.com/nspcc-dev/neo-go v0.98.0
github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220302134950-d065453bd0a7 github.com/nspcc-dev/neofs-api-go/v2 v2.12.1
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.2 github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3
github.com/prometheus/client_golang v1.11.0 github.com/prometheus/client_golang v1.11.0
github.com/prometheus/common v0.29.0 github.com/prometheus/common v0.29.0
github.com/prometheus/procfs v0.7.1 // indirect github.com/prometheus/procfs v0.7.1 // indirect

8
go.sum
View file

@ -589,15 +589,15 @@ github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:
github.com/nspcc-dev/neo-go v0.98.0 h1:yyW4sgY88/pLf0949qmgfkQXzRKC3CI/WyhqXNnwMd8= github.com/nspcc-dev/neo-go v0.98.0 h1:yyW4sgY88/pLf0949qmgfkQXzRKC3CI/WyhqXNnwMd8=
github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM= github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220302134950-d065453bd0a7 h1:hLMvj4K9djzBg+TaeDGQWGuohzXvcThi0r0LSLhhi3M= github.com/nspcc-dev/neofs-api-go/v2 v2.12.1 h1:PVU2rLlG9S0jDe5eKyaUs4nKo/la+mN5pvz32Gib3qM=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.2-0.20220302134950-d065453bd0a7/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.12.1/go.mod h1:73j09Xa7I2zQbM3HCvAHnDHPYiiWnEHa1d6Z6RDMBLU=
github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA= github.com/nspcc-dev/neofs-crypto v0.2.0/go.mod h1:F/96fUzPM3wR+UGsPi3faVNmFlA9KAEAUQR7dMxZmNA=
github.com/nspcc-dev/neofs-crypto v0.2.3/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw= github.com/nspcc-dev/neofs-crypto v0.2.3/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw=
github.com/nspcc-dev/neofs-crypto v0.3.0 h1:zlr3pgoxuzrmGCxc5W8dGVfA9Rro8diFvVnBg0L4ifM= github.com/nspcc-dev/neofs-crypto v0.3.0 h1:zlr3pgoxuzrmGCxc5W8dGVfA9Rro8diFvVnBg0L4ifM=
github.com/nspcc-dev/neofs-crypto v0.3.0/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw= github.com/nspcc-dev/neofs-crypto v0.3.0/go.mod h1:8w16GEJbH6791ktVqHN9YRNH3s9BEEKYxGhlFnp0cDw=
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211201182451-a5b61c4f6477/go.mod h1:dfMtQWmBHYpl9Dez23TGtIUKiFvCIxUZq/CkSIhEpz4= github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211201182451-a5b61c4f6477/go.mod h1:dfMtQWmBHYpl9Dez23TGtIUKiFvCIxUZq/CkSIhEpz4=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.2 h1:m+em1eyrYFIGUdzs2asDCJH0GVWH+9rYdjLTO42mxSY= github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3 h1:ofaiKPYY67a0cQMF+YSChDO48SBQtWlpZnK++cAeqQM=
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.2/go.mod h1:bkVH6yZXH5/F2Sut20SDOlQbveBlaVJ0vOX20tLGnZw= github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3/go.mod h1:0hTXmyJnbw8j4BR1oltN7mFIIrVp1IFLdh8qBzAR464=
github.com/nspcc-dev/rfc6979 v0.1.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= github.com/nspcc-dev/rfc6979 v0.1.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=
github.com/nspcc-dev/rfc6979 v0.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE= github.com/nspcc-dev/rfc6979 v0.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE=
github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=

View file

@ -72,7 +72,7 @@ func runServer() context.CancelFunc {
return cancel return cancel
} }
func simplePut(ctx context.Context, t *testing.T, clientPool pool.Pool, CID *cid.ID) { func simplePut(ctx context.Context, t *testing.T, clientPool *pool.Pool, CID *cid.ID) {
content := "content of file" content := "content of file"
keyAttr, valAttr := "User-Attribute", "user value" keyAttr, valAttr := "User-Attribute", "user value"
@ -132,7 +132,7 @@ func simplePut(ctx context.Context, t *testing.T, clientPool pool.Pool, CID *cid
} }
} }
func simpleGet(ctx context.Context, t *testing.T, clientPool pool.Pool, CID *cid.ID) { func simpleGet(ctx context.Context, t *testing.T, clientPool *pool.Pool, CID *cid.ID) {
content := "content of file" content := "content of file"
attributes := map[string]string{ attributes := map[string]string{
"some-attr": "some-get-value", "some-attr": "some-get-value",
@ -156,7 +156,7 @@ func simpleGet(ctx context.Context, t *testing.T, clientPool pool.Pool, CID *cid
} }
} }
func getByAttr(ctx context.Context, t *testing.T, clientPool pool.Pool, CID *cid.ID) { func getByAttr(ctx context.Context, t *testing.T, clientPool *pool.Pool, CID *cid.ID) {
keyAttr, valAttr := "some-attr", "some-get-by-attr-value" keyAttr, valAttr := "some-attr", "some-get-by-attr-value"
content := "content of file" content := "content of file"
attributes := map[string]string{keyAttr: valAttr} attributes := map[string]string{keyAttr: valAttr}
@ -185,7 +185,7 @@ func getByAttr(ctx context.Context, t *testing.T, clientPool pool.Pool, CID *cid
} }
} }
func getZip(ctx context.Context, t *testing.T, clientPool pool.Pool, CID *cid.ID) { func getZip(ctx context.Context, t *testing.T, clientPool *pool.Pool, CID *cid.ID) {
names := []string{"zipfolder/dir/name1.txt", "zipfolder/name2.txt"} names := []string{"zipfolder/dir/name1.txt", "zipfolder/name2.txt"}
contents := []string{"content of file1", "content of file2"} contents := []string{"content of file1", "content of file2"}
attributes1 := map[string]string{object.AttributeFileName: names[0]} attributes1 := map[string]string{object.AttributeFileName: names[0]}
@ -271,7 +271,7 @@ func getDefaultConfig() *viper.Viper {
return v return v
} }
func getPool(ctx context.Context, t *testing.T, key *keys.PrivateKey) pool.Pool { func getPool(ctx context.Context, t *testing.T, key *keys.PrivateKey) *pool.Pool {
pb := new(pool.Builder) pb := new(pool.Builder)
pb.AddNode("localhost:8080", 1, 1) pb.AddNode("localhost:8080", 1, 1)
@ -285,7 +285,7 @@ func getPool(ctx context.Context, t *testing.T, key *keys.PrivateKey) pool.Pool
return clientPool return clientPool
} }
func createContainer(ctx context.Context, t *testing.T, clientPool pool.Pool) (*cid.ID, error) { func createContainer(ctx context.Context, t *testing.T, clientPool *pool.Pool) (*cid.ID, error) {
pp, err := policy.Parse("REP 1") pp, err := policy.Parse("REP 1")
require.NoError(t, err) require.NoError(t, err)
@ -310,17 +310,17 @@ func createContainer(ctx context.Context, t *testing.T, clientPool pool.Pool) (*
return CID, err return CID, err
} }
func putObject(ctx context.Context, t *testing.T, clientPool pool.Pool, CID *cid.ID, content string, attributes map[string]string) *oid.ID { func putObject(ctx context.Context, t *testing.T, clientPool *pool.Pool, CID *cid.ID, content string, attributes map[string]string) *oid.ID {
obj := object.New() obj := object.New()
obj.SetContainerID(CID) obj.SetContainerID(CID)
obj.SetOwnerID(clientPool.OwnerID()) obj.SetOwnerID(clientPool.OwnerID())
var attrs []*object.Attribute var attrs []object.Attribute
for key, val := range attributes { for key, val := range attributes {
attr := object.NewAttribute() attr := object.NewAttribute()
attr.SetKey(key) attr.SetKey(key)
attr.SetValue(val) attr.SetValue(val)
attrs = append(attrs, attr) attrs = append(attrs, *attr)
} }
obj.SetAttributes(attrs...) obj.SetAttributes(attrs...)

View file

@ -34,7 +34,7 @@ const (
// Uploader is an upload request handler. // Uploader is an upload request handler.
type Uploader struct { type Uploader struct {
log *zap.Logger log *zap.Logger
pool pool.Pool pool *pool.Pool
enableDefaultTimestamp bool enableDefaultTimestamp bool
} }
@ -46,7 +46,7 @@ type epochDurations struct {
// New creates a new Uploader using specified logger, connection pool and // New creates a new Uploader using specified logger, connection pool and
// other options. // other options.
func New(log *zap.Logger, conns pool.Pool, enableDefaultTimestamp bool) *Uploader { func New(log *zap.Logger, conns *pool.Pool, enableDefaultTimestamp bool) *Uploader {
return &Uploader{log, conns, enableDefaultTimestamp} return &Uploader{log, conns, enableDefaultTimestamp}
} }
@ -107,27 +107,27 @@ func (u *Uploader) Upload(c *fasthttp.RequestCtx) {
} }
} }
attributes := make([]*object.Attribute, 0, len(filtered)) attributes := make([]object.Attribute, 0, len(filtered))
// prepares attributes from filtered headers // prepares attributes from filtered headers
for key, val := range filtered { for key, val := range filtered {
attribute := object.NewAttribute() attribute := object.NewAttribute()
attribute.SetKey(key) attribute.SetKey(key)
attribute.SetValue(val) attribute.SetValue(val)
attributes = append(attributes, attribute) attributes = append(attributes, *attribute)
} }
// sets FileName attribute if it wasn't set from header // sets FileName attribute if it wasn't set from header
if _, ok := filtered[object.AttributeFileName]; !ok { if _, ok := filtered[object.AttributeFileName]; !ok {
filename := object.NewAttribute() filename := object.NewAttribute()
filename.SetKey(object.AttributeFileName) filename.SetKey(object.AttributeFileName)
filename.SetValue(file.FileName()) filename.SetValue(file.FileName())
attributes = append(attributes, filename) attributes = append(attributes, *filename)
} }
// sets Timestamp attribute if it wasn't set from header and enabled by settings // sets Timestamp attribute if it wasn't set from header and enabled by settings
if _, ok := filtered[object.AttributeTimestamp]; !ok && u.enableDefaultTimestamp { if _, ok := filtered[object.AttributeTimestamp]; !ok && u.enableDefaultTimestamp {
timestamp := object.NewAttribute() timestamp := object.NewAttribute()
timestamp.SetKey(object.AttributeTimestamp) timestamp.SetKey(object.AttributeTimestamp)
timestamp.SetValue(strconv.FormatInt(time.Now().Unix(), 10)) timestamp.SetValue(strconv.FormatInt(time.Now().Unix(), 10))
attributes = append(attributes, timestamp) attributes = append(attributes, *timestamp)
} }
id, bt := u.fetchOwnerAndBearerToken(c) id, bt := u.fetchOwnerAndBearerToken(c)
@ -197,7 +197,7 @@ func (pr *putResponse) encode(w io.Writer) error {
return enc.Encode(pr) return enc.Encode(pr)
} }
func getEpochDurations(ctx context.Context, p pool.Pool) (*epochDurations, error) { func getEpochDurations(ctx context.Context, p *pool.Pool) (*epochDurations, error) {
if conn, _, err := p.Connection(); err != nil { if conn, _, err := p.Connection(); err != nil {
return nil, err return nil, err
} else if networkInfoRes, err := conn.NetworkInfo(ctx, client.PrmNetworkInfo{}); err != nil { } else if networkInfoRes, err := conn.NetworkInfo(ctx, client.PrmNetworkInfo{}); err != nil {