-
Notifications
You must be signed in to change notification settings - Fork 5
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
init #51
init #51
Conversation
nodejs/src/client/wsClient.ts
Outdated
|
||
export class WsClient { | ||
private _wsConnector?: WebSocketConnector; | ||
private _req_id = 1000000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsued
nodejs/src/client/wsClient.ts
Outdated
private _timeout?:number | undefined | null; | ||
private _url:URL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly?
nodejs/package.json
Outdated
"@types/jest": "^29.2.1", | ||
"@types/json-bigint": "^1.0.1", | ||
"@types/node": "^18.0.0", | ||
"@types/websocket": "^1.0npm install async-mutex.5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong version
@@ -0,0 +1,61 @@ | |||
import { createHash } from 'crypto'; | |||
import { v4 as uuidv4 } from 'uuid'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uuid not found
nodejs/src/common/taosResult.ts
Outdated
} | ||
|
||
export function readNchar(dataBuffer: ArrayBuffer, colDataHead: number, length: number): string { | ||
let decoder = new TextDecoder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused
nodejs/src/common/wsError.ts
Outdated
export class TaosResultError extends TDWebSocketClientError{}; | ||
export class TaosError extends TDWebSocketClientError{}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary semicolon
nodejs/src/common/wsError.ts
Outdated
ERR_WEBSOCKET_CONNECTION = 104, | ||
ERR_WEBSOCKET_QUERY_TIMEOUT = 105, | ||
ERR_INVALID_AUTHENTICATION = 106, | ||
ERR_UNSPPORTED_TDENGINE_TYPE = 107, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo? unsupported?
nodejs/src/sql/wsRows.ts
Outdated
try { | ||
let wsFetchResponse = await this._wsClient.fetch(this._wsQueryResponse); | ||
console.log("[wsQuery.execute.wsFetchResponse]==>\n", wsFetchResponse) | ||
if (wsFetchResponse.completed == true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified to wsFetchResponse.completed
nodejs/src/sql/wsRows.ts
Outdated
} | ||
|
||
this._taosResult = await this.getBlockData(); | ||
if (this._taosResult.GetData() == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'if' statement can be simplified
nodejs/src/sql/wsSql.ts
Outdated
try{ | ||
while (true) { | ||
let wsFetchResponse = await this._wsClient.fetch(wsQueryResponse) | ||
if (wsFetchResponse.completed == true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified to wsFetchResponse.completed
let err :any = e | ||
throw new TaosResultError(err.code, err.message); | ||
} finally { | ||
this._wsClient.freeResult(wsQueryResponse) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing await for an async function call ?
nodejs/src/tmq/config.ts
Outdated
user: string; | ||
password: string; | ||
group_id: string; | ||
clien_id: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
nodejs/src/tmq/tmqResponse.ts
Outdated
|
||
} | ||
|
||
export class CommitedResp extends PartitionsResp { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
nodejs/src/tmq/wsTmq.ts
Outdated
var taosResults: Map<string, TaosResult> = new Map(); | ||
let resp = await this._wsClient.exec(JSON.stringify(queryMsg), false); | ||
let pollResp = new WsPollResponse(resp) | ||
if (pollResp.have_message == false || pollResp.message_type != TMQMessageType.ResDataType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified to !pollResp.have_message
nodejs/src/tmq/wsTmq.ts
Outdated
// count++ | ||
let fetchResp = await this.fetch(pollResp) | ||
if (fetchResp.completed || fetchResp.rows == 0) { | ||
let currTime = new Date().getTime(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused
nodejs/src/client/wsConnectorPool.ts
Outdated
private static _instance?:WebSocketConnectionPool; | ||
private pool: Map<string, WebSocketConnector[]> = new Map(); | ||
private _connectionCount: number; | ||
private _maxConnections: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly?
nodejs/src/sql/wsRows.ts
Outdated
return | ||
} | ||
this._isClose = true | ||
this._wsClient.freeResult(this._wsQueryResponse) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need .then()?
nodejs/src/sql/wsRows.ts
Outdated
|
||
export class WSRows { | ||
private _wsClient: WsClient; | ||
private _wsQueryResponse: WSQueryResponse; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly?
nodejs/example/basicSql.ts
Outdated
let result = await wsRows.GetData(); | ||
console.log('queryRes.Scan().then=>', result); | ||
} | ||
await wsRows.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrRows.Close is a synchronous function
nodejs/src/sql/wsSql.ts
Outdated
let tmp: TaosResult = await this._wsClient.fetchBlock(wsFetchResponse, taosResult); | ||
taosResult = tmp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is redundant
nodejs/src/stmt/wsParams.ts
Outdated
private precisionLength:number = PrecisionLength['ms'] | ||
private _params: ColumnInfo[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comments
nodejs/src/common/taosResult.ts
Outdated
public GetTotalTime() { | ||
return this._totalTime; | ||
} | ||
public AddtotalTime(totalTime:number) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AddtotalTime -> AddTotalTime
need to format and add automatic tests |
nodejs/example/basicSchemaless.ts
Outdated
import { sqlConnect } from '../index'; | ||
let dsn = 'ws://root:[email protected]:6051/ws'; | ||
let db = 'power' | ||
let influxdbData = "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
尽量使用 meters 表做用例
nodejs/example/basicSql.ts
Outdated
import { WSConfig } from '../src/common/config'; | ||
import { sqlConnect } from '../index' | ||
|
||
let dsn = 'ws://root:[email protected]:6051/ws'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最后的 ws 是数据库吗,如果不是,是端点,不要体现出来,Adapter 的 路径对外不可见
nodejs/example/basicTmq.ts
Outdated
[TMQConstants.CONNECT_PASS, "taosdata"], | ||
[TMQConstants.AUTO_OFFSET_RESET, "earliest"], | ||
[TMQConstants.CLIENT_ID, 'test_tmq_client'], | ||
[TMQConstants.WS_URL, 'ws://192.168.1.95:6051/rest/tmq'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest/tmq 不要暴露
- **host/port**: Declare host and port. eg. `localhost:6041` | ||
- **database**: Optional, use to specify database name. | ||
- **params**: Other parameters. Like cloud Token. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dsn 定义是对的,严格按照这个来解析
|
||
``` typescript | ||
import {connect} from '@tdengine/websocket' | ||
let dsn = "ws://host:port/rest/ws/db" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里跟上面 dsn 对不上
nodejs/src/sql/wsSql.ts
Outdated
}) | ||
} | ||
|
||
async execute(sql: string, reqId?: number, action:string = 'query'): Promise<TaosResult> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
schemaless 不支持sql
nodejs/src/stmt/wsParams.ts
Outdated
} | ||
|
||
|
||
private encodeColumnNumbers(params:any[], dataType:string = 'number', typeLen:number, columnType:number):[number, ArrayBuffer] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
方法名好像只处理 number 类型
nodejs/src/tmq/wsTmq.ts
Outdated
// let count = 0 | ||
// let startTime = new Date().getTime(); | ||
while (true) { | ||
// count++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
无用代码都应该删除,不要注释掉
for (let i = 0; i < actualData.length; i++) { | ||
actualData[i].forEach((d, index) => { | ||
if (expectMeta[index].name == 'geo' || expectMeta[index].name == 'vbinary') { | ||
expect(d).toBeTruthy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为何这两种类型没有仔细检查?
wsSchemaless.Close(); | ||
}); | ||
|
||
test('normal wsSql insert', async() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里都没有check
No description provided.