You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2023/02/27 10:11:02 UTC

[iotdb-client-go] branch rel/0.13 updated: Update README.md (#77)

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

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


The following commit(s) were added to refs/heads/rel/0.13 by this push:
     new ec57c6c  Update README.md (#77)
ec57c6c is described below

commit ec57c6c073d91eb9303f785a9b39659d8c47cc82
Author: Liwen Fu <fu...@gmail.com>
AuthorDate: Mon Feb 27 18:10:56 2023 +0800

    Update README.md (#77)
---
 README.md    | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 README_ZH.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 109 insertions(+)

diff --git a/README.md b/README.md
index ac6e808..cc2a26e 100644
--- a/README.md
+++ b/README.md
@@ -80,6 +80,61 @@ curl -o session_example.go -L https://github.com/apache/iotdb-client-go/raw/main
 go run session_example.go
 ```
 
+## How to Use the SessionPool
+SessionPool is a wrapper of a Session Set. Using SessionPool, the user do not need to consider how to reuse a session connection.
+If there is no available connections and the pool reaches its max size, the all methods will hang until there is a available connection.
+The PutBack method must be called after use
+
+### New sessionPool
+
+```golang
+
+config := &client.PoolConfig{
+    Host:     host,
+    Port:     port,
+    UserName: user,
+    Password: password,
+}
+sessionPool = client.NewSessionPool(config, 3, 60000, 60000, false)
+
+```
+
+### Get session through sessionPool, putback after use
+
+set storage group
+
+```golang
+
+session, err := sessionPool.GetSession()
+defer sessionPool.PutBack(session)
+if err == nil {
+    session.SetStorageGroup(sg)
+}
+
+```
+
+query statement
+
+```golang
+
+var timeout int64 = 1000
+session, err := sessionPool.GetSession()
+defer sessionPool.PutBack(session)
+if err != nil {
+    log.Print(err)
+    return
+}
+sessionDataSet, err := session.ExecuteQueryStatement(sql, &timeout)
+if err == nil {
+    defer sessionDataSet.Close()
+    printDataSet1(sessionDataSet)
+} else {
+    log.Println(err)
+}
+
+```
+
+
 ## Developer environment requirements for iotdb-client-go
 
 ### OS
diff --git a/README_ZH.md b/README_ZH.md
index dfbb0dc..13d4ff8 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -63,6 +63,60 @@ curl -o session_example.go -L https://github.com/apache/iotdb-client-go/raw/main
 go run session_example.go
 ```
 
+## SessionPool
+通过SessionPool管理session,用户不需要考虑如何重用session,当到达pool的最大值时,获取session的请求会阻塞
+注意:session使用完成后需要调用PutBack方法
+
+### 创建sessionPool
+
+```golang
+
+config := &client.PoolConfig{
+    Host:     host,
+    Port:     port,
+    UserName: user,
+    Password: password,
+}
+sessionPool = client.NewSessionPool(config, 3, 60000, 60000, false)
+
+```
+
+### 使用sessionPool获取session,使用完手动调用PutBack
+
+例1:设置存储组
+
+```golang
+
+session, err := sessionPool.GetSession()
+defer sessionPool.PutBack(session)
+if err == nil {
+    session.SetStorageGroup(sg)
+}
+
+```
+
+例2:查询
+
+```golang
+
+var timeout int64 = 1000
+session, err := sessionPool.GetSession()
+defer sessionPool.PutBack(session)
+if err != nil {
+    log.Print(err)
+    return
+}
+sessionDataSet, err := session.ExecuteQueryStatement(sql, &timeout)
+if err == nil {
+    defer sessionDataSet.Close()
+    printDataSet1(sessionDataSet)
+} else {
+    log.Println(err)
+}
+
+```
+
+
 ## iotdb-client-go的开发者环境要求
 
 ### 操作系统