浏览代码

Update documentation

Daniel Cannon 10 年之前
父节点
当前提交
76d7214745
共有 2 个文件被更改,包括 13 次插入2 次删除
  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
 // HostPoolHostPolicy is a host policy which uses the bitly/go-hostpool library
 // to distribute queries between hosts and prevent sending queries to
 // 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 {
 func HostPoolHostPolicy(hp hostpool.HostPool) HostSelectionPolicy {
 	return &hostPoolHostPolicy{hostMap: map[string]HostInfo{}, hp: hp}
 	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
 // Tests of the host pool host selection policy implementation
 func TestHostPoolHostPolicy(t *testing.T) {
 func TestHostPoolHostPolicy(t *testing.T) {
-	policy := HostPoolHostPolicy(hostpool.New([]string{}))
+	policy := HostPoolHostPolicy(hostpool.New(nil))
 
 
 	hosts := []HostInfo{
 	hosts := []HostInfo{
 		HostInfo{HostId: "0", Peer: "0"},
 		HostInfo{HostId: "0", Peer: "0"},