Skip to content

Commit

Permalink
opt example
Browse files Browse the repository at this point in the history
  • Loading branch information
HTHou committed Aug 29, 2024
1 parent 1a4ba32 commit 66f93c1
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions example/session_example.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ func main() {
}
defer session.Close()

//connectCluster()

setStorageGroup("root.ln1")
deleteStorageGroup("root.ln1")

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 66f93c1

Please sign in to comment.