Skip to content

Commit

Permalink
DefaultPort to Port: I tink it make more sense like that
Browse files Browse the repository at this point in the history
  • Loading branch information
juliendsv committed Aug 20, 2014
1 parent 4b86114 commit 838e2ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import (
"github.com/golang/groupcache/lru"
)

const (
defaultPort = 9042
)

//Package global reference to Prepared Statements LRU
var stmtsLRU preparedLRU

Expand Down Expand Up @@ -49,7 +53,7 @@ type ClusterConfig struct {
CQLVersion string // CQL version (default: 3.0.0)
ProtoVersion int // version of the native protocol (default: 2)
Timeout time.Duration // connection timeout (default: 600ms)
DefaultPort int // default port (default: 9042)
Port int // port (default: 9042)
Keyspace string // initial keyspace (optional)
NumConns int // number of connections per host (default: 2)
NumStreams int // number of streams per connection (default: 128)
Expand All @@ -71,7 +75,7 @@ func NewCluster(hosts ...string) *ClusterConfig {
CQLVersion: "3.0.0",
ProtoVersion: 2,
Timeout: 600 * time.Millisecond,
DefaultPort: 9042,
Port: defaultPort,
NumConns: 2,
NumStreams: 128,
Consistency: Quorum,
Expand Down
6 changes: 3 additions & 3 deletions connectionpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Example of Single Connection Pool:
func NewSingleConnection(cfg *ClusterConfig) ConnectionPool {
addr := strings.TrimSpace(cfg.Hosts[0])
if strings.Index(addr, ":") < 0 {
addr = fmt.Sprintf("%s:%d", addr, cfg.DefaultPort)
addr = fmt.Sprintf("%s:%d", addr, cfg.Port)
}
connCfg := ConnConfig{
ProtoVersion: cfg.ProtoVersion,
Expand Down Expand Up @@ -146,7 +146,7 @@ func NewSimplePool(cfg *ClusterConfig) ConnectionPool {
for i := 0; i < len(cfg.Hosts); i++ {
addr := strings.TrimSpace(cfg.Hosts[i])
if strings.Index(addr, ":") < 0 {
addr = fmt.Sprintf("%s:%d", addr, cfg.DefaultPort)
addr = fmt.Sprintf("%s:%d", addr, cfg.Port)
}

if pool.connect(addr) == nil {
Expand Down Expand Up @@ -236,7 +236,7 @@ func (c *SimplePool) fillPool() {
for host := range c.hosts {
addr := strings.TrimSpace(host)
if strings.Index(addr, ":") < 0 {
addr = fmt.Sprintf("%s:%d", addr, c.cfg.DefaultPort)
addr = fmt.Sprintf("%s:%d", addr, c.cfg.Port)
}

numConns := 1
Expand Down

0 comments on commit 838e2ab

Please sign in to comment.