Skip to content

Commit 1b80a99

Browse files
Merge pull request #75 from leanix/feature/cid-3846-handle-multiple-pod-in-k8s
Feature/cid 3846 handle multiple pod in k8s
2 parents b73ea58 + a2fa76b commit 1b80a99

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/main/kotlin/net/leanix/githubagent/runners/PostStartupRunner.kt renamed to src/main/kotlin/net/leanix/githubagent/listener/ApplicationReadyListener.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.leanix.githubagent.runners
1+
package net.leanix.githubagent.listener
22

33
import net.leanix.githubagent.handler.BrokerStompSessionHandler
44
import net.leanix.githubagent.services.CachingService
@@ -9,26 +9,26 @@ import net.leanix.githubagent.services.SyncLogService
99
import net.leanix.githubagent.services.WebSocketService
1010
import net.leanix.githubagent.shared.APP_NAME_TOPIC
1111
import org.slf4j.LoggerFactory
12-
import org.springframework.boot.ApplicationArguments
13-
import org.springframework.boot.ApplicationRunner
12+
import org.springframework.boot.context.event.ApplicationReadyEvent
13+
import org.springframework.context.ApplicationListener
1414
import org.springframework.context.annotation.Profile
1515
import org.springframework.stereotype.Component
1616

1717
@Component
1818
@Profile("!test")
19-
class PostStartupRunner(
19+
class ApplicationReadyListener(
2020
private val githubAuthenticationService: GitHubAuthenticationService,
2121
private val webSocketService: WebSocketService,
2222
private val gitHubScanningService: GitHubScanningService,
2323
private val gitHubEnterpriseService: GitHubEnterpriseService,
2424
private val cachingService: CachingService,
2525
private val brokerStompSessionHandler: BrokerStompSessionHandler,
2626
private val syncLogService: SyncLogService
27-
) : ApplicationRunner {
27+
) : ApplicationListener<ApplicationReadyEvent> {
2828

29-
private val logger = LoggerFactory.getLogger(PostStartupRunner::class.java)
29+
private val logger = LoggerFactory.getLogger(this::class.java)
3030

31-
override fun run(args: ApplicationArguments?) {
31+
override fun onApplicationEvent(event: ApplicationReadyEvent) {
3232
webSocketService.initSession()
3333
if (!brokerStompSessionHandler.isConnected()) {
3434
logger.error("Stopping the application as the WebSocket connection could not be established.")

src/main/resources/application.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ resilience4j.retry:
1919
maxAttempts: 5
2020
enable-exponential-backoff: true
2121
exponential-backoff-multiplier: 2
22-
waitDuration: 1000
22+
waitDuration: 5s
2323
logging:
2424
level:
2525
org.springframework.web.socket.handler: DEBUG

src/test/kotlin/net/leanix/githubagent/runners/PostStartupRunnerTest.kt renamed to src/test/kotlin/net/leanix/githubagent/listener/ApplicationReadyListenerTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.leanix.githubagent.runners
1+
package net.leanix.githubagent.listener
22

33
import io.mockk.every
44
import io.mockk.mockk
@@ -15,14 +15,14 @@ import net.leanix.githubagent.shared.APP_NAME_TOPIC
1515
import org.junit.jupiter.api.BeforeEach
1616
import org.junit.jupiter.api.Test
1717

18-
class PostStartupRunnerTest {
18+
class ApplicationReadyListenerTest {
1919

2020
private lateinit var githubAuthenticationService: GitHubAuthenticationService
2121
private lateinit var webSocketService: WebSocketService
2222
private lateinit var gitHubScanningService: GitHubScanningService
2323
private lateinit var gitHubEnterpriseService: GitHubEnterpriseService
2424
private lateinit var cachingService: CachingService
25-
private lateinit var postStartupRunner: PostStartupRunner
25+
private lateinit var applicationListener: ApplicationReadyListener
2626
private lateinit var brokerStompSessionHandler: BrokerStompSessionHandler
2727
private lateinit var syncLogService: SyncLogService
2828

@@ -36,7 +36,7 @@ class PostStartupRunnerTest {
3636
brokerStompSessionHandler = mockk()
3737
syncLogService = mockk()
3838

39-
postStartupRunner = PostStartupRunner(
39+
applicationListener = ApplicationReadyListener(
4040
githubAuthenticationService,
4141
webSocketService,
4242
gitHubScanningService,
@@ -67,7 +67,7 @@ class PostStartupRunnerTest {
6767
gitHubAppName, mapOf(), listOf()
6868
)
6969

70-
postStartupRunner.run(mockk())
70+
applicationListener.onApplicationEvent(mockk())
7171

7272
verify { webSocketService.sendMessage(APP_NAME_TOPIC, gitHubAppName) }
7373
verify { syncLogService.sendFullScanStart(any()) }

0 commit comments

Comments
 (0)