Skip to content

Commit cbfcd16

Browse files
committed
strike datacentre spelling
1 parent 37030fb commit cbfcd16

File tree

5 files changed

+31
-20
lines changed

5 files changed

+31
-20
lines changed

cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ type ClusterConfig struct {
198198
// If DisableInitialHostLookup then the driver will not attempt to get host info
199199
// from the system.peers table, this will mean that the driver will connect to
200200
// hosts supplied and will not attempt to lookup the hosts information, this will
201-
// mean that data_centre, rack and token information will not be available and as
201+
// mean that data_center, rack and token information will not be available and as
202202
// such host filtering and token aware query routing will not be available.
203203
DisableInitialHostLookup bool
204204

filters.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,20 @@ func DenyAllFilter() HostFilter {
5353
})
5454
}
5555

56-
// DataCentreHostFilter filters all hosts such that they are in the same data centre
57-
// as the supplied data centre.
58-
func DataCentreHostFilter(dataCentre string) HostFilter {
56+
// DataCenterHostFilter filters all hosts such that they are in the same data center
57+
// as the supplied data center.
58+
func DataCenterHostFilter(dataCenter string) HostFilter {
5959
return HostFilterFunc(func(host *HostInfo) bool {
60-
return host.DataCenter() == dataCentre
60+
return host.DataCenter() == dataCenter
6161
})
6262
}
6363

64+
// Deprecated: Use DataCenterHostFilter instead.
65+
// DataCentreHostFilter is an alias that doesn't use the preferred spelling.
66+
func DataCentreHostFilter(dataCenter string) HostFilter {
67+
return DataCenterHostFilter(dataCenter)
68+
}
69+
6470
// WhiteListHostFilter filters incoming hosts by checking that their address is
6571
// in the initial hosts whitelist.
6672
func WhiteListHostFilter(hosts ...string) HostFilter {

filters_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ func TestFilter_DenyAll(t *testing.T) {
9595
}
9696
}
9797

98-
func TestFilter_DataCentre(t *testing.T) {
99-
f := DataCentreHostFilter("dc1")
98+
func TestFilter_DataCenter(t *testing.T) {
99+
f := DataCenterHostFilter("dc1")
100+
fDeprecated := DataCentreHostFilter("dc1")
101+
100102
tests := [...]struct {
101103
dc string
102104
accept bool
@@ -113,5 +115,9 @@ func TestFilter_DataCentre(t *testing.T) {
113115
} else if test.accept {
114116
t.Errorf("%d: should have been accepted but wasn't", i)
115117
}
118+
119+
if f.Accept(&HostInfo{dataCenter: test.dc}) != fDeprecated.Accept(&HostInfo{dataCenter: test.dc}) {
120+
t.Errorf("%d: DataCenterHostFilter and DataCentreHostFilter should be the same", i)
121+
}
116122
}
117123
}

host_source.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ import (
3535
"time"
3636
)
3737

38-
var ErrCannotFindHost = errors.New("cannot find host")
39-
var ErrHostAlreadyExists = errors.New("host already exists")
38+
var (
39+
ErrCannotFindHost = errors.New("cannot find host")
40+
ErrHostAlreadyExists = errors.New("host already exists")
41+
)
4042

4143
type nodeState int32
4244

@@ -111,7 +113,6 @@ func (c cassVersion) Before(major, minor, patch int) bool {
111113
} else if c.Minor == minor && c.Patch < patch {
112114
return true
113115
}
114-
115116
}
116117
return false
117118
}
@@ -439,7 +440,7 @@ func (h *HostInfo) String() string {
439440
connectAddr, source := h.connectAddressLocked()
440441
return fmt.Sprintf("[HostInfo hostname=%q connectAddress=%q peer=%q rpc_address=%q broadcast_address=%q "+
441442
"preferred_ip=%q connect_addr=%q connect_addr_source=%q "+
442-
"port=%d data_centre=%q rack=%q host_id=%q version=%q state=%s num_tokens=%d]",
443+
"port=%d data_center=%q rack=%q host_id=%q version=%q state=%s num_tokens=%d]",
443444
h.hostname, h.connectAddress, h.peer, h.rpcAddress, h.broadcastAddress, h.preferredIP,
444445
connectAddr, source,
445446
h.port, h.dataCenter, h.rack, h.hostId, h.version, h.state, len(h.tokens))

policies.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
package gocql
2626

27-
//This file will be the future home for more policies
27+
// This file will be the future home for more policies
2828

2929
import (
3030
"context"
@@ -159,7 +159,7 @@ type RetryPolicy interface {
159159
// //Assign to a query
160160
// query.RetryPolicy(&gocql.SimpleRetryPolicy{NumRetries: 1})
161161
type SimpleRetryPolicy struct {
162-
NumRetries int //Number of times to retry a query
162+
NumRetries int // Number of times to retry a query
163163
}
164164

165165
// Attempt tells gocql to attempt the query again based on query.Attempts being less
@@ -839,8 +839,8 @@ type dcAwareRR struct {
839839
}
840840

841841
// DCAwareRoundRobinPolicy is a host selection policies which will prioritize and
842-
// return hosts which are in the local datacentre before returning hosts in all
843-
// other datercentres
842+
// return hosts which are in the local datacenter before returning hosts in all
843+
// other datacenters
844844
func DCAwareRoundRobinPolicy(localDC string) HostSelectionPolicy {
845845
return &dcAwareRR{local: localDC}
846846
}
@@ -885,7 +885,6 @@ func roundRobbin(shift int, hosts ...[]*HostInfo) NextHost {
885885
currentlyObserved := 0
886886

887887
return func() SelectedHost {
888-
889888
// iterate over layers
890889
for {
891890
if currentLayer == len(hosts) {
@@ -921,7 +920,7 @@ func (d *dcAwareRR) Pick(q ExecutableQuery) NextHost {
921920

922921
// RackAwareRoundRobinPolicy is a host selection policies which will prioritize and
923922
// return hosts which are in the local rack, before hosts in the local datacenter but
924-
// a different rack, before hosts in all other datercentres
923+
// a different rack, before hosts in all other datacenters
925924

926925
type rackAwareRR struct {
927926
// lastUsedHostIdx keeps the index of the last used host.
@@ -1031,14 +1030,13 @@ func (s *singleHostReadyPolicy) Ready() bool {
10311030
type ConvictionPolicy interface {
10321031
// Implementations should return `true` if the host should be convicted, `false` otherwise.
10331032
AddFailure(error error, host *HostInfo) bool
1034-
//Implementations should clear out any convictions or state regarding the host.
1033+
// Implementations should clear out any convictions or state regarding the host.
10351034
Reset(host *HostInfo)
10361035
}
10371036

10381037
// SimpleConvictionPolicy implements a ConvictionPolicy which convicts all hosts
10391038
// regardless of error
1040-
type SimpleConvictionPolicy struct {
1041-
}
1039+
type SimpleConvictionPolicy struct{}
10421040

10431041
func (e *SimpleConvictionPolicy) AddFailure(error error, host *HostInfo) bool {
10441042
return true

0 commit comments

Comments
 (0)