modify node ci example
This commit is contained in:
parent
63d62fdfd3
commit
a4b35af11b
|
@ -4,8 +4,6 @@
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tdengine/client": "^3.0.1",
|
|
||||||
"@tdengine/rest": "^3.0.0",
|
|
||||||
"@tdengine/websocket": "^3.1.0"
|
"@tdengine/websocket": "^3.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,9 +92,11 @@ async function all_type_example() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function test() {
|
async function test() {
|
||||||
|
console.log("begin all_type_query")
|
||||||
await json_tag_example()
|
await json_tag_example()
|
||||||
await all_type_example()
|
await all_type_example()
|
||||||
taos.destroy();
|
taos.destroy();
|
||||||
|
console.log("end all_type_query")
|
||||||
}
|
}
|
||||||
|
|
||||||
test()
|
test()
|
||||||
|
|
|
@ -139,9 +139,11 @@ async function all_type_example() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function test() {
|
async function test() {
|
||||||
|
console.log("begin all_type_stmt")
|
||||||
await json_tag_example()
|
await json_tag_example()
|
||||||
await all_type_example()
|
await all_type_example()
|
||||||
taos.destroy();
|
taos.destroy();
|
||||||
|
console.log("end all_type_stmt")
|
||||||
}
|
}
|
||||||
|
|
||||||
test()
|
test()
|
||||||
|
|
|
@ -51,7 +51,9 @@ async function schemalessInsert() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function test() {
|
async function test() {
|
||||||
|
console.log("begin json_line_example")
|
||||||
await schemalessInsert();
|
await schemalessInsert();
|
||||||
|
console.log("end json_line_example")
|
||||||
}
|
}
|
||||||
|
|
||||||
test()
|
test()
|
|
@ -43,7 +43,9 @@ async function schemalessInsert() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function test() {
|
async function test() {
|
||||||
await schemalessInsert();
|
console.log("begin line_example")
|
||||||
|
await schemalessInsert();
|
||||||
|
console.log("end line_example")
|
||||||
}
|
}
|
||||||
|
|
||||||
test()
|
test()
|
||||||
|
|
|
@ -74,7 +74,9 @@ async function execSql() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function test() {
|
async function test() {
|
||||||
|
console.log("begin nodejsChecker")
|
||||||
await execSql();
|
await execSql();
|
||||||
|
console.log("end nodejsChecker")
|
||||||
}
|
}
|
||||||
|
|
||||||
test()
|
test()
|
|
@ -136,11 +136,13 @@ async function sqlWithReqid() {
|
||||||
// ANCHOR_END: sqlWithReqid
|
// ANCHOR_END: sqlWithReqid
|
||||||
|
|
||||||
async function test() {
|
async function test() {
|
||||||
|
console.log("begin sql_example")
|
||||||
await createDbAndTable();
|
await createDbAndTable();
|
||||||
await insertData();
|
await insertData();
|
||||||
await queryData();
|
await queryData();
|
||||||
await sqlWithReqid();
|
await sqlWithReqid();
|
||||||
taos.destroy();
|
taos.destroy();
|
||||||
|
console.log("end sql_example")
|
||||||
}
|
}
|
||||||
|
|
||||||
test()
|
test()
|
||||||
|
|
|
@ -74,7 +74,9 @@ async function stmtInsert() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function test () {
|
async function test () {
|
||||||
|
console.log("begin stmt_example")
|
||||||
await stmtInsert();
|
await stmtInsert();
|
||||||
|
console.log("end stmt_example")
|
||||||
}
|
}
|
||||||
|
|
||||||
test()
|
test()
|
|
@ -58,7 +58,9 @@ async function schemalessInsert() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function test() {
|
async function test() {
|
||||||
|
console.log("begin telnet_line_example")
|
||||||
await schemalessInsert();
|
await schemalessInsert();
|
||||||
|
console.log("end telnet_line_example")
|
||||||
}
|
}
|
||||||
|
|
||||||
test()
|
test()
|
|
@ -1,3 +1,4 @@
|
||||||
|
const { sleep } = require("@tdengine/websocket");
|
||||||
const taos = require("@tdengine/websocket");
|
const taos = require("@tdengine/websocket");
|
||||||
|
|
||||||
// ANCHOR: create_consumer
|
// ANCHOR: create_consumer
|
||||||
|
@ -49,10 +50,18 @@ async function prepare() {
|
||||||
|
|
||||||
let createTopic = `CREATE TOPIC IF NOT EXISTS ${topics[0]} AS SELECT * FROM ${db}.${stable}`;
|
let createTopic = `CREATE TOPIC IF NOT EXISTS ${topics[0]} AS SELECT * FROM ${db}.${stable}`;
|
||||||
await wsSql.exec(createTopic);
|
await wsSql.exec(createTopic);
|
||||||
|
wsSql.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function insert() {
|
||||||
for (let i = 0; i < 10; i++) {
|
let conf = new taos.WSConfig('ws://localhost:6041');
|
||||||
|
conf.setUser('root');
|
||||||
|
conf.setPwd('taosdata');
|
||||||
|
conf.setDb('power');
|
||||||
|
let wsSql = await taos.sqlConnect(conf);
|
||||||
|
for (let i = 0; i < 50; i++) {
|
||||||
await wsSql.exec(`INSERT INTO d1001 USING ${stable} (location, groupId) TAGS ("California.SanFrancisco", 3) VALUES (NOW, ${10 + i}, ${200 + i}, ${0.32 + i})`);
|
await wsSql.exec(`INSERT INTO d1001 USING ${stable} (location, groupId) TAGS ("California.SanFrancisco", 3) VALUES (NOW, ${10 + i}, ${200 + i}, ${0.32 + i})`);
|
||||||
|
await sleep(100);
|
||||||
}
|
}
|
||||||
wsSql.close();
|
wsSql.close();
|
||||||
}
|
}
|
||||||
|
@ -82,8 +91,11 @@ async function consumer() {
|
||||||
let consumer = null;
|
let consumer = null;
|
||||||
try {
|
try {
|
||||||
await prepare();
|
await prepare();
|
||||||
consumer = await createConsumer()
|
consumer = await createConsumer();
|
||||||
await subscribe(consumer)
|
const allPromises = [];
|
||||||
|
allPromises.push(subscribe(consumer));
|
||||||
|
allPromises.push(insert());
|
||||||
|
await Promise.all(allPromises);
|
||||||
await consumer.unsubscribe();
|
await consumer.unsubscribe();
|
||||||
console.log("Consumer unsubscribed successfully.");
|
console.log("Consumer unsubscribed successfully.");
|
||||||
}
|
}
|
||||||
|
@ -102,7 +114,9 @@ async function consumer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function test() {
|
async function test() {
|
||||||
await consumer();
|
console.log("begin tmq_example")
|
||||||
|
await consumer();
|
||||||
|
console.log("end tmq_example")
|
||||||
}
|
}
|
||||||
|
|
||||||
test()
|
test()
|
||||||
|
|
|
@ -101,7 +101,9 @@ async function consumer() {
|
||||||
// ANCHOR_END: offset
|
// ANCHOR_END: offset
|
||||||
|
|
||||||
async function test() {
|
async function test() {
|
||||||
|
console.log("begin tmq_seek_example")
|
||||||
await consumer();
|
await consumer();
|
||||||
|
console.log("end tmq_seek_example")
|
||||||
}
|
}
|
||||||
|
|
||||||
test()
|
test()
|
||||||
|
|
Loading…
Reference in New Issue