Skip to content

Commit 3758582

Browse files
committed
fix : add log on matching service
1 parent ddb1752 commit 3758582

File tree

2 files changed

+11
-2
lines changed
  • matching-service

2 files changed

+11
-2
lines changed

matching-service/matching-application/app-api/src/main/kotlin/com/grepp/quizy/matching/api/sse/SseSender.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.grepp.quizy.matching.domain.match.MatchingEventSender
55
import com.grepp.quizy.matching.domain.match.MatchingPoolManager
66
import com.grepp.quizy.matching.domain.match.PersonalMatchingSucceedEvent
77
import com.grepp.quizy.matching.domain.user.UserId
8+
import io.github.oshai.kotlinlogging.KotlinLogging
89
import org.springframework.stereotype.Component
910
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter
1011
import java.io.IOException
@@ -16,6 +17,8 @@ class SseSender(
1617
private val objectMapper: ObjectMapper
1718
) : MatchingEventSender {
1819

20+
private val log = KotlinLogging.logger {}
21+
1922
override fun send(event: PersonalMatchingSucceedEvent) {
2023
val emitter = emitterRepository.findById(event.userId) ?: return
2124

@@ -26,11 +29,12 @@ class SseSender(
2629
.name("MATCHING")
2730
.data(objectMapper.writeValueAsString(MatchingSucceed(event.gameRoomId)))
2831
)
29-
emitter.complete()
32+
log.info { "SSE event sent to ${event.userId}" }
3033
closeEmitter(event.userId)
34+
emitter.complete()
3135
} catch (e: IOException) {
3236
closeEmitter(event.userId)
33-
emitter.completeWithError(e)
37+
emitter.complete()
3438
}
3539
}
3640

matching-service/matching-infra/src/main/kotlin/com/grepp/quizy/matching/infra/match/pubsub/MatchingRedisSubscriber.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.grepp.quizy.matching.infra.match.pubsub
33
import com.fasterxml.jackson.databind.ObjectMapper
44
import com.grepp.quizy.matching.domain.match.MatchingEventSender
55
import com.grepp.quizy.matching.domain.match.PersonalMatchingSucceedEvent
6+
import io.github.oshai.kotlinlogging.KotlinLogging
67
import org.springframework.data.redis.connection.Message
78
import org.springframework.data.redis.connection.MessageListener
89
import org.springframework.stereotype.Component
@@ -13,15 +14,19 @@ class MatchingRedisSubscriber(
1314
private val objectMapper: ObjectMapper,
1415
) : MessageListener {
1516

17+
private val log = KotlinLogging.logger {}
18+
1619
override fun onMessage(message: Message, pattern: ByteArray?) {
1720
try {
1821
val event = objectMapper.readValue(
1922
message.body,
2023
PersonalMatchingSucceedEvent::class.java
2124
)
2225

26+
log.info { "Matching succeeded event: $event" }
2327
matchingEventSender.send(event)
2428
} catch (e: Exception) {
29+
log.error(e) { "Matching failed" }
2530
throw IllegalArgumentException("Failed to send event to Redis", e.cause)
2631
}
2732
}

0 commit comments

Comments
 (0)