This is an automated email from the ASF dual-hosted git repository.

neuyilan pushed a commit to branch fix_session_id
in repository https://gitbox.apache.org/repos/asf/iotdb-client-go.git

commit 30ac5c43abf14447b2a1c0ccf6aed7e852db5b72
Author: HouliangQi <[email protected]>
AuthorDate: Wed Jun 22 12:11:48 2022 +0800

    add cluster example
---
 example/session_example.go | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/example/session_example.go b/example/session_example.go
index c10154b..c8ad1f4 100644
--- a/example/session_example.go
+++ b/example/session_example.go
@@ -39,9 +39,9 @@ var (
 )
 var session client.Session
 
-func main() {
-       flag.StringVar(&host, "host", "127.0.0.1", "--host=192.168.1.100")
-       flag.StringVar(&port, "port", "6667", "--port=6667")
+func InitSingleSession() client.Session {
+       flag.StringVar(&host, "host", "172.16.48.4", "--host=192.168.1.100")
+       flag.StringVar(&port, "port", "8685", "--port=6667")
        flag.StringVar(&user, "user", "root", "--user=root")
        flag.StringVar(&password, "password", "root", "--password=root")
        flag.Parse()
@@ -55,6 +55,27 @@ func main() {
        if err := session.Open(false, 0); err != nil {
                log.Fatal(err)
        }
+       return session
+}
+
+func InitClusterSession() client.Session {
+       nodeUrls := []string{"172.16.48.4:8685", "172.16.48.5:8685", 
"172.16.48.7:8685"}
+       clusterConfig := &client.ClusterConfig{
+               NodeUrls: nodeUrls,
+               UserName: "root",
+               Password: "root",
+       }
+       session = client.NewClusterSession(clusterConfig)
+       err := session.OpenCluster(false)
+       if err != nil {
+               fmt.Println(nil, err)
+       }
+       return session
+}
+
+func main() {
+       // if you want to connect the cluster version of IoTDB, you can see 
InitClusterSession as example
+       InitSingleSession()
        defer session.Close()
 
        setStorageGroup("root.ln1")

Reply via email to