Skip to content

Latest commit

 

History

History

entity

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Entity Service

Sample service that uses Spring Native with Kotlin Coroutines and Kotlin.
Generate a native image to improve the start-up time.

Find more Spring Native samples here

Showcase

  • Interacting with Reactive Redis API with Kotlin Coroutines. Check the blog

Features

  • Kotlin Coroutines
  • Kotlin Serialization
  • Global Exception Handler
  • Input Validation
  • Spring Data Redis Repositories CRUD API
    • Redis Hash
    • Redis Search
    • Redis Graph
  • Observability

Setup

# To generate your own metadata using the annotation processor.
gradle :services:entity:kaptKotlin

Run

Redis

# start local redis
gradle redisComposeUp
# stop local redis before restart again
gradle redisComposeDown
# copy container logs to `build/containers-logs`
gradle redisComposeLogs

via docker-compose

# start local redis and grafana 
docker compose -f infra/redis.yml up
# (Or) start only redis
docker compose -f infra/redis.yml up redis
# stop local redis before restart again
docker compose -f infra/redis.yml down
# this will stop redis and remove all volumes
docker compose -f infra/redis.yml down -v 

Redis Insight: Redis db visualization dashboard

After opening RedisInsight App, connect using host:localhost, port:6379 and name:any_name_is_ok

for Redis Insight 1.x

open http://localhost:8001/

To monitor redis, use Grafana Dashboard

open http://localhost:3000/
gradle :services:entity:bootRun
# log at debug level
gradle :services:entity:bootRun --debug
open http://localhost:8080/account

Test

gradle :services:entity:test
gradle :appservicess:entity:integrationTest

We are using httpie CLI for REST testing

# list
http :8080/account
# health
http :8080/actuator
http :8080/actuator/health

Check API-TEST for more tests.

Build

Build fatJar

gradle :services:entity:build

Build native image

gradle :services:entity:bootBuildImage -x test

Then, you can run the app like any other container:

docker run -i --rm -p 8080:8080 entity-service:1.6.5-SNAPSHOT

Run in GCP

Set environment variables in GKE

GOOGLE_CLOUD_PROJECT=my-project-id
GOOGLE_APPLICATION_CREDENTIALS=/path/to/googleCredentials.json
# optional
STACKDRIVER_LOG_NAME
STACKDRIVER_LOG_FLUSH_LEVEL

TODO

Reference