From 25c2b99ab09ab574a138d140b7a87d2a3f95ca52 Mon Sep 17 00:00:00 2001 From: MykytaPimonovTD Date: Mon, 20 May 2024 18:50:14 +0300 Subject: [PATCH 1/5] Delete useless `UserSessionRepository`. --- .../pingh/sessions/SessionsContext.kt | 3 +- .../pingh/sessions/UserSessionRepository.kt | 53 ------------------- 2 files changed, 2 insertions(+), 54 deletions(-) delete mode 100644 sessions/src/main/kotlin/io/spine/examples/pingh/sessions/UserSessionRepository.kt diff --git a/sessions/src/main/kotlin/io/spine/examples/pingh/sessions/SessionsContext.kt b/sessions/src/main/kotlin/io/spine/examples/pingh/sessions/SessionsContext.kt index 00a07c08..816c80df 100644 --- a/sessions/src/main/kotlin/io/spine/examples/pingh/sessions/SessionsContext.kt +++ b/sessions/src/main/kotlin/io/spine/examples/pingh/sessions/SessionsContext.kt @@ -28,6 +28,7 @@ package io.spine.examples.pingh.sessions import io.spine.server.BoundedContext import io.spine.server.BoundedContextBuilder +import io.spine.server.procman.DefaultProcessManagerRepository /** * Name of the Sessions [BoundedContext]. @@ -39,4 +40,4 @@ public const val NAME: String = "Sessions" */ public fun newBuilder(): BoundedContextBuilder = BoundedContext.singleTenant(NAME) - .add(UserSessionRepository()) + .add(DefaultProcessManagerRepository(UserSessionProcess::class.java)) diff --git a/sessions/src/main/kotlin/io/spine/examples/pingh/sessions/UserSessionRepository.kt b/sessions/src/main/kotlin/io/spine/examples/pingh/sessions/UserSessionRepository.kt deleted file mode 100644 index c4b6197d..00000000 --- a/sessions/src/main/kotlin/io/spine/examples/pingh/sessions/UserSessionRepository.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2024, TeamDev. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Redistribution and use in source and/or binary forms, with or without - * modification, must retain the above copyright notice and the following - * disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package io.spine.examples.pingh.sessions - -import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper -import io.spine.examples.pingh.sessions.event.UserLoggedIn -import io.spine.examples.pingh.sessions.event.UserLoggedOut -import io.spine.server.procman.ProcessManagerRepository -import io.spine.server.route.EventRoute.withId -import io.spine.server.route.EventRouting - -/** - * Manages instances of [UserSessionProcess]. - */ -public class UserSessionRepository : - ProcessManagerRepository() { - - @OverridingMethodsMustInvokeSuper - override fun setupEventRouting(routing: EventRouting) { - super.setupEventRouting(routing) - routing - .route(UserLoggedIn::class.java) { event, _ -> - withId(event.id) - } - .route(UserLoggedOut::class.java) { event, _ -> - withId(event.id) - } - } -} From ed44ea7db0a3f9acbcf790caab678ed9767aebb4 Mon Sep 17 00:00:00 2001 From: MykytaPimonovTD Date: Mon, 20 May 2024 19:33:01 +0300 Subject: [PATCH 2/5] Fix bug that caused rejections to not be generated in time for building. --- mentions/build.gradle.kts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mentions/build.gradle.kts b/mentions/build.gradle.kts index 699d34fe..8999522d 100644 --- a/mentions/build.gradle.kts +++ b/mentions/build.gradle.kts @@ -54,6 +54,14 @@ kotlin { explicitApi() } +/** + * Kotlin code compilation task waits until + * Protobuf files are fully generated and rejections are created. + */ +tasks.named("compileKotlin") { + dependsOn("generateRejections") +} + dependencies { implementation(project(":github")) implementation(project(":sessions")) From 9bceb417ada0154ac91e3a3f8bbee09931d84570 Mon Sep 17 00:00:00 2001 From: MykytaPimonovTD Date: Mon, 20 May 2024 20:32:14 +0300 Subject: [PATCH 3/5] Simplify `sessions` context creation using builder method. --- .../kotlin/io/spine/examples/pingh/sessions/SessionsContext.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sessions/src/main/kotlin/io/spine/examples/pingh/sessions/SessionsContext.kt b/sessions/src/main/kotlin/io/spine/examples/pingh/sessions/SessionsContext.kt index 816c80df..b3e73437 100644 --- a/sessions/src/main/kotlin/io/spine/examples/pingh/sessions/SessionsContext.kt +++ b/sessions/src/main/kotlin/io/spine/examples/pingh/sessions/SessionsContext.kt @@ -28,7 +28,6 @@ package io.spine.examples.pingh.sessions import io.spine.server.BoundedContext import io.spine.server.BoundedContextBuilder -import io.spine.server.procman.DefaultProcessManagerRepository /** * Name of the Sessions [BoundedContext]. @@ -40,4 +39,4 @@ public const val NAME: String = "Sessions" */ public fun newBuilder(): BoundedContextBuilder = BoundedContext.singleTenant(NAME) - .add(DefaultProcessManagerRepository(UserSessionProcess::class.java)) + .add(UserSessionProcess::class.java) From fb053f6a741919b1781640ae5026b3607b896371 Mon Sep 17 00:00:00 2001 From: MykytaPimonovTD Date: Mon, 20 May 2024 20:44:57 +0300 Subject: [PATCH 4/5] Write TODO to point out poor way of organizing Gradle tasks. --- mentions/build.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mentions/build.gradle.kts b/mentions/build.gradle.kts index 8999522d..0a009aa0 100644 --- a/mentions/build.gradle.kts +++ b/mentions/build.gradle.kts @@ -58,6 +58,8 @@ kotlin { * Kotlin code compilation task waits until * Protobuf files are fully generated and rejections are created. */ +// TODO:2024-05-20:MykytaPimonovTD: Rewrite the way of organizing tasks, +// using task inputs and outputs. tasks.named("compileKotlin") { dependsOn("generateRejections") } From becc1fc280f0a35a34613a6027117af3dc305836 Mon Sep 17 00:00:00 2001 From: MykytaPimonovTD Date: Tue, 21 May 2024 12:05:41 +0300 Subject: [PATCH 5/5] Add link to GitHub conservation in TODO message. --- mentions/build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mentions/build.gradle.kts b/mentions/build.gradle.kts index 0a009aa0..32f66396 100644 --- a/mentions/build.gradle.kts +++ b/mentions/build.gradle.kts @@ -58,8 +58,9 @@ kotlin { * Kotlin code compilation task waits until * Protobuf files are fully generated and rejections are created. */ -// TODO:2024-05-20:MykytaPimonovTD: Rewrite the way of organizing tasks, +// TODO:2024-05-20:mykyta.pimonov: Rewrite the way of organizing tasks, // using task inputs and outputs. +// See: https://github.com/spine-examples/Pingh/pull/7#discussion_r1607043747. tasks.named("compileKotlin") { dependsOn("generateRejections") }