Browse Source

Update documentation

Daniel Cannon 10 years ago
parent
commit
76d7214745
2 changed files with 13 additions and 2 deletions
  1. 12 1
      policies.go
  2. 1 1
      policies_test.go

+ 12 - 1
policies.go

@@ -256,7 +256,18 @@ func (host selectedTokenAwareHost) Mark(err error) {
 
 // HostPoolHostPolicy is a host policy which uses the bitly/go-hostpool library
 // to distribute queries between hosts and prevent sending queries to
-// unresponsive hosts.
+// unresponsive hosts. When creating the host pool that is passed to the policy
+// use an empty slice of hosts as the hostpool will be populated later by gocql.
+// See below for examples of usage:
+//
+//     // Create host selection policy using a simple host pool
+//     cluster.PoolConfig.HostSelectionPolicy = HostPoolHostPolicy(hostpool.New(nil))
+//
+//     // Create host selection policy using an epsilon greddy pool
+//     cluster.PoolConfig.HostSelectionPolicy = HostPoolHostPolicy(
+//         hostpool.NewEpsilonGreedy(nil, 0, &hostpool.LinearEpsilonValueCalculator{}),
+//     )
+//
 func HostPoolHostPolicy(hp hostpool.HostPool) HostSelectionPolicy {
 	return &hostPoolHostPolicy{hostMap: map[string]HostInfo{}, hp: hp}
 }

+ 1 - 1
policies_test.go

@@ -106,7 +106,7 @@ func TestTokenAwareHostPolicy(t *testing.T) {
 
 // Tests of the host pool host selection policy implementation
 func TestHostPoolHostPolicy(t *testing.T) {
-	policy := HostPoolHostPolicy(hostpool.New([]string{}))
+	policy := HostPoolHostPolicy(hostpool.New(nil))
 
 	hosts := []HostInfo{
 		HostInfo{HostId: "0", Peer: "0"},