From abf3b329e23c7ee67c3cf96bf4ff993f5337198d Mon Sep 17 00:00:00 2001 From: usbharu <64310155+usbharu@users.noreply.github.com> Date: Sun, 12 May 2024 00:19:09 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=E3=83=97=E3=83=AD=E3=82=B8=E3=82=A7?= =?UTF-8?q?=E3=82=AF=E3=83=88=E6=A7=8B=E9=80=A0=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/pull-request-merge-check.yml | 12 ++++---- build.gradle.kts | 28 ++++++++++++++++++ .../dev/usbharu/hideout/HideoutWorker.kt | 29 +++++++++++++++++++ .../dev/usbharu/hideout/WorkerRunner.kt | 13 ++++++++- .../hideout/worker/SpringConsumerConfig.kt | 28 ++++++++++++++++++ settings.gradle.kts | 3 +- 6 files changed, 105 insertions(+), 8 deletions(-) create mode 100644 hideout-worker/src/main/kotlin/dev/usbharu/hideout/HideoutWorker.kt create mode 100644 hideout-worker/src/main/kotlin/dev/usbharu/hideout/worker/SpringConsumerConfig.kt diff --git a/.github/workflows/pull-request-merge-check.yml b/.github/workflows/pull-request-merge-check.yml index d2082154..0eff5c92 100644 --- a/.github/workflows/pull-request-merge-check.yml +++ b/.github/workflows/pull-request-merge-check.yml @@ -61,7 +61,7 @@ jobs: - name: Build uses: gradle/gradle-build-action@v3.3.2 with: - arguments: testClasses + arguments: :hideout-core:testClasses unit-test: name: Unit Test @@ -113,7 +113,7 @@ jobs: - name: Unit Test uses: gradle/gradle-build-action@v3.3.2 with: - arguments: test + arguments: :hideout-core:test - name: Save Test Report if: always() @@ -177,7 +177,7 @@ jobs: - name: Unit Test uses: gradle/gradle-build-action@v3.3.2 with: - arguments: integrationTest + arguments: :hideout-core:integrationTest - name: Save Test Report if: always() @@ -236,7 +236,7 @@ jobs: - name: Run Kover uses: gradle/gradle-build-action@v3.3.2 with: - arguments: koverXmlReport -x integrationTest -x e2eTest --rerun-tasks + arguments: :hideout-core:koverXmlReport -x :hideout-core:integrationTest -x :hideout-core:e2eTest --rerun-tasks - name: Add coverage report to PR if: always() @@ -331,7 +331,7 @@ jobs: - name: Build with Gradle uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff with: - arguments: detektMain + arguments: :hideout-core:detektMain - name: "reviewdog-suggester: Suggest any code changes based on diff with reviewdog" if: ${{ always() }} @@ -401,7 +401,7 @@ jobs: - name: E2E Test uses: gradle/gradle-build-action@v3.3.2 with: - arguments: e2eTest + arguments: :hideout-core:e2eTest - name: Save Test Report diff --git a/build.gradle.kts b/build.gradle.kts index e69de29b..c0e7f565 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2024 usbharu + * + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + alias(libs.plugins.kotlin.jvm) +} + +dependencies { + implementation("dev.usbharu:hideout-core:0.0.1") + implementation("dev.usbharu:hideout-worker:0.0.1") +} + +tasks.register("run") { + dependsOn(gradle.includedBuild("hideout-core").task(":run")) +} \ No newline at end of file diff --git a/hideout-worker/src/main/kotlin/dev/usbharu/hideout/HideoutWorker.kt b/hideout-worker/src/main/kotlin/dev/usbharu/hideout/HideoutWorker.kt new file mode 100644 index 00000000..3ef74a43 --- /dev/null +++ b/hideout-worker/src/main/kotlin/dev/usbharu/hideout/HideoutWorker.kt @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2024 usbharu + * + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package dev.usbharu.hideout + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.context.properties.ConfigurationPropertiesScan +import org.springframework.boot.runApplication + +@SpringBootApplication +@ConfigurationPropertiesScan +class HideoutWorker + +fun main(args: Array) { + runApplication(*args) +} \ No newline at end of file diff --git a/hideout-worker/src/main/kotlin/dev/usbharu/hideout/WorkerRunner.kt b/hideout-worker/src/main/kotlin/dev/usbharu/hideout/WorkerRunner.kt index b19836b0..47f0b98e 100644 --- a/hideout-worker/src/main/kotlin/dev/usbharu/hideout/WorkerRunner.kt +++ b/hideout-worker/src/main/kotlin/dev/usbharu/hideout/WorkerRunner.kt @@ -17,8 +17,10 @@ package dev.usbharu.hideout import com.fasterxml.jackson.databind.ObjectMapper +import dev.usbharu.hideout.worker.SpringConsumerConfig import dev.usbharu.owl.common.property.* import dev.usbharu.owl.consumer.StandaloneConsumer +import dev.usbharu.owl.consumer.StandaloneConsumerConfig import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch @@ -31,11 +33,13 @@ import org.springframework.stereotype.Component class WorkerRunner( private val springTaskRunnerLoader: SpringTaskRunnerLoader, @Qualifier("activitypub") private val objectMapper: ObjectMapper, + private val springCConsumerConfig: SpringConsumerConfig, ) : ApplicationRunner { override fun run(args: ApplicationArguments?) { GlobalScope.launch(Dispatchers.Default) { val consumer = StandaloneConsumer( - taskRunnerLoader = springTaskRunnerLoader, propertySerializerFactory = CustomPropertySerializerFactory( + taskRunnerLoader = springTaskRunnerLoader, + propertySerializerFactory = CustomPropertySerializerFactory( setOf( IntegerPropertySerializer(), StringPropertyValueSerializer(), @@ -45,6 +49,13 @@ class WorkerRunner( FloatPropertySerializer(), ObjectPropertySerializer(objectMapper), ) + ), + config = StandaloneConsumerConfig( + springCConsumerConfig.address, + springCConsumerConfig.port, + springCConsumerConfig.name, + springCConsumerConfig.hostname, + springCConsumerConfig.concurrency ) ) consumer.init() diff --git a/hideout-worker/src/main/kotlin/dev/usbharu/hideout/worker/SpringConsumerConfig.kt b/hideout-worker/src/main/kotlin/dev/usbharu/hideout/worker/SpringConsumerConfig.kt new file mode 100644 index 00000000..2fa99d6b --- /dev/null +++ b/hideout-worker/src/main/kotlin/dev/usbharu/hideout/worker/SpringConsumerConfig.kt @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2024 usbharu + * + * 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package dev.usbharu.hideout.worker + +import org.springframework.boot.context.properties.ConfigurationProperties + +@ConfigurationProperties("hideout.worker") +data class SpringConsumerConfig( + val address: String = "localhost", + val port: Int = 50051, + val name: String = "hideout-worker", + val hostname: String = "localhost", + val concurrency: Int = 10, +) diff --git a/settings.gradle.kts b/settings.gradle.kts index d68d7e07..2a3ed72d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -19,7 +19,8 @@ plugins { } rootProject.name = "hideout" -includeBuild("owl") +includeBuild("hideout-core") +includeBuild("hideout-worker") dependencyResolutionManagement { repositories {