Skip to content

Commit 93e75f0

Browse files
Merge pull request #4 from redis-performance/tool.revamp
Included ZRANGE/ZREVRANGE benchmark. Added OSS cluster API support
2 parents ccb1f05 + a3394df commit 93e75f0

File tree

4 files changed

+504
-687
lines changed

4 files changed

+504
-687
lines changed

cluster_conn.go

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

go.mod

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ go 1.16
44

55
require (
66
github.com/HdrHistogram/hdrhistogram-go v1.1.0
7-
github.com/golangci/golangci-lint v1.40.0 // indirect
8-
github.com/mediocregopher/radix/v3 v3.7.0
7+
github.com/google/go-cmp v0.5.9 // indirect
8+
github.com/mediocregopher/radix/v3 v3.8.1
99
github.com/mitchellh/gox v1.0.1 // indirect
10-
github.com/tcnksm/ghr v0.13.0 // indirect
10+
github.com/tcnksm/ghr v0.16.0 // indirect
11+
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5 // indirect
1112
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1
13+
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
1214
)

0 commit comments

Comments
 (0)