Skip to content

Commit

Permalink
Merge branch '3.0' of github.com:taosdata/driver-go into 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
godLei6 committed Nov 30, 2023
2 parents 6f7fe3a + c8d83d5 commit 8887e9d
Show file tree
Hide file tree
Showing 72 changed files with 5,873 additions and 1,010 deletions.
160 changes: 136 additions & 24 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,154 @@
name: Go

on: [ push,pull_request ]
on:
pull_request:
branches:
- 'main'
- '3.0'
workflow_dispatch:
inputs:
tbBranch:
description: 'TDengine branch'
required: true
type: string

env:
SCCACHE_GHA_ENABLED: "true"

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.14', '1.19' ]
name: Go ${{ matrix.go }}
runs-on: ubuntu-22.04
name: Build
outputs:
commit_id: ${{ steps.get_commit_id.outputs.commit_id }}
steps:
- name: checkout
- name: checkout TDengine by pr
if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
path: 'driver-go'
- name: checkout TDengine
repository: 'taosdata/TDengine'
path: 'TDengine'
ref: ${{ github.base_ref }}

- name: checkout TDengine manually
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v3
with:
repository: 'taosdata/TDengine'
path: 'TDengine'
ref: 'main'
ref: ${{ inputs.tbBranch }}

- name: get_commit_id
id: get_commit_id
run: |
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'
id: cache-server-pr
uses: actions/cache@v3
with:
path: server.tar.gz
key: ${{ runner.os }}-build-${{ github.base_ref }}-${{ steps.get_commit_id.outputs.commit_id }}

- name: Cache server manually
if: github.event_name == 'workflow_dispatch'
id: cache-server-manually
uses: actions/cache@v3
with:
path: server.tar.gz
key: ${{ runner.os }}-build-${{ inputs.tbBranch }}-${{ steps.get_commit_id.outputs.commit_id }}

- name: prepare install
if: >
(github.event_name == 'workflow_dispatch' && steps.cache-server-manually.outputs.cache-hit != 'true') ||
(github.event_name == 'pull_request' && steps.cache-server-pr.outputs.cache-hit != 'true')
run: sudo apt install -y libgeos-dev

- name: install TDengine
if: >
(github.event_name == 'workflow_dispatch' && steps.cache-server-manually.outputs.cache-hit != 'true') ||
(github.event_name == 'pull_request' && steps.cache-server-pr.outputs.cache-hit != 'true')
run: |
cd TDengine
mkdir debug
cd debug
cmake .. -DBUILD_JDBC=false -DBUILD_TOOLS=false -DBUILD_HTTP=false -DBUILD_TEST=off
make -j32
sudo make install
cmake .. -DBUILD_TEST=off -DBUILD_HTTP=false -DVERNUMBER=3.9.9.9 -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
make -j 4
- name: package
if: >
(github.event_name == 'workflow_dispatch' && steps.cache-server-manually.outputs.cache-hit != 'true') ||
(github.event_name == 'pull_request' && steps.cache-server-pr.outputs.cache-hit != 'true')
run: |
mkdir -p ./release
cp ./TDengine/debug/build/bin/taos ./release/
cp ./TDengine/debug/build/bin/taosd ./release/
cp ./TDengine/tools/taosadapter/taosadapter ./release/
cp ./TDengine/debug/build/lib/libtaos.so.3.9.9.9 ./release/
cp ./TDengine/debug/build/lib/librocksdb.so.8.1.1 ./release/ ||:
cp ./TDengine/include/client/taos.h ./release/
cat >./release/install.sh<<EOF
chmod +x ./taos
chmod +x ./taosd
chmod +x ./taosadapter
cp ./taos /bin/
cp ./taosd /bin/
cp ./taosadapter /bin/
cp ./libtaos.so.3.9.9.9 /usr/lib
cp ./librocksdb.so.8.1.1 /usr/lib ||:
ln -sf /usr/lib/libtaos.so.3.9.9.9 /usr/lib/libtaos.so.1
ln -sf /usr/lib/libtaos.so.1 /usr/lib/libtaos.so
ln -sf /usr/lib/librocksdb.so.8.1.1 /usr/lib/librocksdb.so.8 ||:
ln -sf /usr/lib/librocksdb.so.8 /usr/lib/librocksdb.so ||:
cp ./taos.h /usr/include
EOF
tar -zcvf server.tar.gz ./release
test:
runs-on: ubuntu-22.04
needs: build
strategy:
matrix:
go: [ '1.14', '1.19' ]
name: Go ${{ matrix.go }}
steps:
- name: get cache server by pr
if: github.event_name == 'pull_request'
id: get-cache-server-pr
uses: actions/cache@v3
with:
path: server.tar.gz
key: ${{ runner.os }}-build-${{ github.base_ref }}-${{ needs.build.outputs.commit_id }}
restore-keys: |
${{ runner.os }}-build-${{ github.base_ref }}-
- name: cache server manually
if: github.event_name == 'workflow_dispatch'
id: get-cache-server-manually
uses: actions/cache@v3
with:
path: server.tar.gz
key: ${{ runner.os }}-build-${{ inputs.tbBranch }}-${{ needs.build.outputs.commit_id }}
restore-keys: |
${{ runner.os }}-build-${{ inputs.tbBranch }}-
- name: checkout
uses: actions/checkout@v3
with:
path: 'driver-go'

- name: prepare install
run: sudo apt install -y libgeos-dev

- name: install
run: |
tar -zxvf server.tar.gz
cd release && sudo sh install.sh
- name: shell
run: |
Expand All @@ -40,21 +160,13 @@ jobs:
run: nohup sudo sh ./start.sh &

- name: start taosadapter
run: sudo taosadapter &
run: sudo taosadapter &

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}

- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go }}-${{ hashFiles('driver-go/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go }}-
cache-dependency-path: driver-go/go.sum

- name: Test
run: cd ./driver-go && go test -v ./...
134 changes: 134 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: push

on:
push:
branches:
- 'main'
- '3.0'

env:
SCCACHE_GHA_ENABLED: "true"

jobs:
build:
runs-on: ubuntu-22.04
name: Build
outputs:
commit_id: ${{ steps.get_commit_id.outputs.commit_id }}
steps:
- name: checkout TDengine
uses: actions/checkout@v3
with:
repository: 'taosdata/TDengine'
path: 'TDengine'
ref: ${{ github.ref_name }}

- name: get_commit_id
id: get_commit_id
run: |
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
uses: actions/cache@v3
with:
path: server.tar.gz
key: ${{ runner.os }}-build-${{ github.ref_name }}-${{ steps.get_commit_id.outputs.commit_id }}

- name: prepare install
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
make -j 4
- name: package
if: steps.cache-server.outputs.cache-hit != 'true'
run: |
mkdir -p ./release
cp ./TDengine/debug/build/bin/taos ./release/
cp ./TDengine/debug/build/bin/taosd ./release/
cp ./TDengine/tools/taosadapter/taosadapter ./release/
cp ./TDengine/debug/build/lib/libtaos.so.3.9.9.9 ./release/
cp ./TDengine/debug/build/lib/librocksdb.so.8.1.1 ./release/ ||:
cp ./TDengine/include/client/taos.h ./release/
cat >./release/install.sh<<EOF
chmod +x ./taos
chmod +x ./taosd
chmod +x ./taosadapter
cp ./taos /bin/
cp ./taosd /bin/
cp ./taosadapter /bin/
cp ./libtaos.so.3.9.9.9 /usr/lib
cp ./librocksdb.so.8.1.1 /usr/lib ||:
ln -sf /usr/lib/libtaos.so.3.9.9.9 /usr/lib/libtaos.so.1
ln -sf /usr/lib/libtaos.so.1 /usr/lib/libtaos.so
ln -sf /usr/lib/librocksdb.so.8.1.1 /usr/lib/librocksdb.so.8 ||:
ln -sf /usr/lib/librocksdb.so.8 /usr/lib/librocksdb.so ||:
cp ./taos.h /usr/include
EOF
tar -zcvf server.tar.gz ./release
test:
runs-on: ubuntu-22.04
needs: build
strategy:
matrix:
go: [ '1.14', '1.19' ]
name: Go ${{ matrix.go }}
steps:
- name: get cache server
id: get-cache-server
uses: actions/cache@v3
with:
path: server.tar.gz
key: ${{ runner.os }}-build-${{ github.ref_name }}-${{ needs.build.outputs.commit_id }}
restore-keys: |
${{ runner.os }}-build-${{ github.ref_name }}-
- name: checkout
uses: actions/checkout@v3
with:
path: 'driver-go'

- name: prepare install
run: sudo apt install -y libgeos-dev

- name: install
run: |
tar -zxvf server.tar.gz
cd release && sudo sh install.sh
- name: shell
run: |
cat >start.sh<<EOF
ulimit -n 65535 && TAOS_SUPPORT_VNODES=256 taosd
EOF
- name: taosd
run: nohup sudo sh ./start.sh &

- name: start taosadapter
run: sudo taosadapter &

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
cache-dependency-path: driver-go/go.sum

- name: Test
run: cd ./driver-go && go test -v ./...
37 changes: 30 additions & 7 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@

v2 与 v3 版本不兼容,与 TDengine 版本对应如下:

| **driver-go 版本** | **TDengine 版本** |
|------------------|-----------------|
| v3.0.0 | 3.0.0.0+ |
| v3.0.1 | 3.0.0.0+ |
| v3.0.3 | 3.0.1.5+ |
| v3.0.4 | 3.0.2.2+ |
| v3.1.0 | 3.0.2.2+ |
| **driver-go 版本** | **TDengine 版本** | **主要功能** |
|------------------|-----------------|--------------------------------|
| v3.5.0 | 3.0.5.0+ | 获取消费进度及按照指定进度开始消费 |
| v3.3.1 | 3.0.4.1+ | 基于 websocket 的 schemaless 协议写入 |
| v3.1.0 | 3.0.2.2+ | 提供贴近 kafka 的订阅 api |
| v3.0.4 | 3.0.2.2+ | 新增 request id 相关接口 |
| v3.0.3 | 3.0.1.5+ | 基于 websocket 的 statement 写入 |
| v3.0.2 | 3.0.1.5+ | 基于 websocket 的数据查询和写入 |
| v3.0.1 | 3.0.0.0+ | 基于 websocket 的消息订阅 |
| v3.0.0 | 3.0.0.0+ | 适配 TDengine 3.0 查询和写入 |

## 安装

Expand Down Expand Up @@ -157,6 +160,18 @@ func (c *Consumer) Poll(timeoutMs int) tmq.Event
func (c *Consumer) Commit() ([]tmq.TopicPartition, error)
```

获取消费进度:

```go
func (c *Consumer) Assignment() (partitions []tmq.TopicPartition, err error)
```

按照指定的进度消费:

```go
func (c *Consumer) Seek(partition tmq.TopicPartition, ignoredTimeoutMs int) error
```

取消订阅:

```go
Expand Down Expand Up @@ -533,6 +548,14 @@ DSN 格式为:

提交消息。

- `func (c *Consumer) Assignment() (partitions []tmq.TopicPartition, err error)`

获取消费进度。

- `func (c *Consumer) Seek(partition tmq.TopicPartition, ignoredTimeoutMs int) error`

按照指定的进度消费。

- `func (c *Consumer) Close() error`

关闭连接。
Expand Down
Loading

0 comments on commit 8887e9d

Please sign in to comment.