Hazelcast Node.js Client
Hazelcast is an open-source distributed in-memory data store and computation platform that provides a wide variety of distributed data structures and concurrency primitives.
Hazelcast Node.js client requires a working Hazelcast IMDG cluster to run. This cluster handles the storage and manipulation of the user data.
A Hazelcast IMDG 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 IMDG 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.
docker run -p 5701:5701 hazelcast/hazelcast:3.12.6
Make sure to use Hazelcast IMDG 3.x versions as the work to support 4.x versions is in progress.
npm install hazelcast-client
const Client = ;// Connect to Hazelcast clusterconst client = await Client;// Get or create the 'distributed-map' on the clusterconst map = await client;// Put 'key', 'value' pair into the 'distributed-map'await map;// Get the value associated with the given key from the clusterconst value = await map;console; // Outputs 'value'// Shutdown the clientclient;
If you are using Hazelcast IMDG 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.
const Client Config = ;// Create a configuration objectconst clientConfig = ;// Customize the client configurationclientConfiggroupConfigname = 'cluster-name';clientConfignetworkConfigaddresses;clientConfignetworkConfigaddresses;// Initialize the client with the given configurationconst client = await Client;console;client;
You can also configure the client declaratively using a JSON file.
- 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
- Primitives for distributed computing such as Lock, Semaphore, Atomic Long
- Integration with Hazelcast Cloud
- 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.
You can use the following channels for your questions and development/usage issues:
We encourage any type of contribution in the form of issue reports or pull requests.
For issue reports, please share the following information with us to quickly resolve the problems.
- Hazelcast IMDG and the client version that you use
- General information about the environment and the architecture you use like Node.js version, cluster size, number of clients, Java version, JVM parameters, operating system etc.
- Logs and stack traces, if any.
- Detailed description of the steps to reproduce the issue.
Contributions are submitted, reviewed and accepted using the pull requests on GitHub. For an enhancement or larger feature, create a GitHub issue first to discuss.
- Clone the GitHub repository.
npm installto automatically download and install all the required modules.
- Do the work.
- Hazelcast Node.js client developed using TypeScript. Run
- To have a consistent code style across the code base, Hazelcast Node.js client uses a style checker. Run
npm run lintand fix the reported issues, if any.
In order to test Hazelcast Node.js client locally, you will need the following:
- Java 8 or newer
Following command starts the tests:
Test script automatically downloads
hazelcast-remote-controller and Hazelcast IMDG. The script uses Maven to download those.
Copyright (c) 2008-2020, Hazelcast, Inc. All Rights Reserved.
Visit www.hazelcast.com for more information.