Git Product home page Git Product logo

hazelcast-api's Introduction

hazelcast-api

Codacy Badge Codacy Badge

Microservice that exposes an API to manage information in Hazelcast Maps

Features

  • Write information in a Hazelcast map
  • Read information from a Hazelcast map based on a key

Change Log

See CHANGELOG.md

Configuration

Property Default value Description
MICRONAUT_SERVER_PORT 6969 The port on the API is listening
MICRONAUT_SERVER_MAX_REQUEST_SIZE 1024 Max size, in bytes, allowed for an incoming request
HAZELCAST_NETWORK_ADDRESSES localhost:5701 The DNS and port of the Hazelcast cluster
HAZELCAST_CLIENT_NAME hazelcastApi The name representing this microservice the list of clients from Hazelcast connections
HAZELCAST_CLIENT_CLUSTERNAME dev The name of the Hazelcast cluster to connect
MICRONAUT_METRICS_ENABLED true Enable or disable the Micronaut metrics endpoint

API Endpoints

Endpoint Method Produces Consumes Body Description
/v1/map PUT application/json application/json {"key":"foo", "value":"myvalue", "map-name":"mymap"} Write a key/value on a specific Hazelcast Map
/v1/map POST application/json application/json {"key":"foo", "map-name":"mymap"} Get the value from a key on a specific Hazelcast Map

Examples

Write simple key/value in Map named "mymap2"

curl -X PUT http://localhost:6969/v1/map --header "Content-Type: application/json" -d '{"key":"foo","value":"myvalue2", "map-name":"mymap2"}'

Write a complex key/value in Map named "mymap2"

curl -X PUT http://localhost:6969/v1/map --header "Content-Type: application/json" -d '{"key":"foo","value":"{\"internal_key\": \"internal_value\"}", "map-name":"mymap2"}'

Get a value from a key in Map named "mymap2"

curl -X POST http://localhost:6969/v1/map --header "Content-Type: application/json" -d '{"key":"complexkey", "map-name": "mymap2"}'

Docker

Docker image is available on marcosflobo/hazelcast-api

Run simple hazelcast-api container

docker run -it --rm --name my-hazelcast-api -p 6969:6969 marcosflobo/hazelcast-api:1.0.0

Run hazelcast-api container with concrete configuration for Hazelcast cluster

docker run -it --rm --name my-hazelcast-api -p 6969:6969 --env HAZELCAST_NETWORK_ADDRESSES=hazelcast:5701 --env HAZELCAST_CLIENT_NAME=hazelcast-api-docker --env HAZELCAST_CLIENT_CLUSTERNAME=dev --env MICRONAUT_SERVER_PORT=6969 marcosflobo/hazelcast-api:1.0.0 

Development

During development, it's very important test and test fast, not only the application but also how it will work when it's deployed in production. For that, it's important to test via Docker container and, for doing so, we can use a docker-compose file.

The docker-compose.yml file will run:

  • Container with the last assembled version of this hazelcast-api app
  • Container with Prometheus service, to scrape the metrics exposed by the app
  • Container with Grafana service, to visualize the metrics scraped by Prometheus from the app

Run docker-compose

$ ./gradlew clean assemble && docker-compose up --build

To stop the docker-compose, just type Ctrl+c. To remove the containers created, run docker-compose down.

Metrics

Endpoint Description
/metrics Metrics information in JSON format
/prometheus Metrics information in Prometheus format
/health Status health of the service in JSON format

Micronaut

Feature cache-hazelcast documentation

Feature management documentation

Feature http-client documentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.