forked from valkey-io/valkey-glide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Go: Add
GlideClusterClient
examples (valkey-io#3154)
Add GlideClusterClient examples --------- Signed-off-by: Edward Liang <[email protected]>
- Loading branch information
Showing
17 changed files
with
2,690 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 | ||
|
||
package api | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/valkey-io/valkey-glide/go/api/options" | ||
) | ||
|
||
func ExampleGlideClusterClient_Ping() { | ||
var client *GlideClusterClient = getExampleGlideClusterClient() // example helper function | ||
result, err := client.Ping() | ||
if err != nil { | ||
fmt.Println("Glide example failed with an error: ", err) | ||
} | ||
fmt.Println(result) | ||
|
||
// Output: PONG | ||
} | ||
|
||
func ExampleGlideClusterClient_PingWithOptions() { | ||
var client *GlideClusterClient = getExampleGlideClusterClient() // example helper function | ||
options := options.ClusterPingOptions{ | ||
PingOptions: &options.PingOptions{ | ||
Message: "hello", | ||
}, | ||
Route: nil, | ||
} | ||
result, err := client.PingWithOptions(options) | ||
if err != nil { | ||
fmt.Println("Glide example failed with an error: ", err) | ||
} | ||
fmt.Println(result) | ||
|
||
// Output: hello | ||
} | ||
|
||
func ExampleGlideClusterClient_Echo() { | ||
var client *GlideClusterClient = getExampleGlideClusterClient() // example helper function | ||
result, err := client.Echo("Hello") | ||
if err != nil { | ||
fmt.Println("Glide example failed with an error: ", err) | ||
} | ||
fmt.Println(result) | ||
|
||
// Output: {Hello false} | ||
} | ||
|
||
func ExampleGlideClusterClient_EchoWithOptions() { | ||
var client *GlideClusterClient = getExampleGlideClusterClient() // example helper function | ||
opts := options.ClusterEchoOptions{ | ||
EchoOptions: &options.EchoOptions{ | ||
Message: "Hello World", | ||
}, | ||
RouteOption: &options.RouteOption{Route: nil}, | ||
} | ||
result, err := client.EchoWithOptions(opts) | ||
if err != nil { | ||
fmt.Println("Glide example failed with an error: ", err) | ||
} | ||
fmt.Println(result.singleValue) | ||
|
||
// Output: Hello World | ||
} |
Oops, something went wrong.