Merge pull request #7 from nspcc-dev/fixes-around-new-layer

Fixes for new NeoFS layer client
This commit is contained in:
Evgeniy Kulikov 2020-08-03 18:22:24 +03:00 committed by GitHub
commit 06c9a126d1

View file

@ -2,6 +2,7 @@ package main
import ( import (
"context" "context"
"crypto/ecdsa"
"net" "net"
"net/http" "net/http"
"time" "time"
@ -14,9 +15,6 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
"go.uber.org/zap" "go.uber.org/zap"
"google.golang.org/grpc/keepalive" "google.golang.org/grpc/keepalive"
// should be removed in future
"github.com/minio/minio/legacy"
) )
type ( type (
@ -26,7 +24,7 @@ type (
log *zap.Logger log *zap.Logger
cfg *viper.Viper cfg *viper.Viper
tls *tlsConfig tls *tlsConfig
obj legacy.ObjectLayer obj layer.Client
api api.Handler api api.Handler
conTimeout time.Duration conTimeout time.Duration
@ -52,7 +50,8 @@ func newApp(l *zap.Logger, v *viper.Viper) *App {
cli pool.Pool cli pool.Pool
tls *tlsConfig tls *tlsConfig
caller api.Handler caller api.Handler
obj legacy.ObjectLayer obj layer.Client
key *ecdsa.PrivateKey
reBalance = defaultRebalanceTimer reBalance = defaultRebalanceTimer
conTimeout = defaultConnectTimeout conTimeout = defaultConnectTimeout
reqTimeout = defaultRequestTimeout reqTimeout = defaultRequestTimeout
@ -66,6 +65,8 @@ func newApp(l *zap.Logger, v *viper.Viper) *App {
l.Fatal("failed to initialize auth center", zap.Error(err)) l.Fatal("failed to initialize auth center", zap.Error(err))
} }
key = center.GetNeoFSPrivateKey()
if v.IsSet(cfgTLSKeyFile) && v.IsSet(cfgTLSCertFile) { if v.IsSet(cfgTLSKeyFile) && v.IsSet(cfgTLSCertFile) {
tls = &tlsConfig{ tls = &tlsConfig{
KeyFile: v.GetString(cfgTLSKeyFile), KeyFile: v.GetString(cfgTLSKeyFile),
@ -97,7 +98,7 @@ func newApp(l *zap.Logger, v *viper.Viper) *App {
Peers: fetchPeers(l, v), Peers: fetchPeers(l, v),
Logger: l, Logger: l,
PrivateKey: center.GetNeoFSPrivateKey(), PrivateKey: key,
GRPCLogger: gRPCLogger(l), GRPCLogger: gRPCLogger(l),
GRPCVerbose: v.GetBool(cfgGRPCVerbose), GRPCVerbose: v.GetBool(cfgGRPCVerbose),
@ -125,7 +126,7 @@ func newApp(l *zap.Logger, v *viper.Viper) *App {
} }
} }
if obj, err = layer.NewLayer(l, cli, center); err != nil { if obj, err = layer.NewLayer(l, cli, key); err != nil {
l.Fatal("could not prepare ObjectLayer", zap.Error(err)) l.Fatal("could not prepare ObjectLayer", zap.Error(err))
} }
@ -136,7 +137,7 @@ func newApp(l *zap.Logger, v *viper.Viper) *App {
apiParams := handler.Params{ apiParams := handler.Params{
Log: l, Log: l,
Cli: cli, Cli: cli,
Key: center.GetNeoFSPrivateKey(), Key: key,
} }
if caller, err = handler.New(ctx, apiParams); err != nil { if caller, err = handler.New(ctx, apiParams); err != nil {