small refactoring
This commit is contained in:
parent
5512bd0b2f
commit
cf61136da5
1 changed files with 15 additions and 6 deletions
21
receive.go
21
receive.go
|
@ -16,25 +16,23 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api/service"
|
"github.com/nspcc-dev/neofs-api/service"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *router) receiveFile(c echo.Context) error {
|
func (r *router) receiveFile(c echo.Context) error {
|
||||||
var (
|
var (
|
||||||
|
err error
|
||||||
cid refs.CID
|
cid refs.CID
|
||||||
oid refs.ObjectID
|
oid refs.ObjectID
|
||||||
obj *object.Object
|
obj *object.Object
|
||||||
start = time.Now()
|
start = time.Now()
|
||||||
|
con *grpc.ClientConn
|
||||||
ctx = c.Request().Context()
|
ctx = c.Request().Context()
|
||||||
con, err = r.pool.getConnection(ctx)
|
|
||||||
download = c.QueryParam("download") != ""
|
download = c.QueryParam("download") != ""
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
log := r.log.With(
|
log := r.log.With(
|
||||||
zap.String("node", con.Target()),
|
// zap.String("node", con.Target()),
|
||||||
zap.String("cid", c.Param("cid")),
|
zap.String("cid", c.Param("cid")),
|
||||||
zap.String("oid", c.Param("oid")))
|
zap.String("oid", c.Param("oid")))
|
||||||
|
|
||||||
|
@ -54,9 +52,20 @@ func (r *router) receiveFile(c echo.Context) error {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ // try to connect or throw http error:
|
||||||
|
ctx, cancel := context.WithTimeout(ctx, r.timeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
if con, err = r.pool.getConnection(ctx); err != nil {
|
||||||
|
return echo.NewHTTPError(http.StatusBadRequest, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(ctx, r.timeout)
|
ctx, cancel := context.WithTimeout(ctx, r.timeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
log = log.With(zap.String("node", con.Target()))
|
||||||
|
|
||||||
req := &object.GetRequest{Address: refs.Address{ObjectID: oid, CID: cid}}
|
req := &object.GetRequest{Address: refs.Address{ObjectID: oid, CID: cid}}
|
||||||
req.SetTTL(service.SingleForwardingTTL)
|
req.SetTTL(service.SingleForwardingTTL)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue