Skip to content

Commit e54870a

Browse files
authored
release: 1.3.1 (#259)
2 parents 2d47300 + 279b81d commit e54870a

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

โ€Žsrc/main/kotlin/org/gitanimals/guild/app/CreateGuildFacade.ktโ€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import org.gitanimals.core.filter.MDCFilter.Companion.TRACE_ID
44
import org.gitanimals.guild.app.request.CreateGuildRequest
55
import org.gitanimals.guild.app.response.GuildResponse
66
import org.gitanimals.guild.domain.GuildService
7+
import org.gitanimals.guild.domain.RandomGuildCache
78
import org.gitanimals.guild.domain.request.CreateLeaderRequest
89
import org.rooftop.netx.api.Orchestrator
910
import org.rooftop.netx.api.OrchestratorFactory
@@ -19,6 +20,7 @@ class CreateGuildFacade(
1920
private val guildService: GuildService,
2021
private val identityApi: IdentityApi,
2122
private val renderApi: RenderApi,
23+
private val randomGuildCache: RandomGuildCache,
2224
@Value("\${internal.secret}") internalSecret: String,
2325
orchestratorFactory: OrchestratorFactory,
2426
) {
@@ -40,7 +42,9 @@ class CreateGuildFacade(
4042
TRACE_ID to MDC.get(TRACE_ID),
4143
),
4244
timeoutMillis = 1.minutes.inWholeMilliseconds,
43-
).decodeResultOrThrow(GuildResponse::class)
45+
).decodeResultOrThrow(GuildResponse::class).also {
46+
randomGuildCache.updateForce()
47+
}
4448
}
4549

4650
init {

โ€Žsrc/main/kotlin/org/gitanimals/guild/domain/RandomGuildCache.ktโ€Ž

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package org.gitanimals.guild.domain
22

33
import org.springframework.data.domain.Page
44

5-
fun interface RandomGuildCache {
5+
interface RandomGuildCache {
66

77
fun get(key: Int, text: String, pageNumber: Int, filter: SearchFilter): Page<Guild>
8+
9+
fun updateForce()
810
}

โ€Žsrc/main/kotlin/org/gitanimals/guild/infra/InMemoryRandomGuildCache.ktโ€Ž

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.gitanimals.guild.domain.GuildService
55
import org.gitanimals.guild.domain.GuildService.Companion.PAGE_SIZE
66
import org.gitanimals.guild.domain.RandomGuildCache
77
import org.gitanimals.guild.domain.SearchFilter
8+
import org.slf4j.LoggerFactory
89
import org.springframework.context.event.ContextRefreshedEvent
910
import org.springframework.context.event.EventListener
1011
import org.springframework.data.domain.Page
@@ -18,6 +19,7 @@ class InMemoryRandomGuildCache(
1819
private val guildService: GuildService,
1920
) : RandomGuildCache {
2021

22+
private val logger = LoggerFactory.getLogger(this::class.simpleName)
2123
private lateinit var cache: Map<Int, List<Guild>>
2224

2325
override fun get(key: Int, text: String, pageNumber: Int, filter: SearchFilter): Page<Guild> {
@@ -55,6 +57,14 @@ class InMemoryRandomGuildCache(
5557
return PageImpl(filter.sort(response), Pageable.ofSize(PAGE_SIZE), guilds.size.toLong())
5658
}
5759

60+
override fun updateForce() {
61+
runCatching {
62+
updateRandom()
63+
}.onFailure {
64+
logger.error("Fail to force update in-memory guild cache", it)
65+
}
66+
}
67+
5868
@Scheduled(cron = ONCE_0AM_TIME)
5969
@EventListener(ContextRefreshedEvent::class)
6070
fun updateRandom() {

โ€Žsrc/test/kotlin/org/gitanimals/guild/app/CreateGuildFacadeTest.ktโ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import org.gitanimals.guild.app.request.CreateGuildRequest
1414
import org.gitanimals.guild.domain.GuildIcons
1515
import org.gitanimals.guild.domain.GuildRepository
1616
import org.gitanimals.guild.domain.GuildService
17+
import org.gitanimals.guild.infra.InMemoryRandomGuildCache
1718
import org.gitanimals.guild.supports.RedisContainer
1819
import org.gitanimals.guild.supports.GuildSagaCapture
1920
import org.gitanimals.guild.supports.MockApiConfiguration
@@ -37,6 +38,7 @@ import kotlin.time.Duration.Companion.seconds
3738
CreateGuildFacade::class,
3839
MockApiConfiguration::class,
3940
GuildService::class,
41+
InMemoryRandomGuildCache::class,
4042
]
4143
)
4244
@DisplayName("CreateGuildFacade ํด๋ž˜์Šค์˜")

0 commit comments

Comments
ย (0)