Skip to content

This repository is for learning R2DBC with Spring Webflux parallel to the [Learning Webflux 3.0] repository

Notifications You must be signed in to change notification settings

fResult/poc-r2dbc

Repository files navigation

POC R2DBC

This repository is a parallel project to Learning Webflux 3.0 (module kotlin.06-data-access) and is used for learning R2DBC with Spring WebFlux.

It was created separately because the original repository had connection issues with the R2DBC driver.
This repository serves as a proof of concept (POC) to explore and test the R2DBC setup more reliably.

Prerequisites

  • Docker and Docker Compose

Running the Project

Start Databases

docker-compose -f docker/compose.yml --env-file .env up -d

To stop the databases:

docker-compose -f docker/compose.yml --env-file .env down -v

Build

./gradlew clean build

Run App

common profile

SERVER_PORT=8089 \
MONGO_USER=mongo \
MONGO_PASSWORD=mongo \
MONGO_AUTH_DB=admin \
PG_USER=postgres \
PG_PASSWORD=postgres \
./gradlew bootRun

springdata profile

SERVER_PORT=8089 \
MONGO_USER=mongo \
MONGO_PASSWORD=mongo \
MONGO_AUTH_DB=admin \
PG_USER=postgres \
PG_PASSWORD=postgres \
./gradlew bootRun --args='--spring.profiles.active=springdata'

mongo profile

SERVER_PORT=8089 \
MONGO_USER=mongo \
MONGO_PASSWORD=mongo \
MONGO_AUTH_DB=admin \
PG_USER=postgres \
PG_PASSWORD=postgres \
./gradlew bootRun --args='--spring.profiles.active=mongo'

Test

./gradlew test

Testcontainers for Colima

Ref: https://java.testcontainers.org/supported_docker_environment/#colima

colima start --network-address
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE="$HOME/.colima/default/docker.sock"
export TESTCONTAINERS_HOST_OVERRIDE=$(colima ls -j | jq -r '.address')
export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"

API Endpoints

Functional Endpoints (/fe/...)

Get All Customers:

curl localhost:8089/fe/customers

Get Customer by ID:

curl localhost:8089/fe/customers/:id

Create Customer:

curl -X POST localhost:8089/fe/customers \
     -H "Content-Type: application/json" \
     -d '{"email": "<email_to_create>"}'

Update Customer:

curl -X PATCH localhost:8089/fe/customers/:id \
     -H "Content-Type: application/json" \
     -d '{"email": "<email_to_update>"}'

Delete Customer:

curl -X DELETE localhost:8089/fe/customers/:id

Rest Controller (/rc/...)

Get All Customers:

curl localhost:8089/rc/customers

Get Customer by ID:

curl localhost:8089/rc/customers/:id

Create Customer:

curl -X POST localhost:8089/rc/customers \
     -H "Content-Type: application/json" \
     -d '{"email": "<email_to_create>"}'

Update Customer:

curl -X PATCH localhost:8089/rc/customers/:id \
     -H "Content-Type: application/json" \
     -d '{"email": "<email_to_update>"}'

Delete Customer:

curl -X DELETE localhost:8089/rc/customers/:id

About

This repository is for learning R2DBC with Spring Webflux parallel to the [Learning Webflux 3.0] repository

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages