Skip to content
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

Fix node examples #2345

Merged
merged 1 commit into from
Sep 23, 2024
Merged
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
25 changes: 3 additions & 22 deletions examples/node/README.MD
Original file line number Diff line number Diff line change
@@ -1,38 +1,19 @@
## Pre-requirements
- GCC
- pkg-config
- protobuf-compiler (protoc)
- openssl
- libssl-dev

Installation for ubuntu:
`sudo apt install -y gcc pkg-config protobuf-compiler openssl libssl-dev python3`

### node 16 (or newer)

This is required for the NodeJS wrapper, and for running benchmarks.

### Install node 16 (or newer)
```
curl -s https://deb.nodesource.com/setup_16.x | sudo bash
apt-get install nodejs npm
npm i -g npm@8
```

## Build
To build GLIDE's Node client, run (on unix based systems):
## Install GLIDE package and build the example
```
cd valkey-glide/node
git submodule update --init --recursive
npm install
rm -rf build-ts
npm run build:release
cd valkey-glide/examples/node
npm install
npx tsc
```

## Run
To run the example:
To run the example (make sure redis/valkey server is available at the address used in the example):
```
cd valkey-glide/examples/node
node index.js
Expand Down
9 changes: 6 additions & 3 deletions examples/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { GlideClient, GlideClusterClient, Logger } from "@valkey/valkey-glide";

async function sendPingToNode() {
async function sendPingToStandAloneNode() {
// When in Redis is in standalone mode, add address of the primary node, and any replicas you'd like to be able to read from.
const addresses = [
{
Expand Down Expand Up @@ -64,6 +64,9 @@ function setConsoleLogger() {
}

setFileLogger();
await sendPingToNode();
setConsoleLogger();
await sendPingToRandomNodeInCluster();
// Enable for standalone mode
await sendPingToStandAloneNode();

// Enable for cluster mode
// await sendPingToRandomNodeInCluster();
2 changes: 1 addition & 1 deletion examples/node/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"dependencies": {
"@valkey/valkey-glide": "^1.1.0",
"@valkey/valkey-glide": "latest",
"@types/node": "^20.4.8"
},
"devDependencies": {
Expand Down
Loading