mirror of https://github.com/usbharu/Hideout.git
feat: mongodbのurlを変更可能に
This commit is contained in:
parent
3c1b262d6f
commit
f391221bc0
|
@ -132,6 +132,7 @@ dependencies {
|
||||||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
|
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
|
||||||
implementation("org.springframework.security:spring-security-oauth2-jose")
|
implementation("org.springframework.security:spring-security-oauth2-jose")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
|
implementation("org.springframework.boot:spring-boot-starter-data-mongodb")
|
||||||
|
implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive")
|
||||||
implementation("org.jetbrains.exposed:exposed-spring-boot-starter:0.44.0")
|
implementation("org.jetbrains.exposed:exposed-spring-boot-starter:0.44.0")
|
||||||
implementation("io.trbl:blurhash:1.0.0")
|
implementation("io.trbl:blurhash:1.0.0")
|
||||||
implementation("software.amazon.awssdk:s3:2.20.157")
|
implementation("software.amazon.awssdk:s3:2.20.157")
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package dev.usbharu.hideout.core.infrastructure.kjobmongodb
|
package dev.usbharu.hideout.core.infrastructure.kjobmongodb
|
||||||
|
|
||||||
|
import com.mongodb.reactivestreams.client.MongoClient
|
||||||
import dev.usbharu.hideout.core.service.job.JobQueueWorkerService
|
import dev.usbharu.hideout.core.service.job.JobQueueWorkerService
|
||||||
import kjob.core.dsl.JobRegisterContext
|
import kjob.core.dsl.JobRegisterContext
|
||||||
import kjob.core.dsl.KJobFunctions
|
import kjob.core.dsl.KJobFunctions
|
||||||
|
@ -12,10 +13,10 @@ import kjob.core.dsl.JobContextWithProps as JCWP
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ConditionalOnProperty(name = ["hideout.use-mongodb"], havingValue = "true", matchIfMissing = false)
|
@ConditionalOnProperty(name = ["hideout.use-mongodb"], havingValue = "true", matchIfMissing = false)
|
||||||
class KJobMongoJobQueueWorkerService : JobQueueWorkerService {
|
class KJobMongoJobQueueWorkerService(private val mongoClient: MongoClient) : JobQueueWorkerService, AutoCloseable {
|
||||||
val kjob by lazy {
|
val kjob by lazy {
|
||||||
kjob(Mongo) {
|
kjob(Mongo) {
|
||||||
connectionString = "mongodb://localhost"
|
client = mongoClient
|
||||||
nonBlockingMaxJobs = 10
|
nonBlockingMaxJobs = 10
|
||||||
blockingMaxJobs = 10
|
blockingMaxJobs = 10
|
||||||
jobExecutionPeriodInSeconds = 1
|
jobExecutionPeriodInSeconds = 1
|
||||||
|
@ -29,4 +30,8 @@ class KJobMongoJobQueueWorkerService : JobQueueWorkerService {
|
||||||
kjob.register(job.first, job.second)
|
kjob.register(job.first, job.second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun close() {
|
||||||
|
kjob.shutdown()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package dev.usbharu.hideout.core.infrastructure.kjobmongodb
|
package dev.usbharu.hideout.core.infrastructure.kjobmongodb
|
||||||
|
|
||||||
|
import com.mongodb.reactivestreams.client.MongoClient
|
||||||
import dev.usbharu.hideout.core.service.job.JobQueueParentService
|
import dev.usbharu.hideout.core.service.job.JobQueueParentService
|
||||||
import kjob.core.Job
|
import kjob.core.Job
|
||||||
import kjob.core.dsl.ScheduleContext
|
import kjob.core.dsl.ScheduleContext
|
||||||
|
@ -10,9 +11,9 @@ import org.springframework.stereotype.Service
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ConditionalOnProperty(name = ["hideout.use-mongodb"], havingValue = "true", matchIfMissing = false)
|
@ConditionalOnProperty(name = ["hideout.use-mongodb"], havingValue = "true", matchIfMissing = false)
|
||||||
class KjobMongoJobQueueParentService : JobQueueParentService {
|
class KjobMongoJobQueueParentService(private val mongoClient: MongoClient) : JobQueueParentService, AutoCloseable {
|
||||||
private val kjob = kjob(Mongo) {
|
private val kjob = kjob(Mongo) {
|
||||||
connectionString = "mongodb://localhost"
|
client = mongoClient
|
||||||
databaseName = "kjob"
|
databaseName = "kjob"
|
||||||
jobCollection = "kjob-jobs"
|
jobCollection = "kjob-jobs"
|
||||||
lockCollection = "kjob-locks"
|
lockCollection = "kjob-locks"
|
||||||
|
@ -25,4 +26,8 @@ class KjobMongoJobQueueParentService : JobQueueParentService {
|
||||||
override suspend fun <J : Job> schedule(job: J, block: ScheduleContext<J>.(J) -> Unit) {
|
override suspend fun <J : Job> schedule(job: J, block: ScheduleContext<J>.(J) -> Unit) {
|
||||||
kjob.schedule(job, block)
|
kjob.schedule(job, block)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun close() {
|
||||||
|
kjob.shutdown()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue