Sign inSign up

marcosflobo/hazelcast-api

By marcosflobo

•Updated almost 6 years ago

Microservice that exposes an API to manage information in Hazelcast Maps

Image
0

69

marcosflobo/hazelcast-api repository overview

⁠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

PropertyDefault valueDesciption
MICRONAUT_SERVER_PORT6969The port on the API is listening
MICRONAUT_SERVER_MAX_REQUEST_SIZE1024Max size, in bytes, allowed for an incoming request
HAZELCAST_NETWORK_ADDRESSESlocalhost:5701The DNS and port of the Hazelcast cluster
HAZELCAST_CLIENT_NAMEhazelcastApiThe name representing this microservice the list of clients from Hazelcast connections
HAZELCAST_CLIENT_CLUSTERNAMEdevThe name of the Hazelcast cluster to connect
MICRONAUT_METRICS_ENABLEDtrueEnable or disable the Micronaut metrics endpoint

⁠API Endpoints

EndpointMethodProducesConsumesBodyDesciption
/v1/mapPUTapplication/jsonapplication/json{"key":"foo", "value":"myvalue", "map-name":"mymap"}Write a key/value on a specific Hazelcast Map
/v1/mapPOSTapplication/jsonapplication/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

⁠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
EndpointDesciption
/metricsMetrics information in JSON format
/prometheusMetrics information in Prometheus format
/healthStatus health of the service in JSON format

⁠Micronaut

⁠Feature cache-hazelcast documentation
⁠Feature management documentation
⁠Feature http-client documentation

Tag summary

Content type

Image

Digest

Size

217.8 MB

Last updated

almost 6 years ago

docker pull marcosflobo/hazelcast-api:1.0.0