Closed wujjpp closed 2 years ago
@wey-gu here is the pr, pls take a look.
@wey-gu here is the pr, pls take a look.
Thank you @Reid00 @wujjpp! Great Job! You even fixed two issues on upstream apache thrift 👍🏻. We will look into it.
Best Regards, Wey
@wey-gu 这个PR还合吗?
We'll deal with it in this week, thanks for your following🤝
@wey-gu 这个PR还合吗?
Sorry for the late response, sure we will, hopefully it could be done in short time as aligned with @nianiaJR
@wujjpp Is there any plan to make up the unit test/example in future?
I find it only like a
todo
demo about test?
I have a full test case located at tests/nebula.test-disabled
, but I didn't have nebula
enviroment for testing in github env.
So, I rename nebula.test.ts
to nebula.test-disabled
, you can revert its name and add unit tests for testing.
BTW, those test cases are based on our nebula production server.
/* eslint-disable max-len */
/**
* Created by Wu Jian Ping on - 2021/06/09.
*/
import { expect } from 'chai'
import createClient, { ClientOption } from '../dist'
const relationServer: ClientOption = {
servers: ['10.0.1.100:9669', '10.0.1.101:9669', '10.0.1.102:9669'],
userName: 'xxxxx',
space: 'xxxxx',
database: 'partion1',
pingInterval: 5000,
poolSize: 2
}
const riskInfoServer: ClientOption = {
servers: ['10.0.1.100:9669', '10.0.1.101:9669', '10.0.1.102:9669'],
userName: 'xxxxx',
space: 'xxxxx',
database: 'partion2',
pingInterval: 5000,
poolSize: 2
}
const commands = {
cmd1: 'GET SUBGRAPH 2 STEPS FROM -7897618527020261406',
cmd2: 'fetch prop on Company -7897618527020261406',
cmd3: 'go from 815677140545765099 over Relation yield Relation._src as src, Relation._dst as dst, Relation.relation_name as relation_name, Relation.prop1 as prop1, Relation.prop2 as prop2, Relation.prop3 as prop3, Relation.prop4 as prop4, $^.Person.name as src_p_name, $^.Company.name as src_c_name, $$.Person.name as dst_p_name, $$.Company.name as dst_c_name | limit 1000',
cmd4: 'find noloop path from -4075961126534726064 to 815677140545765099 over Relation bidirect upto 2 steps',
cmd5: 'fetch prop on Relation -4075961126534726064->815677140545765099@-5101473608195470769'
}
describe('nebula', () => {
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
it('test-case-1', async () => {
const client = createClient(relationServer)
const response1 = await client.execute(commands.cmd1)
expect(response1.data?._vertices?.length).greaterThan(0)
expect(response1.data?._edges?.length).greaterThan(0)
await client.close()
})
it('test-case-2', async () => {
const client = createClient(relationServer)
const response1 = await client.execute(commands.cmd2)
expect(response1.data?.vertices_?.length).greaterThan(0)
await client.close()
})
it('test-case-3', async () => {
const client = createClient(riskInfoServer)
const response1 = await client.execute(commands.cmd3)
expect(response1.data?.src?.length).greaterThan(0)
await client.close()
})
it('test-case-4', async () => {
const client = createClient(riskInfoServer)
const response1 = await client.execute(commands.cmd4)
expect(response1.data?.path?.length).greaterThan(0)
await client.close()
})
it('test-case-5', async () => {
const client = createClient(riskInfoServer)
const response1 = await client.execute(commands.cmd5)
expect(response1.data?.edges_?.length).greaterThan(0)
await client.close()
})
it('test-promise-all', async () => {
const client = createClient(relationServer)
const [resp1, resp2, resp3] = await Promise.all([
client.execute('GET SUBGRAPH 1 STEPS FROM -7897618527020261406', false),
client.execute('GET SUBGRAPH 2 STEPS FROM -7897618527020261406', false),
client.execute('GET SUBGRAPH 3 STEPS FROM -7897618527020261406', false)
])
console.log(`resp11:${resp1.data._vertices.length}, ${resp1.data._edges.length}`) // eslint-disable-line
console.log(`resp21:${resp2.data._vertices.length}, ${resp2.data._edges.length}`) // eslint-disable-line
console.log(`resp31:${resp3.data._vertices.length}, ${resp3.data._edges.length}`) // eslint-disable-line
await client.close()
})
after(async () => {
process.exit()
})
})
Nebula Nodejs SDK
This repository provides Nebula client API in Nodejs.
Features
Muti-Server Support
Auto-reconnection support
Client will try to reconnect forever, until the server is available again.
Connection pool support
Disconnection detection
A heartbeat mechanism is implemented, client will send ping to server each
pingInterval
ms for detect connectiveThrift enhancement
fix auto reconnect issue#2407
fix performance issue in huge data scene#2483
API
Connection Options
How To
Install
For compiling C++ native module,
node-gyp
is required, you can installnode-gyp
bynpm install -g node-gyp
Simple and convenient API
Events
About hash64 function
nebula-nodejs
exportshash64
function for convertingstring
tostring[]
, it's based onMurmurHash3
.About Int64
nodejs cannot repreent
Int64
, so we convertInt64
bytes tostring
Development
Build
Unit Test
Unit Test Coverage
Publish
TODO
Not implemented data type for auto parser