lint: fix warning by removing reference to deprecated interface

This commit is contained in:
Daniel Nephin 2021-04-30 17:55:22 -04:00
parent 203c752ee8
commit df98027ad1
2 changed files with 21 additions and 14 deletions

View File

@ -21,7 +21,6 @@ import (
connlimit "github.com/hashicorp/go-connlimit" connlimit "github.com/hashicorp/go-connlimit"
"github.com/hashicorp/go-hclog" "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-memdb" "github.com/hashicorp/go-memdb"
"github.com/hashicorp/memberlist"
"github.com/hashicorp/raft" "github.com/hashicorp/raft"
autopilot "github.com/hashicorp/raft-autopilot" autopilot "github.com/hashicorp/raft-autopilot"
raftboltdb "github.com/hashicorp/raft-boltdb" raftboltdb "github.com/hashicorp/raft-boltdb"
@ -35,6 +34,7 @@ import (
"github.com/hashicorp/consul/agent/consul/fsm" "github.com/hashicorp/consul/agent/consul/fsm"
"github.com/hashicorp/consul/agent/consul/state" "github.com/hashicorp/consul/agent/consul/state"
"github.com/hashicorp/consul/agent/consul/usagemetrics" "github.com/hashicorp/consul/agent/consul/usagemetrics"
"github.com/hashicorp/consul/agent/consul/wanfed"
agentgrpc "github.com/hashicorp/consul/agent/grpc" agentgrpc "github.com/hashicorp/consul/agent/grpc"
"github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/agent/metadata"
"github.com/hashicorp/consul/agent/pool" "github.com/hashicorp/consul/agent/pool"
@ -251,7 +251,7 @@ type Server struct {
// serfWAN is the Serf cluster maintained between DC's // serfWAN is the Serf cluster maintained between DC's
// which SHOULD only consist of Consul servers // which SHOULD only consist of Consul servers
serfWAN *serf.Serf serfWAN *serf.Serf
memberlistTransportWAN memberlist.IngestionAwareTransport memberlistTransportWAN wanfed.IngestionAwareTransport
gatewayLocator *GatewayLocator gatewayLocator *GatewayLocator
// serverLookup tracks server consuls in the local datacenter. // serverLookup tracks server consuls in the local datacenter.
@ -500,7 +500,7 @@ func NewServer(config *Config, flat Deps) (*Server, error) {
// This is always a *memberlist.NetTransport or something which wraps // This is always a *memberlist.NetTransport or something which wraps
// it which satisfies this interface. // it which satisfies this interface.
s.memberlistTransportWAN = config.SerfWANConfig.MemberlistConfig.Transport.(memberlist.IngestionAwareTransport) s.memberlistTransportWAN = config.SerfWANConfig.MemberlistConfig.Transport.(wanfed.IngestionAwareTransport)
// See big comment above why we are doing this. // See big comment above why we are doing this.
if serfBindPortWAN == 0 { if serfBindPortWAN == 0 {

View File

@ -8,10 +8,11 @@ import (
"strings" "strings"
"time" "time"
"github.com/hashicorp/memberlist"
"github.com/hashicorp/consul/agent/pool" "github.com/hashicorp/consul/agent/pool"
"github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/agent/structs"
"github.com/hashicorp/consul/tlsutil" "github.com/hashicorp/consul/tlsutil"
"github.com/hashicorp/memberlist"
) )
const ( const (
@ -29,9 +30,15 @@ const (
type MeshGatewayResolver func(datacenter string) string type MeshGatewayResolver func(datacenter string) string
type IngestionAwareTransport interface {
memberlist.NodeAwareTransport
IngestPacket(conn net.Conn, addr net.Addr, now time.Time, shouldClose bool) error
IngestStream(conn net.Conn) error
}
func NewTransport( func NewTransport(
tlsConfigurator *tlsutil.Configurator, tlsConfigurator *tlsutil.Configurator,
transport memberlist.NodeAwareTransport, transport IngestionAwareTransport,
datacenter string, datacenter string,
gwResolver MeshGatewayResolver, gwResolver MeshGatewayResolver,
) (*Transport, error) { ) (*Transport, error) {
@ -48,17 +55,17 @@ func NewTransport(
} }
t := &Transport{ t := &Transport{
NodeAwareTransport: transport, IngestionAwareTransport: transport,
tlsConfigurator: tlsConfigurator, tlsConfigurator: tlsConfigurator,
datacenter: datacenter, datacenter: datacenter,
gwResolver: gwResolver, gwResolver: gwResolver,
pool: cp, pool: cp,
} }
return t, nil return t, nil
} }
type Transport struct { type Transport struct {
memberlist.NodeAwareTransport IngestionAwareTransport
tlsConfigurator *tlsutil.Configurator tlsConfigurator *tlsutil.Configurator
datacenter string datacenter string
@ -71,7 +78,7 @@ var _ memberlist.NodeAwareTransport = (*Transport)(nil)
// Shutdown implements memberlist.Transport. // Shutdown implements memberlist.Transport.
func (t *Transport) Shutdown() error { func (t *Transport) Shutdown() error {
err1 := t.pool.Close() err1 := t.pool.Close()
err2 := t.NodeAwareTransport.Shutdown() err2 := t.IngestionAwareTransport.Shutdown()
if err2 != nil { if err2 != nil {
// the more important error is err2 // the more important error is err2
return err2 return err2
@ -118,7 +125,7 @@ func (t *Transport) WriteToAddress(b []byte, addr memberlist.Address) (time.Time
return time.Now(), nil return time.Now(), nil
} }
return t.NodeAwareTransport.WriteToAddress(b, addr) return t.IngestionAwareTransport.WriteToAddress(b, addr)
} }
// DialAddressTimeout implements memberlist.NodeAwareTransport. // DialAddressTimeout implements memberlist.NodeAwareTransport.
@ -137,7 +144,7 @@ func (t *Transport) DialAddressTimeout(addr memberlist.Address, timeout time.Dur
return t.dial(dc, node, pool.ALPN_WANGossipStream, gwAddr) return t.dial(dc, node, pool.ALPN_WANGossipStream, gwAddr)
} }
return t.NodeAwareTransport.DialAddressTimeout(addr, timeout) return t.IngestionAwareTransport.DialAddressTimeout(addr, timeout)
} }
// NOTE: There is a close mirror of this method in agent/pool/pool.go:DialTimeoutWithRPCType // NOTE: There is a close mirror of this method in agent/pool/pool.go:DialTimeoutWithRPCType