Skip to content

Commit

Permalink
config: remove legacy DiscoveryConfig
Browse files Browse the repository at this point in the history
DiscoveryConfig was replaced with the HostFilter, DiscoveryConfig was
not fully ported over when adding host events.
  • Loading branch information
Zariel committed Sep 17, 2016
1 parent 6b33c11 commit f859eab
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 36 deletions.
23 changes: 0 additions & 23 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,6 @@ func (p PoolConfig) buildPool(session *Session) *policyConnPool {
return newPolicyConnPool(session)
}

type DiscoveryConfig struct {
// If not empty will filter all discovered hosts to a single Data Centre (default: "")
DcFilter string
// If not empty will filter all discovered hosts to a single Rack (default: "")
RackFilter string
// ignored
Sleep time.Duration
}

func (d DiscoveryConfig) matchFilter(host *HostInfo) bool {
if d.DcFilter != "" && d.DcFilter != host.DataCenter() {
return false
}

if d.RackFilter != "" && d.RackFilter != host.Rack() {
return false
}

return true
}

// ClusterConfig is a struct to configure the default cluster implementation
// of gocoql. It has a variety of attributes that can be used to modify the
// behavior to fit the most common use cases. Applications that require a
Expand Down Expand Up @@ -70,8 +49,6 @@ type ClusterConfig struct {
// configuration of host selection and connection selection policies.
PoolConfig PoolConfig

Discovery DiscoveryConfig

// If not zero, gocql attempt to reconnect known DOWN nodes in every ReconnectSleep.
ReconnectInterval time.Duration

Expand Down
14 changes: 2 additions & 12 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,7 @@ func (s *Session) handleNewNode(host net.IP, port int, waitForBinary bool) {
hostInfo.setPeer(addr)
}

if s.cfg.HostFilter != nil {
if !s.cfg.HostFilter.Accept(hostInfo) {
return
}
} else if !s.cfg.Discovery.matchFilter(hostInfo) {
// TODO: remove this when the host selection policy is more sophisticated
if s.cfg.HostFilter != nil && !s.cfg.HostFilter.Accept(hostInfo) {
return
}

Expand Down Expand Up @@ -254,12 +249,7 @@ func (s *Session) handleNodeUp(ip net.IP, port int, waitForBinary bool) {
host.setPeer(addr)
}

if s.cfg.HostFilter != nil {
if !s.cfg.HostFilter.Accept(host) {
return
}
} else if !s.cfg.Discovery.matchFilter(host) {
// TODO: remove this when the host selection policy is more sophisticated
if s.cfg.HostFilter != nil && !s.cfg.HostFilter.Accept(host) {
return
}

Expand Down
1 change: 0 additions & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ func NewSession(cfg ClusterConfig) (*Session, error) {
}

var hosts []*HostInfo

if !cfg.disableControlConn {
s.control = createControlConn(s)
if err := s.control.connect(cfg.Hosts); err != nil {
Expand Down

0 comments on commit f859eab

Please sign in to comment.