Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M7l5 gremlin (#32) #34

Merged
merged 2 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions deploy/docker-compose-arcadedb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.3"
services:
arcadedb:
image: "arcadedata/arcadedb:24.4.1"
ports:
- "2480:2480"
- "2424:2424"
- "8182:8182"
# volumes:
# - ./volumes/arcadedb:/home/arcadedb/databases
# Здесь можно добавить доступные через gremlin графы и псевдонимы
# - ./volumes/arcadedb:/home/arcadedb/config/gremlin-server.groovy
environment:
JAVA_OPTS: >
-Darcadedb.server.rootPassword=root_root
-Darcadedb.server.plugins=GremlinServer:com.arcadedb.server.gremlin.GremlinServerPlugin
8 changes: 8 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ spring-boot = "3.2.0"
liquibase = "4.27.0"
exposed = "0.50.0"
cassandra = "4.17.0"
arcadedb = "24.4.1"
gremlin = "3.7.2"

# Docker
testcontainers = "1.19.7"
Expand Down Expand Up @@ -98,6 +100,12 @@ db-cassandra-qbuilder = { module = "com.datastax.oss:java-driver-query-builder",
db-cassandra-kapt = { module = "com.datastax.oss:java-driver-mapper-processor", version.ref = "cassandra" }
db-cassandra-mapper = { module = "com.datastax.oss:java-driver-mapper-runtime", version.ref = "cassandra" }

# Gremlin
gdb-gremlin-driver = { module = "org.apache.tinkerpop:gremlin-driver", version.ref = "gremlin" }
gdb-arcade-engine = { module = "com.arcadedb:arcadedb-engine", version.ref = "arcadedb" }
gdb-arcade-network = { module = "com.arcadedb:arcadedb-network", version.ref = "arcadedb" }
gdb-arcade-gremlin = { module = "com.arcadedb:arcadedb-gremlin", version.ref = "arcadedb" }

# Liquidbase
liquibase-core = { module = "org.liquibase:liquibase-core", version.ref = "liquibase" }
liquibase-picocli = "info.picocli:picocli:4.7.5"
Expand Down
2 changes: 2 additions & 0 deletions ok-marketplace-be/ok-marketplace-app-ktor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ kotlin {
implementation(project(":ok-marketplace-api-v1-mappers"))

implementation(projects.okMarketplaceRepoCassandra)
implementation(projects.okMarketplaceRepoGremlin)

implementation("ru.otus.otuskotlin.marketplace.libs:ok-marketplace-lib-logging-logback")
implementation(libs.testcontainers.cassandra)
implementation(libs.testcontainers.core)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,25 @@ marketplace:
repository:
test: "inmemory"
prod: "$DB_TYPE_PROD:inmemory"

psql:
schema: public
database: "$MKPLADS_DB:marketplace-ads"
host: "$MKPLADS_HOST:localhost"
port: "$MKPLADS_PORT:5432"
user: "$MKPLADS_USER:postgres"
password: "$MKPLADS_PASS:marketplace-pass"

cassandra:
hosts: localhost
keyspace: test_keyspace
pass: cassandra
port: 9042
user: cassandra

gremlin:
host: "$DB_GREMLIN_HOST:localhost"
user: "$DB_GREMLIN_HOST:root"
password: "$DB_GREMLIN_HOST:root_root"
port: "$DB_GREMLIN_PORT:8182"
enableSsl: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package ru.otus.otuskotlin.marketplace.app.ktor.configs

import io.ktor.server.config.*

data class GremlinConfig(
val host: String = "localhost",
val port: Int = 8182,
val user: String = "root",
val pass: String,
val enableSsl: Boolean = false,
) {
constructor(config: ApplicationConfig): this(
host = config.property("$PATH.host").getString(),
user = config.property("$PATH.user").getString(),
pass = config.property("$PATH.password").getString(),
enableSsl = config.property("$PATH.enableSsl").getString().toBoolean(),
)

companion object {
const val PATH = "${ConfigPaths.repository}.gremlin"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package ru.otus.otuskotlin.marketplace.app.ktor.plugins
import io.ktor.server.application.*
import ru.otus.otuskotlin.marketplace.app.ktor.configs.CassandraConfig
import ru.otus.otuskotlin.marketplace.app.ktor.configs.ConfigPaths
import ru.otus.otuskotlin.marketplace.app.ktor.configs.GremlinConfig
import ru.otus.otuskotlin.marketplace.backend.repo.cassandra.RepoAdCassandra
import ru.otus.otuskotlin.marketplace.backend.repository.gremlin.AdRepoGremlin
import ru.otus.otuskotlin.marketplace.common.repo.IRepoAd

actual fun Application.getDatabaseConf(type: AdDbType): IRepoAd {
Expand All @@ -13,6 +15,7 @@ actual fun Application.getDatabaseConf(type: AdDbType): IRepoAd {
"in-memory", "inmemory", "memory", "mem" -> initInMemory()
"postgres", "postgresql", "pg", "sql", "psql" -> initPostgres()
"cassandra", "nosql", "cass" -> initCassandra()
"arcade", "arcadedb", "graphdb", "gremlin", "g", "a" -> initGremliln()
else -> throw IllegalArgumentException(
"$dbSettingPath must be set in application.yml to one of: " +
"'inmemory', 'postgres', 'cassandra', 'gremlin'"
Expand All @@ -31,3 +34,13 @@ private fun Application.initCassandra(): IRepoAd {
)
}

private fun Application.initGremliln(): IRepoAd {
val config = GremlinConfig(environment.config)
return AdRepoGremlin(
hosts = config.host,
port = config.port,
user = config.user,
pass = config.pass,
enableSsl = config.enableSsl,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,30 @@ ktor:
# queue: mkpl-ads-v1-queue
# consumerTag: "mkpl-ads-v1-consumer"
# exchangeType: direct

marketplace:
repository:
test: "inmemory"
prod: "$DB_TYPE_PROD:inmemory"

psql:
schema: public
database: "$MKPLADS_DB:marketplace-ads"
host: "$MKPLADS_HOST:localhost"
port: "$MKPLADS_PORT:5432"
user: "$MKPLADS_USER:postgres"
password: "$MKPLADS_PASS:marketplace-pass"

cassandra:
hosts: localhost
keyspace: test_keyspace
pass: cassandra
port: 9042
user: cassandra

gremlin:
host: "$DB_GREMLIN_HOST:localhost"
user: "$DB_GREMLIN_HOST:root"
password: "$DB_GREMLIN_HOST:root_root"
port: "$DB_GREMLIN_PORT:8182"
enableSsl: false
18 changes: 0 additions & 18 deletions ok-marketplace-be/ok-marketplace-app-tmp/build.gradle.kts

This file was deleted.

53 changes: 0 additions & 53 deletions ok-marketplace-be/ok-marketplace-app-tmp/src/main/kotlin/Main.kt

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fun errorEmptyLock(id: MkplAdId) = DbAdResponseErr(

fun errorDb(e: RepoException) = DbAdResponseErr(
errorSystem(
violationCode = "dbLockEmpty",
violationCode = "db-error",
e = e
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package ru.otus.otuskotlin.marketplace.common.repo.exceptions

class UnknownDbException(mes: String): RepoException(mes)
Loading
Loading