• Stars
    star
    150
  • Rank 247,323 (Top 5 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Hazelcast Node.js Client

Hazelcast Node.js Client

NPM version Chat on Slack Follow on Twitter


What is Hazelcast?

Hazelcast is a distributed computation and storage platform for consistently low-latency querying, aggregation and stateful computation against event streams and traditional data sources. It allows you to quickly build resource-efficient, real-time applications. You can deploy it at any scale from small edge devices to a large cluster of cloud instances.

A cluster of Hazelcast nodes share both the data storage and computational load which can dynamically scale up and down. When you add new nodes to the cluster, the data is automatically rebalanced across the cluster, and currently running computational tasks (known as jobs) snapshot their state and scale with processing guarantees.

For more info, check out Hazelcast repository.

What is Hazelcast Node.js Client?

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.

docker run -p 5701:5701 hazelcast/hazelcast

This command fetches the latest Hazelcast version. You can find all available tags here.

You can also use our ZIP or TAR distributions as described here.

Client

npm install hazelcast-client

Overview

Usage

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 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

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 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 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.

Getting Help

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

Contributing

We encourage any type of contribution in the form of issue reports or pull requests.

Issue Reports

For issue reports, please share the following information with us to quickly resolve the problems.

  • Hazelcast 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.

Pull Requests

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.

Development

  1. Clone the GitHub repository.
  2. Run npm install to automatically download and install all the required modules.
  3. Do the work.
  4. Hazelcast Node.js client developed using TypeScript. Run npm run compile to compile TypeScript files to JavaScript.
  5. To have a consistent code style across the code base, Hazelcast Node.js client uses a style checker. Run npm run lint and fix the reported issues, if any.

Testing

In order to test Hazelcast Node.js client locally, you will need the following:

  • Java 8 or newer
  • Maven

Following command starts the tests:

npm test

Test script automatically downloads hazelcast-remote-controller and Hazelcast. The script uses Maven to download those.

In order to run specific tests, you can give a pattern to the test command like the following:

npm test pattern

This command will only run the tests matching the pattern. The pattern can be a string or regex in the same form grep command accepts.

License

Apache 2.0 License.

Copyright

Copyright (c) 2008-2022, Hazelcast, Inc. All Rights Reserved.

Visit www.hazelcast.com for more information.

More Repositories

1

hazelcast

Hazelcast is a unified real-time data platform combining stream processing with a fast data store, allowing customers to act instantly on data-in-motion for real-time insights.
Java
6,036
star
2

hazelcast-jet

Distributed Stream and Batch Processing
Java
1,095
star
3

hazelcast-code-samples

Hazelcast Code Samples
Java
536
star
4

hazelcast-go-client

Hazelcast Go Client
Go
191
star
5

hazelcast-kubernetes

Kubernetes Discovery for Hazelcast
Java
172
star
6

hazelcast-jet-demos

Demonstration applications using Hazelcast Jet
Java
136
star
7

hazelcast-python-client

Hazelcast Python Client
Python
112
star
8

hazelcast-csharp-client

Hazelcast .NET Client
C#
102
star
9

hazelcast-docker

This repository contains docker image for Hazelcast open-source in-memory data-grid.
Dockerfile
90
star
10

hazelcast-simulator

A tool for stress testing Hazelcast
Java
83
star
11

spring-data-hazelcast

Hazelcast Spring Data integration Project http://projects.spring.io/spring-data/
Java
83
star
12

hazelcast-jet-code-samples

82
star
13

hazelcast-cpp-client

Hazelcast IMDG C++ Client
C++
79
star
14

quarkus-hazelcast-client

Quarkus Hazelcast Client Extension
Java
44
star
15

hazelcast-hibernate

A distributed second-level cache for Hibernate
Java
44
star
16

hazelcast-aws

AWS EC2 discovery plugin for hazelcast
Java
38
star
17

charts

Hazelcast Official Helm Chart Repository
Mustache
36
star
18

hazelcast-platform-demos

hazelcast-platform-demos
Java
34
star
19

hazelcast-tomcat-sessionmanager

Tomcat Based Web Session Replication
Java
33
star
20

hazelcast-eureka

Hazelcast Discovery SPI Plugin for Netflix' Eureka Service Discovery V1
Java
30
star
21

hazelcast-scala

Scala language support for Hazelcast
Scala
25
star
22

hazelcast-commandline-client

Home of Hazelcast CLC
Shell
23
star
23

hazelcast-spark

Spark Connector for Hazelcast
Scala
22
star
24

training

Java
22
star
25

hazelcast-platform-operator

Easily deploy Hazelcast clusters and Management Center into Kubernetes/OpenShift environments and manage their lifecycles.
Go
22
star
26

hazelcast-jet-contrib

Extension modules for Hazelcast Jet
Java
21
star
27

hazelcast-zookeeper

Hazelcast Discovery Plugin for Apache ZooKeeper
Java
21
star
28

hazelcast-platform-training

Java
20
star
29

hazelcast-reference-manual

Hazelcast Reference Manual
Java
19
star
30

hive

Design system built with A11Y in mind
TypeScript
18
star
31

hazelcast-hibernate-3-and-4

distributed second level cache for your Hibernate
Java
17
star
32

hazelcast-azure

Azure discovery plugin for hazelcast
Java
16
star
33

trading-demo

A trading demo application
Java
16
star
34

jet-train

Kotlin
14
star
35

big-data-benchmark

Java
13
star
36

management-center-docker

This repository contains Docker image for Hazelcast Management Center.
Dockerfile
13
star
37

hazelcast-wm

Hazelcast filter-based Web Session Manager
Java
12
star
38

hazelcast-client-protocol

Hazelcast Open Binary Client Protocol
Jinja
12
star
39

docker-grafana-graphite

Docker image with StatsD, Graphite and Grafana 2
Dockerfile
11
star
40

hazelcast-mesos

Hazelcast on Mesos
Java
11
star
41

hz-docs

Source content for the Hazelcast Platform documentation
JavaScript
10
star
42

hazelcast-operator

Shell
10
star
43

hazelcast-packaging

Shell
9
star
44

hazelcast-openshift

Hazelcast Openshift
Dockerfile
9
star
45

hazelcast-jetty-sessionmanager

Jetty Based Web Session Replication
Java
7
star
46

hazelcast-remote-controller

Java
7
star
47

hazelcast-hibernate4

!!!This repo is outdated. Kept alive only for backward compatibility reasons.!!! Beta implementation of hazelcast-hibernate module for Hibernate 4.0.
Java
7
star
48

homebrew-hz

Homebrew Repository for Hazelcast Command Line
Ruby
7
star
49

hazelcast-docs

Hazelcast documentation playbook
JavaScript
7
star
50

betleopard

Java
6
star
51

hazelcast-jmh

JMH Benchmarks for Hazelcast
Java
6
star
52

hazelcast-docs-ui

User interface styles for the Hazelcast documentation playbook.
Handlebars
6
star
53

imdg-docs

Source content for the Hazelcast IMDG documentation
JavaScript
5
star
54

hazelcast-jet-beam-runner

Hazelcast Jet Runner for Apache Beam
Java
5
star
55

hazelcast-qa

Collection of Hazelcast QA tools.
Java
4
star
56

hazelcast-gcp

Google Cloud Platform
Java
4
star
57

hazelcast-jet-reference-manual

Reference Manual for Hazelcast Jet
4
star
58

fraud-detection-onnx

Hazelcast and Onnx for Low Latency Fraud Detection
Java
4
star
59

training-courses

Java
4
star
60

hazelcast-jdbc

Hazelcast JDBC Driver allows Java applications to connect to Hazelcast using the standard JDBC API
Java
4
star
61

hazelcast-docker-samples

Java
4
star
62

hazelcast-platform-operator-agent

Go
3
star
63

hazelcast-ra

Hazelcast JCA Resource Adapter
Java
3
star
64

hazelcast-gradle-starter

Java
3
star
65

rel-scripts

3
star
66

hazelcast-dissector-for-wireshark

Hazelcast 4+ member protocol dissector
C
3
star
67

hazelcast-demos

Java
3
star
68

hazelcast-platform-operator-docs

Source content for the Kubernetes Operator of Hazelcast Platform (Enterprise)
JavaScript
3
star
69

performancetop5

The benchmarks for the Hazelcast Performance Top 5 blog series
Java
3
star
70

management-center-docs

Source content for the Hazelcast Management Center documentation
JavaScript
3
star
71

hazelcast-python-client-kerberos

Kerberos authentication support for Hazelcast Python Client
Python
3
star
72

hazelcast-jet-ansible-tests

Set of tests for Hazelcast Jet Soak Testing Environment.
Java
2
star
73

hazelcast-cloud-cli

CLI for Hazelcast Cloud
Go
2
star
74

hazelcast-cloud-go-sample-client

Sample Go Client For Hazelcast Cloud Community
Go
2
star
75

hazelcast-dynacache

This repository contains Hazelcast DynaCache feature for Liberty Profile.
Java
2
star
76

hazelcast-cloud-code-samples

Hazelcast Cloud Code Samples
Java
2
star
77

hazelcast-jet-docker

This repository contains Docker image for Hazelcast Jet open-source distributed computing platform built for high-performance stream processing and fast batch processing.
Dockerfile
2
star
78

hazelcast-hadoop

Hadoop Integration for Hazelcast IMDG
Java
2
star
79

client-compatibility-suites

JavaScript
2
star
80

cloud-docs

Source content for the Hazelcast Cloud documentation
JavaScript
1
star
81

sample-worker

Sample worker
Java
1
star
82

hazelcast-cloud-maven-plugin

Maven Plugin for Hazelcast Cloud
Java
1
star
83

fraud-detection-python

Python
1
star
84

clc-kafka-jet-demo

Kotlin
1
star
85

management-center-openshift

Dockerfile
1
star
86

hazelcast-grails

hazelcast grails plugin
Groovy
1
star
87

hazelcast-jet-management-center-docker

This repository contains Docker image for Hazelcast Jet Management Center
Dockerfile
1
star
88

hazelcast-cloud-community

Hazelcast Cloud Community Feature,Feedback,Issue Repository
1
star
89

hazelcast-cloud-python-sample-client

Sample Python Client For Hazelcast Cloud Community
Python
1
star
90

hazelcast-jclouds

jclouds discovery plugin for hazelcast
Java
1
star
91

hazelcast-tpm

Repository of Hazelcast Technical Program Management Team for storing scripts & tools that helps gathering & processing information.
Python
1
star
92

cfsummit17-wednesday

Hazelcast Technology for PCF Demo presented at Cloud Foundry Summit Silicon Valley 2017
Java
1
star
93

java-client-reference-manual

Java
1
star
94

hazelcast-diagnostics

Java
1
star
95

clc-docs

JavaScript
1
star