Skip to content
Draft
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
115 changes: 2 additions & 113 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,119 +38,8 @@ For more info, check out Hazelcast [repository](https://github.com/hazelcast/haz
Hazelcast Node.js client is a way to communicate to Hazelcast clusters and access the cluster data via Node.js.
The client provides a Promise-based API with a builtin support for native JavaScript objects.

## Installation

### Hazelcast

Hazelcast Node.js client requires a working Hazelcast cluster to run. This cluster handles the storage and
manipulation of the user data.

A Hazelcast cluster consists of one or more cluster members. These members generally run on multiple virtual or
physical machines and are connected to each other via the network. Any data put on the cluster is partitioned to
multiple members transparent to the user. It is therefore very easy to scale the system by adding new members as
the data grows. Hazelcast cluster also offers resilience. Should any hardware or software problem causes a crash
to any member, the data on that member is recovered from backups and the cluster continues to operate without any
downtime.

The quickest way to start a single member cluster for development purposes is to use our
[Docker images](https://hub.docker.com/r/hazelcast/hazelcast/).

```bash
docker run -p 5701:5701 hazelcast/hazelcast
```

This command fetches the latest Hazelcast version. You can find all available tags
[here](https://hub.docker.com/r/hazelcast/hazelcast/tags).

You can also use our ZIP or TAR [distributions](https://hazelcast.com/open-source-projects/downloads/)
as described [here](DOCUMENTATION.md#121-setting-up-a-hazelcast-cluster).

### Client

```bash
npm install hazelcast-client
```

## Overview

### Usage

```js
const { Client } = require('hazelcast-client');

// Connect to Hazelcast cluster
const client = await Client.newHazelcastClient();

// Get or create the 'distributed-map' on the cluster
const map = await client.getMap('distributed-map');

// Put 'key', 'value' pair into the 'distributed-map'
await map.put('key', 'value');

// Get the value associated with the given key from the cluster
const value = await map.get('key');
console.log(value); // Outputs 'value'

// Shutdown the client
await client.shutdown();
```

> **NOTE: For the sake of brevity we are going to omit boilerplate parts in the above code snippet.
> Refer to [this code sample](https://github.com/hazelcast/hazelcast-nodejs-client/tree/master/code_samples/readme_sample.js)
> to see the complete code.**

If you are using Hazelcast and the Node.js client on the same machine, the default configuration should work
out-of-the-box. However, you may need to configure the client to connect to cluster nodes that are running on
different machines or to customize client properties.

### Configuration

```js
const { Client } = require('hazelcast-client');

// Initialize the client with the given configuration
const client = await Client.newHazelcastClient({
clusterName: 'cluster-name',
network: {
clusterMembers: [
'10.90.0.2:5701',
'10.90.0.3:5701'
]
},
lifecycleListeners: [
(state) => {
console.log('Lifecycle Event >>> ' + state);
}
]
});

console.log('Connected to cluster');
await client.shutdown();
```

Refer to [the documentation](DOCUMENTATION.md) to learn more about supported configuration options.

## Features

* Distributed, partitioned and queryable in-memory key-value store implementation, called **Map**
* Eventually consistent cache implementation to store a subset of the Map data locally in the memory of the client, called **Near Cache**
* Additional data structures and simple messaging constructs such as **Set**, **MultiMap**, **Queue**, **Topic**
* Cluster-wide unique ID generator, called **FlakeIdGenerator**
* Distributed, CRDT based counter, called **PNCounter**
* Distributed concurrency primitives from CP Subsystem such as **FencedLock**, **Semaphore**, **AtomicLong**
* Integration with [Hazelcast Viridian](https://viridian.hazelcast.com/)
* Support for serverless and traditional web service architectures with **Unisocket** and **Smart** operation modes
* Ability to listen client lifecycle, cluster state and distributed data structure events
* and [many more](https://hazelcast.com/clients/node-js/#client-features).

## Getting Help

You can use the following channels for your questions and development/usage issues:

* [GitHub repository](https://github.com/hazelcast/hazelcast-nodejs-client)
* [Complete documentation](https://github.com/hazelcast/hazelcast-nodejs-client/blob/master/DOCUMENTATION.md)
* [API documentation](http://hazelcast.github.io/hazelcast-nodejs-client)
* [Slack](https://slack.hazelcast.com)
For a list of the features available, and for information about how to install and get started with the client,
see the [Node.js client documentation](https://docs.hazelcast.com/hazelcast/latest/clients/nodejs).

## Contributing

Expand Down