-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster_conn.go
33 lines (28 loc) · 1.01 KB
/
cluster_conn.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"github.com/mediocregopher/radix/v3"
"log"
)
func getOSSClusterConn(addr string, opts []radix.DialOpt, clients uint64) *radix.Cluster {
var vanillaCluster *radix.Cluster
var err error
customConnFunc := func(network, addr string) (radix.Conn, error) {
return radix.Dial(network, addr, opts...,
)
}
// this cluster will use the ClientFunc to create a pool to each node in the
// cluster.
poolFunc := func(network, addr string) (radix.Client, error) {
return radix.NewPool(network, addr, int(clients), radix.PoolConnFunc(customConnFunc), radix.PoolPipelineWindow(0, 0))
}
vanillaCluster, err = radix.NewCluster([]string{addr}, radix.ClusterPoolFunc(poolFunc))
if err != nil {
log.Fatalf("Error preparing for benchmark, while creating new connection to %v. error = %v", []string{addr}, err)
}
// Issue CLUSTER SLOTS command
err = vanillaCluster.Sync()
if err != nil {
log.Fatalf("Error preparing for benchmark, while issuing CLUSTER SLOTS. error = %v", err)
}
return vanillaCluster
}