This document describes how to set up your development environment to build and test the GLIDE for Redis Node wrapper.
The GLIDE Node wrapper consists of both TypeScript and Rust code. Rust bindings for Node.js are implemented using napi-rs. The Node and Rust components communicate using the protobuf protocol.
Software Dependencies
Note: Currently, we only support npm major version 8. f you have a later version installed, you can downgrade it with
npm i -g npm@8
.
- npm v8
- git
- GCC
- pkg-config
- protoc (protobuf compiler)
- openssl
- openssl-dev
- rustup
Dependencies installation for Ubuntu
sudo apt update -y
sudo apt install -y nodejs npm git gcc pkg-config protobuf-compiler openssl libssl-dev
npm i -g npm@8
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
Dependencies installation for CentOS
sudo yum update -y
sudo yum install -y nodejs git gcc pkgconfig protobuf-compiler openssl openssl-devel gettext
npm i -g npm@8
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
Dependencies installation for MacOS
brew update
brew install nodejs git gcc pkgconfig protobuf openssl
npm i -g npm@8
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
Before starting this step, make sure you've installed all software requirments.
-
Clone the repository:
VERSION=0.1.0 # You can modify this to other released version or set it to "main" to get the unstable branch git clone --branch ${VERSION} https://github.com/aws/glide-for-redis.git cd glide-for-redis
-
Initialize git submodule:
git submodule update --init --recursive
-
Install all node dependencies:
cd node npm i cd rust-client npm i cd ..
-
Build the Node wrapper: Choose a build option from the following and run it from the
node
folder:1. Build in release mode, stripped from all debug symbols (optimized and minimized binary size): ```bash npm run build:release ``` 2. Build in release mode with debug symbols (optimized but large binary size): ```bash npm run build:benchmark ``` 3. For testing purposes, you can execute an unoptimized but fast build using: `bash
npm run build
Once building completed, you'll find the compiled JavaScript code in the
./build-ts` folder. -
Run tests:
- Ensure that you have installed redis-server and redis-cli on your host. You can find the Redis installation guide at the following link: Redis Installation Guide.
- Execute the following command from the node folder:
npm test
-
Integrating the built GLIDE package into your project: Add the package to your project using the folder path with the command
npm install <path to GLIDE>/node
.
- For a fast build, execute
npm run build
. This will perform a full, unoptimized build, which is suitable for developing tests. Keep in mind that performance is significantly affected in an unoptimized build, so it's required to build with thebuild:release
orbuild:benchmark
option when measuring performance. - If your modifications are limited to the TypeScript code, run
npm run build-external
to build the external package without rebuilding the internal package. - If your modifications are limited to the Rust code, execute
npm run build-internal
to build the internal package and generate TypeScript code. - To generate Node's protobuf files, execute
npm run build-protobuf
. Keep in mind that protobuf files are generated as part of full builds (e.g.,build
,build:release
, etc.).
Note: Once building completed, you'll find the compiled JavaScript code in the
node/build-ts
folder.
To run tests, use the following command:
npm test
After pulling new changes, ensure that you update the submodules by running the following command:
git submodule update
Development on the Node wrapper may involve changes in either the TypeScript or Rust code. Each language has distinct linter tests that must be passed before committing changes.
TypeScript:
- ESLint
- Prettier
Rust:
- clippy
- fmt
- TypeScript
# Run from the `node` folder npm install eslint-plugin-import@latest @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-tsdoc eslint typescript eslint-plugin-import@latest eslint-config-prettier npm i npx eslint . --max-warnings=0
- Rust
# Run from the `node/rust-client` folder rustup component add clippy rustfmt cargo clippy --all-features --all-targets -- -D warnings cargo fmt --manifest-path ./Cargo.toml --all
- Prettier - Code formatter - JavaScript / TypeScript formatter.
- ESLint - linter.
- Jest Runner - in-editor test runner.
- Jest Test Explorer - adapter to the VSCode testing UI.
- rust-analyzer - Rust language support for VSCode.