• Stars
    star
    186
  • Rank 203,157 (Top 5 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 7 years ago
  • Updated 5 months ago

Reviews

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

Repository Details

Hazelcast Go Client

Hazelcast Go Client

Go Reference

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 Go client is a way to communicate to Hazelcast 4 and 5 clusters and access the cluster data.

Sample Code

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/hazelcast/hazelcast-go-client"
)

func main() {
	ctx := context.TODO()
	// create the client and connect to the cluster on localhost
	client, err := hazelcast.StartNewClient(ctx)
	if err != nil {
		log.Fatal(err)
	}
	// get a map
	people, err := client.GetMap(ctx, "people")
	if err != nil {
		log.Fatal(err)
	}
	personName := "Jane Doe"
	// set a value in the map
	if err = people.Set(ctx, personName, 30); err != nil {
		log.Fatal(err)
	}
	// get a value from the map
	age, err := people.Get(ctx, personName)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%s is %d years old.\n", personName, age)
	// stop the client to release resources
	client.Shutdown(ctx)
}

Features

  • Distributed, partitioned and queryable in-memory key-value store implementation, called Map.
  • Additional data structures and simple messaging constructs such as Replicated Map, MultiMap, Queue, List, PNCounter, Set, Topic and others.
  • Support for serverless and traditional web service architectures with Unisocket and Smart operation modes.
  • Go context support for all distributed data structures.
  • Viridian integration.
  • SQL support (only on Hazelcast 5.x).
  • External smart client discovery.
  • Hazelcast Management Center integration.
  • Ability to listen to client lifecycle, cluster state, and distributed data structure events.
  • And more...

Install

Requirements:

  • Hazelcast Go client is compatible only with Hazelcast 4.x and 5.x.
  • We support two most recent releases of Go, currently 1.17 and up.

In your Go module enabled project, add a dependency to github.com/hazelcast/hazelcast-go-client:

# Depend on the latest release
$ go get github.com/hazelcast/hazelcast-go-client@latest

Quick Start

Hazelcast Go client requires a working Hazelcast cluster.

Check out our Get Started page for options.

Starting the Client with Viridian

You only need the cluster name and Viridian token to start the client. If you haven't already, you can sign up for a free Viridian account.

Check out our Viridian sample

Starting the Default Client

Start the client with the default Hazelcast host and port using hazelcast.StartNewClient, when Hazelcast is running on local with the default options:

ctx := context.TODO()
client, err := hazelcast.StartNewClient(ctx)
// handle client start error

Starting the Client with Given Options

Note that Config structs are not thread-safe. Complete creation of the configuration in a single goroutine.

// create the default configuration
config := hazelcast.Config{}
// optionally set member addresses manually
config.Cluster.Network.SetAddresses("member1.example.com:5701", "member2.example.com:5701")
// create and start the client with the configuration provider
client, err := hazelcast.StartNewClientWithConfig(ctx, config)
// handle client start error

Documentation

Hazelcast Go Client documentation is hosted at pkg.go.dev.

You can view the documentation locally by using godoc:

$ godoc -http=localhost:5500

godoc is not installed by default with the base Go distribution. Install it using:

$ go get -u golang.org/x/tools/...`

Support

Join us at Go Client channel or Hazelcast at Google Groups.

Running the tests

Currently, we support only Linux, MacOS and WSL (Windows Subsystem for Linux) for testing the client.

You need to have the following installed in order to run integration tests:

  • Java 8
  • Maven 3 or better
  • Bash
  • Make

Before running the tests, starts Hazelcast Remote Controller, which enables the test suite to create clusters:

# Start RC with Hazelcast Community features
$ ./rc.sh start

# Or, start RC with Hazelcast Enterprise features
$ HAZELCAST_ENTERPRISE_KEY=ENTERPRISE-KEY-HERE ./rc.sh start 

You can run the tests using one of the following approaches:

  • Run make test-all to run integration tests.
  • Run make test-all-race to run integration tests with race detection.
  • Run make test-cover to generate the coverage report and make view-cover to view the test coverage summary and generate an HTML report.

Testing the client with SSL support requires running the remote controller with Hazelcast Enterprise features. To enable SSL connections, add ENABLE_SSL=1 to environment variables, or prepend it to the make commands above.

In order to turn on verbose logging, add ENABLE_TRACE=1 to environment variables, or prepend it to the make commands above.

License

Apache 2 License.

Copyright (c) 2008-2021, 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
5,935
star
2

hazelcast-jet

Distributed Stream and Batch Processing
Java
1,091
star
3

hazelcast-code-samples

Hazelcast Code Samples
Java
536
star
4

hazelcast-kubernetes

Kubernetes Discovery for Hazelcast
Java
172
star
5

hazelcast-nodejs-client

Hazelcast Node.js Client
TypeScript
147
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#
101
star
9

hazelcast-docker

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

hazelcast-jet-code-samples

83
star
11

hazelcast-simulator

A tool for stress testing Hazelcast
Java
83
star
12

spring-data-hazelcast

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

hazelcast-cpp-client

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

quarkus-hazelcast-client

Quarkus Hazelcast Client Extension
Java
43
star
15

hazelcast-hibernate

A distributed second-level cache for Hibernate
Java
42
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

management-center-docker

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

hazelcast-wm

Hazelcast filter-based Web Session Manager
Java
12
star
37

hazelcast-client-protocol

Hazelcast Open Binary Client Protocol
Jinja
12
star
38

big-data-benchmark

Java
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

betleopard

Java
6
star
50

hazelcast-jmh

JMH Benchmarks for Hazelcast
Java
6
star
51

hazelcast-docs-ui

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

hazelcast-docs

Hazelcast documentation playbook
JavaScript
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-gcp

Google Cloud Platform
Java
4
star
56

hazelcast-jet-reference-manual

Reference Manual for Hazelcast Jet
4
star
57

fraud-detection-onnx

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

hazelcast-qa

Collection of Hazelcast QA tools.
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-demos

Java
4
star
63

hazelcast-platform-operator-agent

Go
3
star
64

hazelcast-ra

Hazelcast JCA Resource Adapter
Java
3
star
65

hazelcast-gradle-starter

Java
3
star
66

rel-scripts

3
star
67

hazelcast-dissector-for-wireshark

Hazelcast 4+ member protocol dissector
C
3
star
68

performancetop5

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

management-center-docs

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

hazelcast-python-client-kerberos

Kerberos authentication support for Hazelcast Python Client
Python
3
star
71

client-compatibility-suites

PowerShell
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-platform-operator-docs

Source content for the Kubernetes Operator of Hazelcast Platform (Enterprise)
JavaScript
2
star
78

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
79

hazelcast-hadoop

Hadoop Integration for Hazelcast IMDG
Java
2
star
80

cloud-docs

Source content for the Hazelcast Cloud documentation
JavaScript
1
star
81

sample-worker

Sample worker
Java
1
star
82

fraud-detection-python

Python
1
star
83

hazelcast-cloud-maven-plugin

Maven Plugin for Hazelcast Cloud
Java
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