Skip to content

feat: query with a rust flight client #561

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
132 changes: 132 additions & 0 deletions .circleci/config-rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
version: 2.1

executors:
macos-executor:
macos:
version: 12.0
environment:
DEBUG: "napi:*"
APP_NAME: flight-sql-client
MACOSX_DEPLOYMENT_TARGET: '10.13'

ubuntu-executor:
docker:
- image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
environment:
DEBUG: "napi:*"
APP_NAME: flight-sql-client

windows-executor:
docker:
- image: mcr.microsoft.com/windows/servercore:ltsc2022
environment:
DEBUG: "napi:*"
APP_NAME: flight-sql-client

ubuntu-docker-executor:
docker:
- image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian
working_directory: /workspace

jobs:
build:
executor: ubuntu-executor
strategy:
matrix:
# List the different platforms to build on
parameters:
target:
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
- i686-pc-windows-msvc
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- aarch64-apple-darwin
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- aarch64-linux-android
- armv7-linux-androideabi
- aarch64-unknown-linux-musl
steps:
- checkout
- run:
name: Setup Node.js
command: |
curl -sL https://deb.nodesource.com/setup_18.x | bash -
apt-get install -y nodejs
npm install -g yarn
- run:
name: Install dependencies
command: yarn install
- run:
name: Setup Rust toolchain
command: |
rustup target add $CIRCLE_JOB
rustup update
- run:
name: Build project
command: |
yarn build --target $CIRCLE_JOB
strip -x *.node
- persist_to_workspace:
root: .
paths:
- .

test:
executor: ubuntu-executor
steps:
- checkout
- run:
name: Install dependencies
command: yarn install
- run:
name: Download artifacts
command: |
cp -r /workspace/artifacts/* .
- run:
name: Run tests
command: yarn test

publish:
executor: ubuntu-executor
steps:
- checkout
- run:
name: Install dependencies
command: yarn install
- run:
name: Publish
command: |
if git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --access public
elif git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+";
then
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
npm publish --tag next --access public
else
echo "Not a release, skipping publish"
fi
environment:
NPM_TOKEN: $NPM_TOKEN

workflows:
version: 2
build_and_test:
jobs:
- build:
matrix:
parameters:
target:
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
- x86_64-unknown-linux-gnu
- test:
requires:
- build
- publish:
requires:
- test

40 changes: 40 additions & 0 deletions packages/client/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

# Influxdb3 js client with rust backend TODO
## Overview
Core inspiration: https://github.com/roeap/flight-sql-client-node
Nice example of napi package: https://github.com/rollup/rollup

## CI
- Add building of the rust client for all supported tripplets
- Add publishing of the rust client for all supported tripplets


## Rust
- Use regular Get GRPC request, like it is done in original client (now in browser implementation) to query data, not prepared statements
- Propagate errors from rust to js


## JS
Note, that only linux-x64-gnu and win32-x64-msvc are precompiled and published at the moment under the @vlastahajek NPM name.
native.js was manually modified to include the correct package name.
building rust client will rewrite the native.js to include the correct package name.

After building and publishing the rust client for supported platform, we need to change the package.json to include the correct packages:

```json
"optionalDependencies": {
"@influxdata/influxdb3-js-flight-sql-client-android-arm-eabi": "0.0.1",
"@influxdata/influxdb3-js-flight-sql-client-android-arm64": "0.0.1",
"@influxdata/influxdb3-js-flight-sql-client-darwin-arm64": "0.0.1",
"@influxdata/influxdb3-js-flight-sql-client-darwin-x64": "0.0.1",
"@influxdata/influxdb3-js-flight-sql-client-freebsd-x64": "0.0.1",
"@influxdata/influxdb3-js-flight-sql-client-linux-arm-gnueabihf": "0.0.1",
"@influxdata/influxdb3-js-flight-sql-client-linux-arm64-gnu": "0.0.1",
"@influxdata/influxdb3-js-flight-sql-client-linux-arm64-musl": "0.0.1",
"@influxdata/influxdb3-js-flight-sql-client-linux-x64-gnu": "0.0.1",
"@influxdata/influxdb3-js-flight-sql-client-linux-x64-musl": "0.0.1",
"@influxdata/influxdb3-js-flight-sql-client-win32-ia32-msvc": "0.0.1",
"@influxdata/influxdb3-js-flight-sql-client-win32-x64-msvc": "0.0.1"
}
```

36 changes: 36 additions & 0 deletions packages/client/native.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* tslint:disable */
/* eslint-disable */

/* auto-generated by NAPI-RS */

/** A ':' separated key value pair */
export interface KeyValue {
key: string
value: string
}
export interface ClientOptions {
/**
* Additional headers.
*
* Values should be key value pairs separated by ':'
*/
headers: Array<KeyValue>
/** Username */
username?: string
/** Password */
password?: string
/** Auth token. */
token?: string
/** Server host. */
host: string
}
export declare function createFlightSqlClient(
options: ClientOptions
): Promise<FlightSqlClient>
export declare function rustCrateVersion(): string
export declare class FlightSqlClient {
query(
query: string,
params?: Array<[string, string]> | undefined | null
): Promise<Buffer>
}
Loading
Loading