Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions taosWS/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

"github.com/gorilla/websocket"
jsoniter "github.com/json-iterator/go"

"github.com/taosdata/driver-go/v3/common"
stmtCommon "github.com/taosdata/driver-go/v3/common/stmt"
"github.com/taosdata/driver-go/v3/common/tdversion"
Expand Down Expand Up @@ -86,6 +87,12 @@ func newTaosConn(cfg *Config) (*taosConn, error) {
}
endpoint := endpointUrl.String()
dialer := common.DefaultDialer
if cfg.ReadBufferSize > 0 {
dialer.ReadBufferSize = cfg.ReadBufferSize
}
if cfg.WriteBufferSize > 0 {
dialer.WriteBufferSize = cfg.WriteBufferSize
}
dialer.EnableCompression = cfg.EnableCompression
ws, _, err := dialer.Dial(endpoint, nil)
if err != nil {
Expand Down
14 changes: 13 additions & 1 deletion taosWS/dsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type Config struct {
Timezone *time.Location // Timezone for connection, e.g., "Asia%2FShanghai" or "UTC"
BearerToken string // BearerToken for TSDB auth
TotpCode string // TOTP code for TSDB TOTP auth
ReadBufferSize int // Read buffer size
WriteBufferSize int // Write buffer size
}

// NewConfig creates a new Config and sets default values.
Expand Down Expand Up @@ -88,7 +90,7 @@ func ParseDSN(dsn string) (cfg *Config, err error) {
if strings.ContainsRune(dsn[k+1:i], ')') {
return nil, ErrInvalidDSNUnescaped
}
//return nil, errInvalidDSNAddr
// return nil, errInvalidDSNAddr
}
addr := dsn[k+1 : i-1]
host, port, err := net.SplitHostPort(addr)
Expand Down Expand Up @@ -178,6 +180,16 @@ func parseDSNParams(cfg *Config, params string) (err error) {
cfg.BearerToken = value
case "totpCode":
cfg.TotpCode = value
case "readBufferSize", "writeBufferSize":
val, err := strconv.Atoi(value)
if err != nil {
return &errors.TaosError{Code: 0xffff, ErrStr: "invalid " + param[0] + " value: " + value}
}
if param[0] == "readBufferSize" {
cfg.ReadBufferSize = val
} else {
cfg.WriteBufferSize = val
}
default:
// lazy init
if cfg.Params == nil {
Expand Down
Loading