Skip to content

Commit

Permalink
CID-2940 Use 3 max attempts for retrying establishing connection
Browse files Browse the repository at this point in the history
  • Loading branch information
geoandri committed Dec 13, 2024
1 parent dd1ceb5 commit 948d288
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package net.leanix.githubagent.config
import com.fasterxml.jackson.databind.ObjectMapper
import io.github.resilience4j.retry.annotation.Retry
import net.leanix.githubagent.handler.BrokerStompSessionHandler
import net.leanix.githubagent.services.LeanIXAuthService
import net.leanix.githubagent.shared.GitHubAgentProperties.GITHUB_AGENT_VERSION
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
Expand All @@ -20,14 +21,16 @@ import org.springframework.web.socket.sockjs.client.WebSocketTransport
class WebSocketClientConfig(
private val brokerStompSessionHandler: BrokerStompSessionHandler,
private val objectMapper: ObjectMapper,
private val leanIXProperties: LeanIXProperties
private val leanIXAuthService: LeanIXAuthService,
private val leanIXProperties: LeanIXProperties,
private val gitHubEnterpriseProperties: GitHubEnterpriseProperties
) {
@Retry(name = "ws_init_session")
fun initSession(): StompSession {
val headers = WebSocketHttpHeaders()
val stompHeaders = StompHeaders()
stompHeaders["Authorization"] = "Bearer dummy"
stompHeaders["GitHub-Enterprise-URL"] = "https://url.com"
stompHeaders["Authorization"] = "Bearer ${leanIXAuthService.getBearerToken()}"
stompHeaders["GitHub-Enterprise-URL"] = gitHubEnterpriseProperties.baseUrl
stompHeaders["GitHub-Agent-Version"] = GITHUB_AGENT_VERSION
return stompClient().connectAsync(
leanIXProperties.wsBaseUrl,
Expand Down

0 comments on commit 948d288

Please sign in to comment.