-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
125 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
GOOGLE_CLOUD_PROJECT_ID="gsync" | ||
|
||
.PHONY: init_spanner_emulator | ||
init_spanner_emulator: | ||
docker-compose up -d | ||
gcloud config configurations create emulator || true | ||
gcloud config set auth/disable_credentials true | ||
gcloud config set project ${GOOGLE_CLOUD_PROJECT_ID} | ||
gcloud config set api_endpoint_overrides/spanner http://localhost:9020/ | ||
gcloud spanner instances create gsync --config=emulator-config --description="gsync" --nodes=1 | ||
gcloud spanner databases create gsync --instance=gsync | ||
|
||
.PHONY: test | ||
test: | ||
./gradlew test | ||
|
||
.PHONY: lint | ||
lint: | ||
./gradlew spotlessCheck | ||
|
||
.PHONY: format | ||
format: | ||
./gradlew spotlessApply | ||
|
||
.PHONY: check_dependencies | ||
check_dependencies: | ||
./gradlew dependencyUpdates -Drevision=release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
services: | ||
spanner: | ||
build: ./docker/spanner | ||
ports: | ||
- "9010:9010" | ||
- "9020:9020" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FROM gcr.io/cloud-spanner-emulator/emulator |
42 changes: 42 additions & 0 deletions
42
src/main/kotlin/net/averak/gsync/infrastructure/json/JsonUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package net.averak.gsync.infrastructure.json | ||
|
||
import com.fasterxml.jackson.core.JsonParser | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule | ||
import com.fasterxml.jackson.module.kotlin.KotlinFeature | ||
import com.fasterxml.jackson.module.kotlin.KotlinModule | ||
|
||
class JsonUtils { | ||
|
||
companion object { | ||
|
||
private val objectMapper = ObjectMapper() | ||
.registerModule( | ||
KotlinModule.Builder() | ||
.withReflectionCacheSize(512) | ||
.configure(KotlinFeature.NullToEmptyCollection, false) | ||
.configure(KotlinFeature.NullToEmptyMap, false) | ||
.configure(KotlinFeature.NullIsSameAsDefault, false) | ||
.configure(KotlinFeature.SingletonSupport, false) | ||
.configure(KotlinFeature.StrictNullChecks, false) | ||
.build() | ||
) | ||
.registerModule(JavaTimeModule()) | ||
.configure(JsonParser.Feature.AUTO_CLOSE_SOURCE, true) | ||
|
||
@JvmStatic | ||
fun encode(value: Any?): String { | ||
return if (value == null) { | ||
"{}" | ||
} else { | ||
objectMapper.writeValueAsString(value) | ||
} | ||
} | ||
|
||
@JvmStatic | ||
fun <T> decode(json: String, clazz: Class<T>): T { | ||
return objectMapper.readValue(json, clazz) | ||
} | ||
|
||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/net/averak/gsync/infrastructure/spanner/SpannerClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package net.averak.gsync.infrastructure.spanner | ||
|
||
import com.google.cloud.spanner.Spanner | ||
import jakarta.inject.Singleton | ||
|
||
@Singleton | ||
class SpannerClient( | ||
private val spanner: Spanner, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
quarkus: | ||
application: | ||
name: "gsync" | ||
version: "1.0.0-SNAPSHOT" | ||
datasource: | ||
db-kind: spanner | ||
jdbc: | ||
url: jdbc:cloudspanner:/projects/${quarkus.google.cloud.project-id}/instances/${quarkus.google.cloud.instance-id}/databases/${quarkus.google.cloud.database-id} | ||
driver: com.google.cloud.spanner.jdbc.JdbcDriver | ||
google: | ||
cloud: | ||
project-id: ${GOOGLE_CLOUD_PROJECT_ID:gsync} | ||
instance-id: ${GOOGLE_CLOUD_SPANNER_INSTANCE_ID:gsync} | ||
database-id: ${GOOGLE_CLOUD_SPANNER_DATABASE_NAME:gsync} | ||
spanner: | ||
emulator-host: http://localhost:9020 |
6 changes: 6 additions & 0 deletions
6
src/test/groovy/net/averak/gsync/adapter/handler/controller/AbstractController_IT.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package net.averak.gsync.adapter.handler.controller | ||
|
||
import net.averak.gsync.AbstractSpec | ||
|
||
class AbstractController_IT extends AbstractSpec { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.