diff --git a/src/main/kotlin/com/hero/alignlab/domain/health/resource/HealthRsocket.kt b/src/main/kotlin/com/hero/alignlab/domain/health/resource/HealthRsocket.kt new file mode 100644 index 0000000..1b55965 --- /dev/null +++ b/src/main/kotlin/com/hero/alignlab/domain/health/resource/HealthRsocket.kt @@ -0,0 +1,23 @@ +package com.hero.alignlab.domain.health.resource + +import com.hero.alignlab.common.model.Response +import com.hero.alignlab.domain.health.model.response.HealthResponse +import io.github.oshai.kotlinlogging.KotlinLogging +import org.springframework.core.env.Environment +import org.springframework.messaging.handler.annotation.MessageMapping +import org.springframework.stereotype.Controller + +@Controller +class HealthRsocket( + private val environment: Environment +) { + private val logger = KotlinLogging.logger {} + + @MessageMapping("rs.health") + suspend fun healthSocket(): Response { + logger.debug { "rsocket health check" } + return environment.activeProfiles.first() + .run { HealthResponse.from(this) } + .run { Response(this) } + } +}