Skip to content

Commit

Permalink
release_v3.00.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
YilunZhang39 committed Jul 31, 2024
1 parent 14ab6cc commit 80e1810
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func main() {
通过配置 BehaviorOptions 可以配置行为标识。可配置行为标识如下:

- Priority:指定本任务优先级,可选范围为 0~8,默认为 8。
- Parallelism:指定本任务并行度,可选范围为 0~64,默认为 8
- Parallelism:指定本任务并行度,可选范围为 0~64,默认为 64
- FetchSize: 指定分块返回的块大小。
- LoadBalance: 指定是否开启负载均衡。
- EnableHighAvailability: 指定是否开启高可用。
Expand Down Expand Up @@ -1868,14 +1868,14 @@ NewTableFromStruct(obj interface{}) (*Table, error)

入参说明:

obj 可以为任意结构体对象,但是该结构体字段类型需要为数组,且字段带有以 `dolphindb` 开头的特定 tag,如 `dolphindb:"column:name,type:string"`
obj 可以为任意结构体对象,但是该结构体字段类型需要为数组,且字段带有以 `dolphindb` 开头的特定 tag,如 `dolphindb:"column:name;type:string"`
其中,column 后为列名,type 后为列数据类型(通过 model.GetDataTypeString 获取)。字段类型需要跟列数据类型匹配。

示例:

```go
type Example struct {
Name []string `dolphindb:"column:name,type:string"`
Name []string `dolphindb:"column:name;type:string"`
}

func main() {
Expand Down
2 changes: 1 addition & 1 deletion dialer/behavior.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (f *BehaviorOptions) GetPriority() int {
// GetParallelism gets the parallelism of the task.
func (f *BehaviorOptions) GetParallelism() int {
if f.Parallelism == nil {
return 2
return 64
}
return *f.Parallelism
}
Expand Down
2 changes: 1 addition & 1 deletion dialer/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (c *conn) handleGetClusterPerfError(n *node, err error) error {
}

func (c *conn) connectNode(n *node) (bool, error) {
// fmt.Println("Connect to ", n.address)
fmt.Println("Connect to ", n.address)
for !c.isClosed {
err := c.connect(n.address)
if err != nil {
Expand Down
80 changes: 80 additions & 0 deletions test/dbConnection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,83 @@ func TestConnectionHighAvailability(t *testing.T) {
})

}

func TestConnectionParallel(t *testing.T) {
t.Parallel()
db, err := api.NewSimpleDolphinDBClient(context.TODO(), host3, "admin", "123456")
AssertNil(err)
db.RunScript("login(`admin,`123456);try{createUser(`test1, `123456)}catch(ex){};go;setMaxJobParallelism(`test1, 10);")
Convey("TestConnectionParallel_lt_MaxJobParallelism", t, func() {

priority := 4
parallel := 1
opt := &dialer.BehaviorOptions{
Priority: &priority,
Parallelism: &parallel,
}
conn, err := api.NewDolphinDBClient(context.TODO(), host3, opt)
So(err, ShouldBeNil)
conn.Connect()
loginReq := &api.LoginRequest{
UserID: "test1",
Password: "123456",
}
err = conn.Login(loginReq)
So(err, ShouldBeNil)
res, _ := conn.RunScript("getConsoleJobs()")
Println(res)
So(res.(*model.Table).GetColumnByName("parallelism").Get(0).Value().(int32), ShouldEqual, 1)
So(res.(*model.Table).GetColumnByName("priority").Get(0).Value().(int32), ShouldEqual, 4)

conn.Close()
So(conn.IsClosed(), ShouldBeTrue)
})

Convey("TestConnectionParallel_gt_MaxJobParallelism", t, func() {

priority := 4
parallel := 11
opt := &dialer.BehaviorOptions{
Priority: &priority,
Parallelism: &parallel,
}
conn, err := api.NewDolphinDBClient(context.TODO(), host3, opt)
So(err, ShouldBeNil)
conn.Connect()
loginReq := &api.LoginRequest{
UserID: "test1",
Password: "123456",
}
err = conn.Login(loginReq)
So(err, ShouldBeNil)
res, _ := conn.RunScript("getConsoleJobs()")
Println(res)
So(res.(*model.Table).GetColumnByName("parallelism").Get(0).Value().(int32), ShouldEqual, 10)
So(res.(*model.Table).GetColumnByName("priority").Get(0).Value().(int32), ShouldEqual, 4)

conn.Close()
So(conn.IsClosed(), ShouldBeTrue)
})

Convey("TestConnectionParallel_default", t, func() {
conn, err := api.NewDolphinDBClient(context.TODO(), host3, nil)
So(err, ShouldBeNil)
conn.Connect()
loginReq := &api.LoginRequest{
UserID: "test1",
Password: "123456",
}
err = conn.Login(loginReq)
So(err, ShouldBeNil)
res, _ := conn.RunScript("getConsoleJobs()")
Println(res)
So(res.(*model.Table).GetColumnByName("parallelism").Get(0).Value().(int32), ShouldEqual, 10)
So(res.(*model.Table).GetColumnByName("priority").Get(0).Value().(int32), ShouldEqual, 4)

conn.Close()
So(conn.IsClosed(), ShouldBeTrue)
})

db.Close()
AssertEqual(db.IsClosed(), true)
}

0 comments on commit 80e1810

Please sign in to comment.