Skip to content

Commit

Permalink
Merge pull request #498 from aerospike/stage
Browse files Browse the repository at this point in the history
CLIENT-2014
  • Loading branch information
DomPeliniAerospike authored Dec 13, 2022
2 parents d8ebeed + b18ec34 commit 816dd03
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 159 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ jobs:
strategy:
matrix:
node-version: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
- 10.x
- 12.x
- 14.x
- 16.x
- 17.x
- 18.x
- 19.x
continue-on-error: true
steps:
- uses: actions/checkout@v2
Expand Down
175 changes: 87 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,57 @@

The Aerospike Node.js client is a Node.js add-on module, written using V8.

The client is compatible with Node.js 19, 18 (LTS), 16 (LTS) and 14 (LTS).
It supports the following operating systems:
- RHEL 8/9
- Debian 10/11
- Ubuntu 18.04/20.04/22.04 (Focal, Jammy, Bionic)
- Many Linux distributions compatible with one of the above OS releases.
- macOS versions 11/12/13 are also supported. (Node.js 14 install unavailable on M1 Mac systems)

The client is compatible with arm64, aarch64, and x86_64 architectures.

The Aerospike Node.js client supports all Node.js [LTS
releases](https://github.com/nodejs/Release#release-schedule). To download and
install the latest stable version of Node.js, visit
[nodejs.org](http://nodejs.org/).

Install the necessary "development tools" and other libraries to build the client software.
Reference various docker files in the repository under the docker directory for more information.

## Installation

The Aerospike Node.js client is an add-on module that uses the Aerospike C client. The installation will attempt to install the pre-built binaries including dependent C client.

You can install the Aerospike Node.js client like any other Node.js module.

### Primer on Node.js Modules

Node.js modules are containers of JavaScript code and a `package.json`, which defines
the module, its dependencies and requirements. Modules are usually installed as
dependencies of other Node.js applications or modules. The modules are installed in
the application's `node_modules` directory, and can be utilized within the program
by requiring the module by name.

### npm Registry Installations

To install `aerospike` as a dependency of your project, in your project directory run:

```bash
npm install aerospike
```

To add `aerospike` as a dependency in _package.json_, run:

```bash
npm install aerospike --save-dev
```

To require the module in your application:
```bash
const Aerospike = require('aerospike')
```

## Usage

The following is very simple example how to create, update, read and remove a
Expand All @@ -22,11 +73,6 @@ const Aerospike = require('aerospike')
// INSERT HOSTNAME AND PORT NUMBER OF AEROPSIKE SERVER NODE HERE!
const config = {
hosts: '192.168.33.10:3000',
// Timeouts disabled, latency varies with hardware selection. Configure as needed.
policies: {
read : new Aerospike.WritePolicy({socketTimeout : 0, totalTimeout: 0}),
write : new Aerospike.ReadPolicy({socketTimeout : 0, totalTimeout: 0})
}
}

const key = new Aerospike.Key('test', 'demo', 'demo')
Expand All @@ -45,9 +91,9 @@ Aerospike.connect(config)
const meta = { ttl: 10000 }
const policy = new Aerospike.WritePolicy({
exists: Aerospike.policy.exists.CREATE_OR_REPLACE,
// Timeouts disabled, latency varies with hardware selection. Configure as needed.
// Timeouts disabled, latency dependent on server location. Configure as needed.
socketTimeout : 0,
totalTimeout: 0
totalTimeout : 0
})

return client.put(key, bins, meta, policy)
Expand Down Expand Up @@ -84,27 +130,9 @@ Aerospike.connect(config)
}
})
```

## Prerequisites

The client is compatible with Node.js 10, 12 (LTS), 14 (LTS), 16 (LTS) and 18 (LTS). It
supports the following operating systems: CentOS/RHEL 7/8, Debian 8/9/10/11,
Ubuntu 18.04/20.04, as well as many Linux distributions compatible with one of
these OS releases. macOS is also supported. The client port to Windows is a
community supported project and suitable for application prototyping and
development.

The Aerospike Node.js client supports all Node.js [LTS
releases](https://github.com/nodejs/Release#release-schedule). To download and
install the latest stable version of Node.js, visit
[nodejs.org](http://nodejs.org/) or use the version that comes bundled with
your operating system.

Install the necessary "development tools" and other libraries to build the client software.

Reference various docker files in the repository under the docker / directory for more information.

#### CentOS/RHEL
#### RHEL/CentOS

To install library prerequisites using `yum`:

Expand Down Expand Up @@ -159,105 +187,76 @@ To install library prerequisites using `apt`:
sudo apt install g++ libssl libssl-dev zlib1g-dev
```

### macOS (Intel)
### macOS

Before starting with the Aerospike Nodejs Client, verify that you have the following prerequisites:

- macOS 10.8 or greater.
- Xcode 5 or greater.

### macOS (M1 Chip)

Currently the C library does not support M1, so you cannot install Aerospike Nodejs Client directly on your mac, see [Issue](https://github.com/aerospike/aerospike-client-nodejs/issues/430).
As a workaround, you can build your app inside of Docker before using `--platform` [option](https://docs.docker.com/engine/reference/commandline/build/).
Example of a working docker-compose.yaml file looks similar to this:
```
version: '2.4'
services:
my-node-js-app:
build: .
platform: linux/amd64
```

**Openssl Library**

The below example shows how to install the Openssl library.

```bash
$ brew install openssl
$ brew link openssl --force
$ unlink /usr/local/opt/openssl
$ # Change the below linking based on openssl version and installation path
$ ln -s /usr/local/Cellar/openssl@x/y.z/ /usr/local/opt/openssl
brew install openssl
unlink /usr/local/opt/openssl
# Change the below linking based on openssl version and installation path
ln -s /usr/local/Cellar/openssl@x/y.z/ /usr/local/opt/openssl
```
For 4x client support, install openssl@1.1 version.

**LIBUV Library**

The example below shows how to install the LIBUV library.

If you are looking upgrade switch from openssl@1 or an older version of openssl@3, add these variables to your .bashrc, .profile, or .zshrc file.
```bash
$ brew install libuv
$ brew link libuv --force
$ unlink /usr/local/opt/libuv
$ # Change the below linking based on libuv version and installation path
$ ln -s /usr/local/Cellar/libuv/1.44.1_1/ /usr/local/opt/libuv
export PATH="/usr/local/bin/:/usr/local/opt/openssl/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
export EXT_CFLAGS="-I/usr/local/opt/openssl/include"
```

## Installation

The Aerospike Node.js client is an add-on module that uses the Aerospike C client. The installation will attempt to install the pre-built binaries including dependent C client.

You can install the Aerospike Node.js client like any other Node.js module.

### Primer on Node.js Modules

Node.js modules are containers of JavaScript code and a `package.json`, which defines
the module, its dependencies and requirements. Modules are usually installed as
dependencies of other Node.js applications or modules. The modules are installed in
the application's `node_modules` directory, and can be utilized within the program
by requiring the module by name.

### npm Registry Installations

To install `aerospike` as a dependency of your project, in your project directory run:

Afterwards, source the file that was changed and confirm the desired openssl version is installed
```bash
$ npm install aerospike
source ~/.bashrc
source ~/.profile
source ~/.zshrc
openssl version
```
For 4x client support, install openssl@1.1 version.

To add `aerospike` as a dependency in _package.json_, run:
**LIBUV Library**

```bash
$ npm install aerospike --save-dev
```
The example below shows how to install the LIBUV library.

To require the module in your application:
```bash
const Aerospike = require('aerospike')
brew install libuv
unlink /usr/local/opt/libuv
# Change the below linking based on libuv version and installation path
ln -s /usr/local/Cellar/libuv/1.44.1_1/ /usr/local/opt/libuv
```

### Git Repository Installations

When using a cloned repository, install `aerospike` as a dependency of your application. Instead of referencing the module by name, you reference it by path.

To clone the repository use the following command:

$ git clone --recursive [email protected]:aerospike/aerospike-client-nodejs.git
```bash
git clone --recursive [email protected]:aerospike/aerospike-client-nodejs.git
```

#### Building dependancy C client

Make sure to build the C client before doing npm install variants
Run the following commands to build the C client:

$ ./scripts/build-c-client.sh
```bash
./scripts/build-c-client.sh
```

#### Building and installing Node.js client

To install the module as a dependency of your application, run the following in the application directory:

```bash
$ npm install --unsafe-perm --build-from-source
npm install --unsafe-perm --build-from-source
```

To require it in the application:
Expand Down Expand Up @@ -301,17 +300,17 @@ The client includes a comprehensive test suite using

Before running the tests, you need to update the dependencies:

$ npm update
npm update

To run all the test cases:

$ npm test
npm test

Note: make sure your server has TTL enabled for the `test` namespace ([Namespace Retention Configuration](https://docs.aerospike.com/server/operations/configure/namespace/retention)) to allow all tests to run correctly.

To run the tests and also report on test coverage:

$ npm run coverage
npm run coverage

## Benchmarks

Expand All @@ -324,4 +323,4 @@ License, Version 2, as stated in the LICENSE file.

Individual files may be made available under their own specific license, all
compatible with Apache License, Version 2. Refer to individual files for
details.
details.
2 changes: 1 addition & 1 deletion aerospike-client-c
28 changes: 19 additions & 9 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
{
'variables': {
'build_arch%': '<(target_arch)',
'conditions': [
['target_arch=="x64"', {
'build_arch%': 'x86_64'
},'OS=="linux"', {
'build_arch%': 'aarch64'
}]
]
},
'targets': [
{
'target_name': 'aerospike-core-client',
Expand All @@ -13,14 +23,14 @@
'conditions': [
['OS=="linux"',{
'outputs': [
'aerospike-client-c/target/Linux-x86_64/include/aerospike/aerospike.h',
'aerospike-client-c/target/Linux-x86_64/lib/aerospike.lib'
'aerospike-client-c/target/Linux-<(build_arch)/include/aerospike/aerospike.h',
'aerospike-client-c/target/Linux-<(build_arch)/lib/aerospike.lib'
],
}],
['OS=="mac"',{
'outputs': [
'aerospike-client-c/target/Darwin-x86_64/include/aerospike/aerospike.h',
'aerospike-client-c/target/Darwin-x86_64/lib/aerospike.lib'
'aerospike-client-c/target/Darwin-<(build_arch)/include/aerospike/aerospike.h',
'aerospike-client-c/target/Darwin-<(build_arch)/lib/aerospike.lib'
],
}],
],
Expand All @@ -42,7 +52,7 @@
'action': [
'pwsh', 'scripts/build-c-client.ps1',
'-Configuration', "$(ConfigurationName)",
'-NodeLibFile', "<(node_root_dir)/<(target_arch)/node.lib"
'-NodeLibFile', "<(node_root_dir)/<(build_arch)/node.lib"
]
}
]
Expand Down Expand Up @@ -138,15 +148,15 @@
'conditions': [
['OS=="linux"',{
'libraries': [
'../aerospike-client-c/target/Linux-x86_64/lib/libaerospike.a',
'../aerospike-client-c/target/Linux-<(build_arch)/lib/libaerospike.a',
'-lz',
'-lssl'
],
'defines': [
'AS_USE_LIBUV'
],
'include_dirs': [
'aerospike-client-c/target/Linux-x86_64/include',
'aerospike-client-c/target/Linux-<(build_arch)/include',
'aerospike-client-c/src/include',
'src/include',
"<!(node -e \"require('nan')\")",
Expand All @@ -155,15 +165,15 @@
}],
['OS=="mac"',{
'libraries': [
'../aerospike-client-c/target/Darwin-x86_64/lib/libaerospike.a',
'../aerospike-client-c/target/Darwin-<(build_arch)/lib/libaerospike.a',
'-lz',
'-lssl'
],
'defines': [
'AS_USE_LIBUV'
],
'include_dirs': [
'aerospike-client-c/target/Darwin-x86_64/include',
'aerospike-client-c/target/Darwin-<(build_arch)/include',
'aerospike-client-c/src/include',
'src/include',
"<!(node -e \"require('nan')\")",
Expand Down
Loading

0 comments on commit 816dd03

Please sign in to comment.