Skip to content

Commit

Permalink
release 3.00.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
YilunZhang39 committed Nov 5, 2024
1 parent 80e1810 commit a3c25a4
Show file tree
Hide file tree
Showing 132 changed files with 2,312 additions and 3,171 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h1 align="center">DolphinDB Go API</h1>

[![GitHub release](https://img.shields.io/github/release/dolphindb/api-go.svg?style=flat-square)](https://github.com/dolphindb/api-go/releases/latest)
[![PkgGoDev](https://img.shields.io/badge/go.dev-docs-007d9c?style=flat-square&logo=go&logoColor=white)](https://pkg.go.dev/github.com/dolphindb/api-go)
[![GitHub release](https://img.shields.io/github/release/dolphindb/api-go.svg?style=flat-square)](https://github.com/dolphindb/api-go/v3/releases/latest)
[![PkgGoDev](https://img.shields.io/badge/go.dev-docs-007d9c?style=flat-square&logo=go&logoColor=white)](https://pkg.go.dev/github.com/dolphindb/api-go/v3)

欢迎使用 DolphinDB Go API。您可以使用 Go API 连接 DolphinDB 数据库,进行建库建表,以及读取、写入数据等操作。

Expand Down Expand Up @@ -172,7 +172,7 @@ Go API 需要运行在 Go 1.15 或以上版本的环境。注意,Go API 只支
使用 `go get` 下载安装 `Go API`

```sh
go get -u github.com/dolphindb/api-go
go get -u github.com/dolphindb/api-go/v3
```

## 3. DolphinDB 基本用法
Expand All @@ -196,7 +196,7 @@ package main
import (
"context"

"github.com/dolphindb/api-go/api"
"github.com/dolphindb/api-go/v3/api"
)

func main() {
Expand Down Expand Up @@ -256,7 +256,7 @@ package main
import (
"context"

"github.com/dolphindb/api-go/api"
"github.com/dolphindb/api-go/v3/api"
)

func main() {
Expand Down Expand Up @@ -287,7 +287,7 @@ package main
import (
"context"

"github.com/dolphindb/api-go/api"
"github.com/dolphindb/api-go/v3/api"
)

func main() {
Expand Down Expand Up @@ -346,7 +346,7 @@ package main
import (
"fmt"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"
)

// new a bool datatype variable
Expand Down Expand Up @@ -552,8 +552,8 @@ import (
"context"
"fmt"

"github.com/dolphindb/api-go/api"
"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/api"
"github.com/dolphindb/api-go/v3/model"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"strings"

"github.com/dolphindb/api-go/dialer"
"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/dialer"
"github.com/dolphindb/api-go/v3/model"
)

// DolphinDB interface declares functions to communicate with the dolphindb server.
Expand Down
2 changes: 1 addition & 1 deletion api/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package api
import (
"fmt"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"
)

// Database is used to call table api based on the name of db.
Expand Down
4 changes: 2 additions & 2 deletions api/patitioned_table_appender.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"strings"

"github.com/dolphindb/api-go/domain"
"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/domain"
"github.com/dolphindb/api-go/v3/model"
)

// PartitionedTableAppender is used to append tables into a partitioned table.
Expand Down
2 changes: 1 addition & 1 deletion api/patitioned_table_appender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"
"time"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"

"github.com/stretchr/testify/assert"
)
Expand Down
7 changes: 4 additions & 3 deletions api/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"sync"
"time"

"github.com/dolphindb/api-go/dialer"
"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/dialer"
"github.com/dolphindb/api-go/v3/model"
)

// DBConnectionPool is the client which helps you to handle tasks with connections.
Expand All @@ -20,7 +20,7 @@ type DBConnectionPool struct {
loadBalanceAddresses []string

connections chan dialer.Conn
timeout time.Duration
timeout time.Duration
}

// PoolOption helps you to configure DBConnectionPool by calling NewDBConnectionPool.
Expand Down Expand Up @@ -123,6 +123,7 @@ func newConn(addr string, opt *PoolOption) (dialer.Conn, error) {
func (d *DBConnectionPool) RefreshTimeout(t time.Duration) {
d.timeout = t
}

// Execute executes all task by connections with DBConnectionPool.
func (d *DBConnectionPool) Execute(tasks []*Task) error {
wg := sync.WaitGroup{}
Expand Down
2 changes: 1 addition & 1 deletion api/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package api
import (
"testing"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"

"github.com/stretchr/testify/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion api/table.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package api

import (
"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"
)

// Table is the client of table script.
Expand Down
4 changes: 2 additions & 2 deletions api/table_appender.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package api
import (
"fmt"

"github.com/dolphindb/api-go/dialer"
"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/dialer"
"github.com/dolphindb/api-go/v3/model"
)

// TableAppender is used to append tables into another.
Expand Down
4 changes: 2 additions & 2 deletions api/table_appender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"
"time"

"github.com/dolphindb/api-go/dialer"
"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/dialer"
"github.com/dolphindb/api-go/v3/model"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion api/task.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package api

import "github.com/dolphindb/api-go/model"
import "github.com/dolphindb/api-go/v3/model"

// Task is the unit of work that is executed in the DBConnectionPool.
type Task struct {
Expand Down
2 changes: 1 addition & 1 deletion api/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package api
import (
"testing"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"

"github.com/stretchr/testify/assert"
)
Expand Down
6 changes: 6 additions & 0 deletions api/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import (
uuid "github.com/satori/go.uuid"
)

var API_VERSION = "3.00.0.1"

func GetAPIVersion() string {
return API_VERSION
}

func generateDBName() string {
u1 := uuid.NewV4()
return fmt.Sprintf("db_%s", u1.String()[:8])
Expand Down
4 changes: 2 additions & 2 deletions dialer/behavior.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ type BehaviorOptions struct {
LoadBalance bool

// Whether to enable high availability.
// If true, when the address is unrearched, another address in HighAvailabilitySites will be connected.
// If true, when the address is unreached, another address in HighAvailabilitySites will be connected.
EnableHighAvailability bool

// Available only when EnableHighAvailability is true.
HighAvailabilitySites []string

// If true, the address will be reconncted util the server is ready.
// If true, the address will be reconnected util the server is ready.
Reconnect bool

// IsReverseStreaming specifies whether the job is a reverse stream subscription
Expand Down
17 changes: 10 additions & 7 deletions dialer/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"sync"
"time"

"github.com/dolphindb/api-go/dialer/protocol"
"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/dialer/protocol"
"github.com/dolphindb/api-go/v3/model"
)

const (
Expand Down Expand Up @@ -109,6 +109,9 @@ func NewConn(ctx context.Context, addr string, behaviorOpt *BehaviorOptions) (Co
if !behaviorOpt.EnableHighAvailability && len(behaviorOpt.HighAvailabilitySites) != 0 {
fmt.Println("Warn: HighAvailabilitySites is not empty but EnableHighAvailability is false")
}
if behaviorOpt.Priority != nil && (*behaviorOpt.Priority < 0 || *behaviorOpt.Priority > 8) {
return nil, errors.New("the job priority must be between 0 and 8")
}
return &conn{
behaviorOpt: behaviorOpt,
addr: addr,
Expand Down Expand Up @@ -144,9 +147,10 @@ func NewSimpleConn(ctx context.Context, address, userID, pwd string) (Conn, erro
return conn, err
}

func (c *conn) GetReader() protocol.Reader {
func (c *conn) GetReader() protocol.Reader {
return c.reader
}

// Add an init script which will be run after you call connect
// func (c *conn) AddInitScript(script string) {
// if c.initScripts == nil {
Expand Down Expand Up @@ -236,9 +240,8 @@ func (c *conn) Connect() error {
return err
} else {
if c.reconnect {
c.nodePool = &nodePool{
nodes: []*node{{address: c.addr}},
}
c.nodePool = &nodePool{}
c.nodePool.add(&node{address: c.addr})
return c.switchDatanode(&node{address: ""})
} else {
ok, err := c.connectNode(&node{address: c.addr})
Expand Down Expand Up @@ -421,7 +424,7 @@ func (c *conn) runInternal(params *requestParams) (*responseHeader, model.DataFo
}

if c.behaviorOpt.GetFetchSize() > 0 && c.behaviorOpt.GetFetchSize() < 8192 {
return nil, nil, fmt.Errorf("fetchSize %d must be greater than 8192", c.behaviorOpt.GetFetchSize())
return nil, nil, fmt.Errorf("fetchSize %d must be equal or greater than 8192", c.behaviorOpt.GetFetchSize())
}
}

Expand Down
2 changes: 1 addition & 1 deletion dialer/dialer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
"time"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"

"github.com/stretchr/testify/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion dialer/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"time"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"
)

type node struct {
Expand Down
4 changes: 2 additions & 2 deletions dialer/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"strconv"

"github.com/dolphindb/api-go/dialer/protocol"
"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/dialer/protocol"
"github.com/dolphindb/api-go/v3/model"
)

type requestParams struct {
Expand Down
6 changes: 3 additions & 3 deletions dialer/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"fmt"
"strconv"

"github.com/dolphindb/api-go/dialer/protocol"
"github.com/dolphindb/api-go/errors"
"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/dialer/protocol"
"github.com/dolphindb/api-go/v3/errors"
"github.com/dolphindb/api-go/v3/model"
)

type responseHeader struct {
Expand Down
4 changes: 2 additions & 2 deletions dialer/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"strconv"
"strings"

"github.com/dolphindb/api-go/dialer/protocol"
"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/dialer/protocol"
"github.com/dolphindb/api-go/v3/model"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package domain
import (
"fmt"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"
)

// PartitionType decides how to append partitioned table.
Expand Down
2 changes: 1 addition & 1 deletion domain/domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package domain
import (
"testing"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"

"github.com/stretchr/testify/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion domain/hash_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"fmt"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"
)

// HashDomain implements the Domain interface.
Expand Down
2 changes: 1 addition & 1 deletion domain/hash_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"
"time"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"

"github.com/stretchr/testify/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion domain/list_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"fmt"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"
)

// ListDomain implements the Domain interface.
Expand Down
2 changes: 1 addition & 1 deletion domain/list_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"
"time"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"

"github.com/stretchr/testify/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion domain/range_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"fmt"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"
)

// RangeDomain implements the Domain interface.
Expand Down
2 changes: 1 addition & 1 deletion domain/range_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package domain
import (
"testing"

"github.com/dolphindb/api-go/model"
"github.com/dolphindb/api-go/v3/model"

"github.com/stretchr/testify/assert"
)
Expand Down
Loading

0 comments on commit a3c25a4

Please sign in to comment.