Skip to content

Commit 401d639

Browse files
committed
multi: add examples for connect functions
Part of #123
1 parent 200dc9d commit 401d639

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

multi/example_test.go

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package multi
2+
3+
import (
4+
"fmt"
5+
"github.com/tarantool/go-tarantool"
6+
"time"
7+
)
8+
9+
func ExampleConnect() {
10+
multiConn, err := Connect([]string{"127.0.0.1:3031", "127.0.0.1:3032"}, tarantool.Opts{
11+
Timeout: 500 * time.Millisecond,
12+
User: "test",
13+
Pass: "test",
14+
})
15+
if err != nil {
16+
fmt.Printf("error in connect is %v", err)
17+
}
18+
fmt.Println(multiConn)
19+
}
20+
21+
func ExampleConnectWithOpts() {
22+
multiConn, err := ConnectWithOpts([]string{"127.0.0.1:3301", "127.0.0.1:3302"}, tarantool.Opts{
23+
Timeout: 500 * time.Millisecond,
24+
User: "test",
25+
Pass: "test",
26+
}, OptsMulti{
27+
// Check for connection timeout every 1 second.
28+
CheckTimeout: 1 * time.Second,
29+
// Lua function name for getting address list.
30+
NodesGetFunctionName: "get_cluster_nodes",
31+
// Ask server for updated address list every 3 seconds.
32+
ClusterDiscoveryTime: 3 * time.Second,
33+
})
34+
if err != nil {
35+
fmt.Printf("error in connect is %v", err)
36+
}
37+
fmt.Println(multiConn)
38+
}

0 commit comments

Comments
 (0)