From e4e652fd9dae95864d89b1fe22c6a49244d5581d Mon Sep 17 00:00:00 2001 From: Swordsteel Date: Sat, 30 Nov 2024 13:36:52 +0100 Subject: [PATCH] Set up cassandra --- README.md | 13 ++++++++++--- build.gradle.kts | 5 +++++ cql/00-setup_device_configuration.cql | 6 ++++++ src/main/resources/application.yml | 16 ++++++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 cql/00-setup_device_configuration.cql diff --git a/README.md b/README.md index ad395e1..806bbe5 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,16 @@ A vault of secrets, a treasure untold, Configurations gathered, both new and old ## Properties for deployment -| name | required | info | -|------------------------|----------|-------------------------| -| spring.profiles.active | * | Spring Boot environment | +| name | required | info | +|----------------------------|----------|-------------------------| +| spring.profiles.active | * | Spring Boot environment | +| cassandra.keyspace-name | | | +| cassandra.port | | | +| cassandra.schema-action | | | +| cassandra.local-datacenter | | | +| cassandra.contact-points | * | | +| cassandra.username | * | | +| cassandra.password | ** | | Required: * can be stored as text, and ** need to be stored as secret. diff --git a/build.gradle.kts b/build.gradle.kts index 31d3562..bd80ba0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,9 +7,14 @@ plugins { } dependencies { + implementation(hlaeja.fasterxml.jackson.module.kotlin) + implementation(hlaeja.kotlin.logging) implementation(hlaeja.kotlin.reflect) implementation(hlaeja.kotlinx.coroutines) + implementation(hlaeja.library.hlaeja.common.messages) implementation(hlaeja.springboot.starter.actuator) + implementation(hlaeja.springboot.starter.cassandra) + implementation(hlaeja.springboot.starter.cassandra.reactive) implementation(hlaeja.springboot.starter.webflux) testImplementation(hlaeja.kotlin.test.junit5) diff --git a/cql/00-setup_device_configuration.cql b/cql/00-setup_device_configuration.cql new file mode 100644 index 0000000..e1e52b6 --- /dev/null +++ b/cql/00-setup_device_configuration.cql @@ -0,0 +1,6 @@ +-- Create a keyspace +CREATE KEYSPACE IF NOT EXISTS device_configuration + WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}; + +-- Use the keyspace +USE device_configuration; diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 4fc7d7a..e5ece0c 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -10,6 +10,12 @@ spring: name: "%APP_BUILD_OS_NAME%" version: "%APP_BUILD_OS_VERSION%" + cassandra: + keyspace-name: device_configuration + port: 9042 + schema-action: none + local-datacenter: datacenter1 + --- ############################### ### Development environment ### @@ -19,6 +25,11 @@ spring: activate: on-profile: development + cassandra: + contact-points: localhost + username: cassandra + password: password + --- ########################## ### Docker environment ### @@ -28,6 +39,11 @@ spring: activate: on-profile: docker + cassandra: + contact-points: cassandra + username: cassandra + password: password + --- ############################## ### Production environment ###