From 66f93c1ac26c86294aac7d4efba4568fad4ffaf1 Mon Sep 17 00:00:00 2001 From: HTHou Date: Thu, 29 Aug 2024 15:40:44 +0800 Subject: [PATCH] opt example --- example/session_example.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/example/session_example.go b/example/session_example.go index b370435..fbfba4f 100644 --- a/example/session_example.go +++ b/example/session_example.go @@ -57,6 +57,8 @@ func main() { } defer session.Close() + //connectCluster() + setStorageGroup("root.ln1") deleteStorageGroup("root.ln1") @@ -143,6 +145,19 @@ func main() { deleteTimeseries("root.ln.device1.*") } +// If your IotDB is a cluster version, you can use the following code for multi node connection +func connectCluster() { + config := &client.ClusterConfig{ + NodeUrls: strings.Split("127.0.0.1:6667,127.0.0.1:6668,127.0.0.1:6669", ","), + UserName: "root", + Password: "root", + } + session = client.NewClusterSession(config) + if err := session.OpenCluster(false); err != nil { + log.Fatal(err) + } +} + func printDevice1(sds *client.SessionDataSet) { showTimestamp := !sds.IsIgnoreTimeStamp() if showTimestamp { @@ -667,16 +682,3 @@ func checkError(status *common.TSStatus, err error) { } } } - -// If your IotDB is a cluster version, you can use the following code for multi node connection -func connectCluster() { - config := &client.ClusterConfig{ - NodeUrls: strings.Split("127.0.0.1:6667,127.0.0.1:6668,127.0.0.1:6669", ","), - UserName: "root", - Password: "root", - } - session = client.NewClusterSession(config) - if err := session.OpenCluster(false); err != nil { - log.Fatal(err) - } -}