Remove server aliases (#1154)

This commit is contained in:
Egon Elbre 2019-01-28 17:04:53 +02:00 committed by GitHub
parent 04d3699107
commit cecd4b0816
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 16 additions and 24 deletions

View File

@ -91,7 +91,7 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, config Config) (*P
return nil, errs.Combine(err, peer.Close())
}
peer.Public.Server, err = server.NewServer(publicOptions, peer.Public.Listener, nil)
peer.Public.Server, err = server.New(publicOptions, peer.Public.Listener, nil)
if err != nil {
return nil, errs.Combine(err, peer.Close())
}

View File

@ -28,6 +28,7 @@ import (
"storj.io/storj/pkg/identity"
"storj.io/storj/pkg/pb"
"storj.io/storj/pkg/provider"
"storj.io/storj/pkg/server"
"storj.io/storj/pkg/transport"
"storj.io/storj/pkg/utils"
"storj.io/storj/storage"
@ -668,13 +669,13 @@ func TestCertificateSigner_Sign_E2E(t *testing.T) {
t.Fatal(err)
}
serverConfig := provider.ServerConfig{Address: listener.Addr().String()}
opts, err := provider.NewServerOptions(serverIdent, serverConfig)
serverConfig := server.Config{Address: listener.Addr().String()}
opts, err := server.NewOptions(serverIdent, serverConfig)
if !assert.NoError(t, err) || !assert.NotNil(t, opts) {
t.Fatal(err)
}
service, err := provider.NewProvider(opts, listener, nil, config)
service, err := server.New(opts, listener, nil, config)
if !assert.NoError(t, err) || !assert.NotNil(t, service) {
t.Fatal(err)
}

View File

@ -13,7 +13,7 @@ import (
"storj.io/storj/pkg/identity"
"storj.io/storj/pkg/pb"
"storj.io/storj/pkg/peertls"
"storj.io/storj/pkg/provider"
"storj.io/storj/pkg/server"
"storj.io/storj/pkg/utils"
"storj.io/storj/storage/boltdb"
"storj.io/storj/storage/redis"
@ -85,7 +85,7 @@ func (c CertServerConfig) NewAuthDB() (*AuthorizationDB, error) {
}
// Run implements the responsibility interface, starting a certificate signing server.
func (c CertServerConfig) Run(ctx context.Context, server *provider.Provider) (err error) {
func (c CertServerConfig) Run(ctx context.Context, server *server.Server) (err error) {
defer mon.Task()(&ctx)(&err)
authDB, err := c.NewAuthDB()

View File

@ -597,7 +597,7 @@ func NewTest(ctx context.Context, t *testing.T, snID, upID *identity.FullIdentit
publicConfig := server.Config{Address: "127.0.0.1:0"}
publicOptions, err := server.NewOptions(snID, publicConfig)
assert.NoError(t, err)
grpcServer, err := server.NewServer(publicOptions, listener, nil)
grpcServer, err := server.New(publicOptions, listener, nil)
assert.NoError(t, err)
pb.RegisterPieceStoreRoutesServer(grpcServer.GRPC(), psServer)
go func() { assert.NoError(t, grpcServer.Run(ctx)) }()

View File

@ -5,14 +5,9 @@ package provider
import (
"storj.io/storj/pkg/identity"
"storj.io/storj/pkg/server"
)
type (
// Provider Transition: pkg/provider is going away.
Provider = server.Server
// ServerConfig Transition: pkg/provider is going away.
ServerConfig = server.Config
// FullIdentity Transition: pkg/provider is going away.
FullIdentity = identity.FullIdentity
// PeerIdentity Transition: pkg/provider is going away.
@ -34,10 +29,6 @@ type (
)
var (
// NewServerOptions Transition: pkg/provider is going away.
NewServerOptions = server.NewOptions
// NewProvider Transition: pkg/provider is going away.
NewProvider = server.NewServer
// PeerIdentityFromContext Transition: pkg/provider is going away.
PeerIdentityFromContext = identity.PeerIdentityFromContext
// NewFullIdentity Transition: pkg/provider is going away.

View File

@ -40,18 +40,18 @@ func (sc Config) Run(ctx context.Context, identity *identity.FullIdentity, inter
}
defer func() { err = utils.CombineErrors(err, opts.RevDB.Close()) }()
s, err := NewServer(opts, lis, interceptor, services...)
server, err := New(opts, lis, interceptor, services...)
if err != nil {
return err
}
go func() {
<-ctx.Done()
if closeErr := s.Close(); closeErr != nil {
if closeErr := server.Close(); closeErr != nil {
zap.S().Errorf("Failed to close server: %s", closeErr)
}
}()
zap.S().Infof("Node %s started on %s", s.Identity().ID, sc.Address)
return s.Run(ctx)
zap.S().Infof("Node %s started on %s", server.Identity().ID, sc.Address)
return server.Run(ctx)
}

View File

@ -28,9 +28,9 @@ type Server struct {
identity *identity.FullIdentity
}
// NewServer creates a Server out of an Identity, a net.Listener,
// New creates a Server out of an Identity, a net.Listener,
// a UnaryServerInterceptor, and a set of services.
func NewServer(opts *Options, lis net.Listener,
func New(opts *Options, lis net.Listener,
interceptor grpc.UnaryServerInterceptor, services ...Service) (
*Server, error) {
grpcOpts, err := opts.grpcOpts()

View File

@ -182,7 +182,7 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, config *Config) (*
return nil, errs.Combine(err, peer.Close())
}
peer.Public.Server, err = server.NewServer(publicOptions, peer.Public.Listener, grpcauth.NewAPIKeyInterceptor())
peer.Public.Server, err = server.New(publicOptions, peer.Public.Listener, grpcauth.NewAPIKeyInterceptor())
if err != nil {
return nil, errs.Combine(err, peer.Close())
}

View File

@ -108,7 +108,7 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, config Config) (*P
return nil, errs.Combine(err, peer.Close())
}
peer.Public.Server, err = server.NewServer(publicOptions, peer.Public.Listener, nil)
peer.Public.Server, err = server.New(publicOptions, peer.Public.Listener, nil)
if err != nil {
return nil, errs.Combine(err, peer.Close())
}