Pārlūkot izejas kodu

Comments and Readme changes

Ben Frye 11 gadi atpakaļ
vecāks
revīzija
e42185c430
4 mainītis faili ar 15 papildinājumiem un 13 dzēšanām
  1. 0 0
      .gitignore
  2. 1 0
      AUTHORS
  3. 1 0
      README.md
  4. 13 13
      cluster.go

+ 0 - 0
.gitignore


+ 1 - 0
AUTHORS

@@ -23,3 +23,4 @@ Dan Forest <bonjour@dan.tf>
 Miguel Serrano <miguelvps@gmail.com>
 Stefan Radomski <gibheer@zero-knowledge.org>
 Josh Wright <jshwright@gmail.com>
+Ben Frye <benfrye@gmail.com>

+ 1 - 0
README.md

@@ -34,6 +34,7 @@ Features
   * Round robin distribution of queries to different hosts
   * Round robin distribution of queries to different connections on a host
   * Each connection can execute up to 128 concurrent queries
+  * Optional automatic discovery of nodes
 * Iteration over paged results with configurable page size
 * Optional frame compression (using snappy)
 * Automatic query preparation

+ 13 - 13
cluster.go

@@ -28,22 +28,22 @@ type ClusterConfig struct {
 	RetryPolicy     RetryPolicy   // Default retry policy to use for queries (default: 0)
 	SocketKeepalive time.Duration // The keepalive period to use, enabled if > 0 (default: 0)
 	ConnPoolType    NewPoolFunc   // The function used to create the connection pool for the session (default: NewSimplePool)
-	DiscoverHosts		bool					// Whether or not CreateSession should attempt to fill out
+	DiscoverHosts   bool          // If set, gocql will attempt to automatically discover other members of the Cassandra cluster (default: false)
 }
 
 // NewCluster generates a new config for the default cluster implementation.
 func NewCluster(hosts ...string) *ClusterConfig {
 	cfg := &ClusterConfig{
-		Hosts:        	hosts,
-		CQLVersion:   	"3.0.0",
-		ProtoVersion: 	2,
-		Timeout:      	600 * time.Millisecond,
-		DefaultPort:  	9042,
-		NumConns:     	2,
-		NumStreams:   	128,
-		Consistency:  	Quorum,
-		ConnPoolType: 	NewSimplePool,
-		DiscoverHosts:	false,
+		Hosts:         hosts,
+		CQLVersion:    "3.0.0",
+		ProtoVersion:  2,
+		Timeout:       600 * time.Millisecond,
+		DefaultPort:   9042,
+		NumConns:      2,
+		NumStreams:    128,
+		Consistency:   Quorum,
+		ConnPoolType:  NewSimplePool,
+		DiscoverHosts: false,
 	}
 	return cfg
 }
@@ -76,7 +76,7 @@ func (cfg *ClusterConfig) CreateSession() (*Session, error) {
 						exists = true
 					}
 				}
-				if !exists{
+				if !exists {
 					cfg.Hosts = append(cfg.Hosts, ip)
 				}
 			}
@@ -97,5 +97,5 @@ func (cfg *ClusterConfig) CreateSession() (*Session, error) {
 var (
 	ErrNoHosts              = errors.New("no hosts provided")
 	ErrNoConnectionsStarted = errors.New("no connections were made when creating the session")
-	ErrHostQueryFailed			= errors.New("unable to populate Hosts")
+	ErrHostQueryFailed      = errors.New("unable to populate Hosts")
 )