Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh: adapts to new websocket interface #233

Merged
merged 2 commits into from
Jan 22, 2024
Merged
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
6 changes: 1 addition & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ on:
required: true
type: string

env:
SCCACHE_GHA_ENABLED: "true"

jobs:
build:
Expand Down Expand Up @@ -44,8 +42,6 @@ jobs:
cd TDengine
echo "commit_id=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT

- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: Cache server by pr
if: github.event_name == 'pull_request'
Expand Down Expand Up @@ -77,7 +73,7 @@ jobs:
cd TDengine
mkdir debug
cd debug
cmake .. -DBUILD_TEST=off -DBUILD_HTTP=false -DVERNUMBER=3.9.9.9 -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
cmake .. -DBUILD_TEST=off -DBUILD_HTTP=false -DVERNUMBER=3.9.9.9
make -j 4

- name: package
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ on:
- 'main'
- '3.0'

env:
SCCACHE_GHA_ENABLED: "true"

jobs:
build:
Expand All @@ -29,8 +27,6 @@ jobs:
cd TDengine
echo "commit_id=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT

- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: Cache server
id: cache-server
Expand All @@ -43,16 +39,14 @@ jobs:
if: steps.cache-server.outputs.cache-hit != 'true'
run: sudo apt install -y libgeos-dev

- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: install TDengine
if: steps.cache-server.outputs.cache-hit != 'true'
run: |
cd TDengine
mkdir debug
cd debug
cmake .. -DBUILD_JDBC=false -DBUILD_TEST=off -DBUILD_HTTP=false -DVERNUMBER=3.9.9.9 -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
cmake .. -DBUILD_JDBC=false -DBUILD_TEST=off -DBUILD_HTTP=false -DVERNUMBER=3.9.9.9
make -j 4

- name: package
Expand Down
2 changes: 1 addition & 1 deletion examples/stmtoverws/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func main() {
defer db.Close()
prepareEnv(db)

config := stmt.NewConfig("ws://127.0.0.1:6041/rest/stmt", 0)
config := stmt.NewConfig("ws://127.0.0.1:6041", 0)
config.SetConnectUser("root")
config.SetConnectPass("taosdata")
config.SetConnectDB("example_ws_stmt")
Expand Down
2 changes: 1 addition & 1 deletion examples/tmqoverws/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func main() {
defer db.Close()
prepareEnv(db)
consumer, err := tmq.NewConsumer(&tmqcommon.ConfigMap{
"ws.url": "ws://127.0.0.1:6041/rest/tmq",
"ws.url": "ws://127.0.0.1:6041",
"ws.message.channelLen": uint(0),
"ws.message.timeout": common.DefaultMessageTimeout,
"ws.message.writeWait": common.DefaultWriteWait,
Expand Down
4 changes: 1 addition & 3 deletions ws/schemaless/schemaless.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ func NewSchemaless(config *Config) (*Schemaless, error) {
if wsUrl.Scheme != "ws" && wsUrl.Scheme != "wss" {
return nil, errors.New("config url scheme error")
}
if len(wsUrl.Path) == 0 || wsUrl.Path != "/rest/schemaless" {
wsUrl.Path = "/rest/schemaless"
}
wsUrl.Path = "/ws"
dialer := common.DefaultDialer
dialer.EnableCompression = config.enableCompression
ws, _, err := dialer.Dial(wsUrl.String(), nil)
Expand Down
2 changes: 1 addition & 1 deletion ws/schemaless/schemaless_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestSchemaless_Insert(t *testing.T) {
}
defer func() { _ = after() }()

s, err := NewSchemaless(NewConfig("ws://localhost:6041/rest/schemaless", 1,
s, err := NewSchemaless(NewConfig("ws://localhost:6041", 1,
SetDb("test_schemaless_ws"),
SetReadTimeout(10*time.Second),
SetWriteTimeout(10*time.Second),
Expand Down
8 changes: 7 additions & 1 deletion ws/stmt/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
"net/url"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -46,7 +47,12 @@ func NewConnector(config *Config) (*Connector, error) {
}
dialer := common.DefaultDialer
dialer.EnableCompression = config.EnableCompression
ws, _, err := dialer.Dial(config.Url, nil)
u, err := url.Parse(config.Url)
if err != nil {
return nil, err
}
u.Path = "/ws"
ws, _, err := dialer.Dial(u.String(), nil)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion ws/stmt/stmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func TestStmt(t *testing.T) {
}
defer cleanEnv()
now := time.Now()
config := NewConfig("ws://127.0.0.1:6041/rest/stmt", 0)
config := NewConfig("ws://127.0.0.1:6041", 0)
config.SetConnectUser("root")
config.SetConnectPass("taosdata")
config.SetConnectDB("test_ws_stmt")
Expand Down
8 changes: 7 additions & 1 deletion ws/tmq/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"net/url"
"strconv"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -79,7 +80,12 @@ func NewConsumer(conf *tmq.ConfigMap) (*Consumer, error) {

dialer := common.DefaultDialer
dialer.EnableCompression = config.EnableCompression
ws, _, err := dialer.Dial(config.Url, nil)
u, err := url.Parse(config.Url)
if err != nil {
return nil, err
}
u.Path = "/rest/tmq"
ws, _, err := dialer.Dial(u.String(), nil)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions ws/tmq/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestConsumer(t *testing.T) {
}
}()
consumer, err := NewConsumer(&tmq.ConfigMap{
"ws.url": "ws://127.0.0.1:6041/rest/tmq",
"ws.url": "ws://127.0.0.1:6041",
"ws.message.channelLen": uint(0),
"ws.message.timeout": common.DefaultMessageTimeout,
"ws.message.writeWait": common.DefaultWriteWait,
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestSeek(t *testing.T) {
}
defer cleanSeekEnv()
consumer, err := NewConsumer(&tmq.ConfigMap{
"ws.url": "ws://127.0.0.1:6041/rest/tmq",
"ws.url": "ws://127.0.0.1:6041",
"ws.message.channelLen": uint(0),
"ws.message.timeout": common.DefaultMessageTimeout,
"ws.message.writeWait": common.DefaultWriteWait,
Expand Down Expand Up @@ -394,7 +394,7 @@ func TestAutoCommit(t *testing.T) {
}
defer cleanAutocommitEnv()
consumer, err := NewConsumer(&tmq.ConfigMap{
"ws.url": "ws://127.0.0.1:6041/rest/tmq",
"ws.url": "ws://127.0.0.1:6041",
"ws.message.channelLen": uint(0),
"ws.message.timeout": common.DefaultMessageTimeout,
"ws.message.writeWait": common.DefaultWriteWait,
Expand Down