forked from valkey-io/valkey-glide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_management_cluster_commands_test.go
107 lines (84 loc) · 2.66 KB
/
server_management_cluster_commands_test.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0
package api
import (
"fmt"
"strings"
"github.com/valkey-io/valkey-glide/go/api/config"
"github.com/valkey-io/valkey-glide/go/api/options"
)
func ExampleGlideClusterClient_Info() {
var client *GlideClusterClient = getExampleGlideClusterClient() // example helper function
response, err := client.Info()
if err != nil {
fmt.Println("Glide example failed with an error: ", err)
}
for _, data := range response {
if strings.Contains(data, "cluster_enabled:1") {
fmt.Println("OK")
break
}
}
// Output: OK
}
func ExampleGlideClusterClient_InfoWithOptions() {
var client *GlideClusterClient = getExampleGlideClusterClient() // example helper function
opts := options.ClusterInfoOptions{
InfoOptions: &options.InfoOptions{Sections: []options.Section{options.Cluster}},
}
response, err := client.InfoWithOptions(opts)
if err != nil {
fmt.Println("Glide example failed with an error: ", err)
}
for _, data := range response.MultiValue() {
if strings.Contains(data, "cluster_enabled:1") {
fmt.Println("OK")
break
}
}
// Output: OK
}
func ExampleGlideClusterClient_TimeWithOptions() {
var client *GlideClusterClient = getExampleGlideClusterClient() // example helper function
route := config.Route(config.RandomRoute)
opts := options.RouteOption{
Route: route,
}
clusterResponse, err := client.TimeWithOptions(opts) // gives: {1 [1738714595 942076] map[]}
if err != nil {
fmt.Println("Glide example failed with an error: ", err)
}
fmt.Println(len(clusterResponse.SingleValue()) == 2)
// Output: true
}
func ExampleGlideClusterClient_DBSizeWithOptions() {
var client *GlideClusterClient = getExampleGlideClusterClient() // example helper function
route := config.SimpleNodeRoute(config.RandomRoute)
opts := options.RouteOption{
Route: route,
}
result, err := client.DBSizeWithOptions(opts)
if err != nil {
fmt.Println("Glide example failed with an error: ", err)
}
fmt.Println(result)
// Output: 0
}
func ExampleGlideClusterClient_ConfigResetStat() {
var client *GlideClusterClient = getExampleGlideClusterClient() // example helper function
result, err := client.ConfigResetStat()
if err != nil {
fmt.Println("Glide example failed with an error: ", err)
}
fmt.Println(result)
// Output: OK
}
func ExampleGlideClusterClient_ConfigResetStatWithOptions() {
var client *GlideClusterClient = getExampleGlideClusterClient() // example helper function
opts := options.RouteOption{Route: nil}
result, err := client.ConfigResetStatWithOptions(opts)
if err != nil {
fmt.Println("Glide example failed with an error: ", err)
}
fmt.Println(result)
// Output: OK
}