Skip to content

Commit 3ed6afc

Browse files
committed
M7l5 gremlin
1 parent ad3a6de commit 3ed6afc

File tree

6 files changed

+16
-200
lines changed

6 files changed

+16
-200
lines changed

ok-marketplace-be/ok-marketplace-app-tmp/build.gradle.kts

-18
This file was deleted.

ok-marketplace-be/ok-marketplace-app-tmp/src/main/kotlin/Main.kt

-53
This file was deleted.

ok-marketplace-be/ok-marketplace-app-tmp/src/main/resources/logback.xml_

-122
This file was deleted.

ok-marketplace-be/ok-marketplace-repo-gremlin/src/main/kotlin/AdRepoGremlin.kt

+11-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AdRepoGremlin(
3030
private val graph: String = "graph", // Этот граф должен быть настроен в /home/arcadedb/config/gremlin-server.groovy
3131
val randomUuid: () -> String = { uuid4().toString() },
3232
initRepo: ((GraphTraversalSource) -> Unit)? = null,
33-
) : AdRepoBase(), IRepoAd, IRepoAdInitializable {
33+
) : AdRepoBase(), IRepoAd, IRepoAdInitializable, AutoCloseable {
3434

3535
private val cluster by lazy {
3636
Cluster.build().apply {
@@ -66,7 +66,7 @@ class AdRepoGremlin(
6666
?: errorDb(UnknownDbException("Db object was not returned after creation by DB: $rq"))
6767
}
6868

69-
private suspend fun <T: Any> checkNotFound(block: suspend () -> T?): T? = runCatching { block() }.getOrElse { e ->
69+
private suspend fun <T : Any> checkNotFound(block: suspend () -> T?): T? = runCatching { block() }.getOrElse { e ->
7070
if (e.cause is ResponseException) null else throw e
7171
}
7272

@@ -148,4 +148,13 @@ class AdRepoGremlin(
148148
.let { result -> DbAdsResponseOk(data = result.map { it.toMkplAd() }) }
149149
}
150150

151+
override fun close() {
152+
if ((::g::getDelegate as? Lazy<*>)?.isInitialized() == true) {
153+
g.close()
154+
}
155+
if ((::cluster::getDelegate as? Lazy<*>)?.isInitialized() == true) {
156+
cluster.close()
157+
}
158+
}
159+
151160
}

ok-marketplace-be/ok-marketplace-repo-gremlin/src/test/kotlin/AdRepoGremlinTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class RepoAdGremlinReadTest : RepoAdReadTest() {
1717
initObjects = initObjects,
1818
repo = ArcadeDbContainer.repository("test_read")
1919
)
20-
override val readSucc = repo.initializedObjects[0]
20+
override val readSucc = repo.initializedObjects[0]
2121
}
2222

2323
class RepoAdGremlinUpdateTest : RepoAdUpdateTest() {

ok-marketplace-be/ok-marketplace-repo-gremlin/src/test/kotlin/SimpleTest.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.`__` as bs
1818
* Для запуска тестов этого файла требуется запустить локальный экземпляр ArcadeDB
1919
* Можно использовать файл /deploy/docker-compose-arcadedb.yml
2020
*/
21-
@Ignore("Тест для экспериментов")
21+
//@Ignore("Тест для экспериментов")
2222
class SimpleTest {
2323
private val host: String = "localhost"
2424
private val user: String = "root"
2525
private val pass: String = "root_root"
2626

2727
private val dbName: String = "graph"
2828

29-
// private val dbName: String = "mkpl" // Этот граф должен быть настроен в /home/arcadedb/config/gremlin-server.groovy
29+
// private val dbName: String = "mkpl" // Этот граф должен быть настроен в /home/arcadedb/config/gremlin-server.groovy
3030
private val aPort: Int = 2480
3131
private val gPort: Int = 8182
3232

@@ -116,7 +116,7 @@ class SimpleTest {
116116
.toList()
117117
println("CONTENT: ${x}")
118118

119-
val y = g.V().hasLabel("Test").`as`("a")
119+
val y = g.V().hasLabel("Test") //.`as`("a")
120120
.project<Any?>("lock", "ownerId", "z")
121121
.by("lock")
122122
// Извлекаем ID связанного объекта (связь через грань Owns
@@ -173,7 +173,7 @@ class SimpleTest {
173173
.choose(
174174
bs.select<Vertex, Vertex>("a")
175175
.values<String>("lock")
176-
.`is`("1112"),
176+
.`is`("111"),
177177
bs.select<Vertex, String>("a").drop().inject("success"),
178178
bs.constant("lock-failure")
179179
).toList()

0 commit comments

Comments
 (0)