mirror of https://github.com/usbharu/Hideout.git
refactor: JobQueue関連の名前を変更
This commit is contained in:
parent
4b0484df64
commit
2faef66dc2
|
@ -15,8 +15,8 @@ import dev.usbharu.hideout.service.IUserAuthService
|
||||||
import dev.usbharu.hideout.service.activitypub.*
|
import dev.usbharu.hideout.service.activitypub.*
|
||||||
import dev.usbharu.hideout.service.impl.UserAuthService
|
import dev.usbharu.hideout.service.impl.UserAuthService
|
||||||
import dev.usbharu.hideout.service.impl.UserService
|
import dev.usbharu.hideout.service.impl.UserService
|
||||||
import dev.usbharu.hideout.service.job.JobQueueService
|
import dev.usbharu.hideout.service.job.JobQueueParentService
|
||||||
import dev.usbharu.hideout.service.job.KJobJobQueueService
|
import dev.usbharu.hideout.service.job.KJobJobQueueParentService
|
||||||
import dev.usbharu.hideout.service.signature.HttpSignatureVerifyService
|
import dev.usbharu.hideout.service.signature.HttpSignatureVerifyService
|
||||||
import dev.usbharu.hideout.service.signature.HttpSignatureVerifyServiceImpl
|
import dev.usbharu.hideout.service.signature.HttpSignatureVerifyServiceImpl
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
|
@ -54,7 +54,7 @@ fun Application.module() {
|
||||||
single<IUserAuthRepository> { UserAuthRepository(get()) }
|
single<IUserAuthRepository> { UserAuthRepository(get()) }
|
||||||
single<IUserAuthService> { UserAuthService(get(), get()) }
|
single<IUserAuthService> { UserAuthService(get(), get()) }
|
||||||
single<HttpSignatureVerifyService> { HttpSignatureVerifyServiceImpl(get()) }
|
single<HttpSignatureVerifyService> { HttpSignatureVerifyServiceImpl(get()) }
|
||||||
single<JobQueueService> { val kJobJobQueueService = KJobJobQueueService(get())
|
single<JobQueueParentService> { val kJobJobQueueService = KJobJobQueueParentService(get())
|
||||||
kJobJobQueueService.init(listOf())
|
kJobJobQueueService.init(listOf())
|
||||||
kJobJobQueueService
|
kJobJobQueueService
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,13 @@ import dev.usbharu.hideout.ap.Follow
|
||||||
import dev.usbharu.hideout.domain.model.ActivityPubResponse
|
import dev.usbharu.hideout.domain.model.ActivityPubResponse
|
||||||
import dev.usbharu.hideout.domain.model.ActivityPubStringResponse
|
import dev.usbharu.hideout.domain.model.ActivityPubStringResponse
|
||||||
import dev.usbharu.hideout.domain.model.job.AcceptFollowJob
|
import dev.usbharu.hideout.domain.model.job.AcceptFollowJob
|
||||||
import dev.usbharu.hideout.service.job.JobQueueService
|
import dev.usbharu.hideout.service.job.JobQueueParentService
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
|
|
||||||
class ActivityPubFollowServiceImpl(private val jobQueueService: JobQueueService) : ActivityPubFollowService {
|
class ActivityPubFollowServiceImpl(private val jobQueueParentService: JobQueueParentService) : ActivityPubFollowService {
|
||||||
override suspend fun receiveFollow(follow: Follow): ActivityPubResponse {
|
override suspend fun receiveFollow(follow: Follow): ActivityPubResponse {
|
||||||
// TODO: Verify HTTP Signature
|
// TODO: Verify HTTP Signature
|
||||||
jobQueueService.schedule(AcceptFollowJob)
|
jobQueueParentService.schedule(AcceptFollowJob)
|
||||||
return ActivityPubStringResponse(HttpStatusCode.OK,"{}",ContentType.Application.Json)
|
return ActivityPubStringResponse(HttpStatusCode.OK,"{}",ContentType.Application.Json)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package dev.usbharu.hideout.service.job
|
||||||
import kjob.core.Job
|
import kjob.core.Job
|
||||||
import kjob.core.dsl.ScheduleContext
|
import kjob.core.dsl.ScheduleContext
|
||||||
|
|
||||||
interface JobQueueService {
|
interface JobQueueParentService {
|
||||||
|
|
||||||
fun init(jobDefines:List<Job>)
|
fun init(jobDefines:List<Job>)
|
||||||
suspend fun <J : Job> schedule(job: J, block: ScheduleContext<J>.(J) -> Unit = {})
|
suspend fun <J : Job> schedule(job: J, block: ScheduleContext<J>.(J) -> Unit = {})
|
|
@ -5,6 +5,6 @@ import kjob.core.dsl.JobContextWithProps
|
||||||
import kjob.core.dsl.JobRegisterContext
|
import kjob.core.dsl.JobRegisterContext
|
||||||
import kjob.core.dsl.KJobFunctions
|
import kjob.core.dsl.KJobFunctions
|
||||||
|
|
||||||
interface JobWorkerService {
|
interface JobQueueWorkerService {
|
||||||
fun init(defines: List<Pair<Job, JobRegisterContext<Job, JobContextWithProps<Job>>.(Job) -> KJobFunctions<Job, JobContextWithProps<Job>>>>)
|
fun init(defines: List<Pair<Job, JobRegisterContext<Job, JobContextWithProps<Job>>.(Job) -> KJobFunctions<Job, JobContextWithProps<Job>>>>)
|
||||||
}
|
}
|
|
@ -7,7 +7,7 @@ import kjob.core.dsl.ScheduleContext
|
||||||
import kjob.core.kjob
|
import kjob.core.kjob
|
||||||
import org.jetbrains.exposed.sql.Database
|
import org.jetbrains.exposed.sql.Database
|
||||||
|
|
||||||
class KJobJobQueueService(private val database: Database) : JobQueueService {
|
class KJobJobQueueParentService(private val database: Database) : JobQueueParentService {
|
||||||
|
|
||||||
val kjob: KJob = kjob(ExposedKJob) {
|
val kjob: KJob = kjob(ExposedKJob) {
|
||||||
connectionDatabase = database
|
connectionDatabase = database
|
|
@ -8,7 +8,7 @@ import kjob.core.dsl.KJobFunctions
|
||||||
import kjob.core.kjob
|
import kjob.core.kjob
|
||||||
import org.jetbrains.exposed.sql.Database
|
import org.jetbrains.exposed.sql.Database
|
||||||
|
|
||||||
class KJobJobWorkerService(private val database: Database) : JobWorkerService {
|
class KJobJobQueueWorkerService(private val database: Database) : JobQueueWorkerService {
|
||||||
|
|
||||||
val kjob by lazy {
|
val kjob by lazy {
|
||||||
kjob(ExposedKJob) {
|
kjob(ExposedKJob) {
|
|
@ -4,13 +4,13 @@ import kjob.core.Job
|
||||||
import org.jetbrains.exposed.sql.Database
|
import org.jetbrains.exposed.sql.Database
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class KJobJobWorkerServiceTest {
|
class KJobJobQueueWorkerServiceTest {
|
||||||
|
|
||||||
object TestJob : Job("test-job")
|
object TestJob : Job("test-job")
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun init() {
|
fun init() {
|
||||||
val kJobJobWorkerService = KJobJobWorkerService(Database.connect("jdbc:h2:mem:"))
|
val kJobJobWorkerService = KJobJobQueueWorkerService(Database.connect("jdbc:h2:mem:"))
|
||||||
kJobJobWorkerService.init(listOf(TestJob to { it -> execute { it as TestJob;println(it.propNames) } }))
|
kJobJobWorkerService.init(listOf(TestJob to { it -> execute { it as TestJob;println(it.propNames) } }))
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue