-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
using newConfigAvailable in heartbeat to refresh AssignmentsCache
- Loading branch information
1 parent
54860fc
commit 2c35d5b
Showing
8 changed files
with
57 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/net/leanix/vsm/gitlab/broker/connector/domain/GitLabHeartbeatResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package net.leanix.vsm.gitlab.broker.connector.domain | ||
|
||
data class GitLabHeartbeatResponse( | ||
val status: String, | ||
val newConfigAvailable: Boolean | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 12 additions & 5 deletions
17
src/main/kotlin/net/leanix/vsm/gitlab/broker/connector/scheduler/HeartbeatScheduler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
package net.leanix.vsm.gitlab.broker.connector.scheduler | ||
|
||
import net.leanix.vsm.gitlab.broker.connector.adapter.feign.VsmClient | ||
import net.leanix.vsm.gitlab.broker.connector.applicaiton.AssignmentService | ||
import net.leanix.vsm.gitlab.broker.shared.cache.AssignmentsCache | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.scheduling.annotation.Scheduled | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class HeartbeatScheduler( | ||
private val vsmClient: VsmClient | ||
private val vsmClient: VsmClient, | ||
private val assignmentService: AssignmentService | ||
) { | ||
|
||
private val logger = LoggerFactory.getLogger(HeartbeatScheduler::class.java) | ||
|
||
@Scheduled(fixedRate = 300000) // 5 minute | ||
@Scheduled(fixedRateString = "\${leanix.heartbeat.interval}") | ||
fun heartbeat() { | ||
AssignmentsCache.getAll().values.forEach { assigment -> | ||
logger.info("Sending heartbeat for runId: ${assigment.runId}") | ||
vsmClient.heartbeat(assigment.runId.toString()) | ||
AssignmentsCache.getAll().values.forEach { assignment -> | ||
logger.info("Sending heartbeat for runId: ${assignment.runId}") | ||
vsmClient.heartbeat(assignment.runId.toString()) | ||
.takeIf { it.newConfigAvailable } | ||
?.also { | ||
assignmentService.getAssignments() | ||
// TODO: here we need to re-fetch everything for this config | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
leanix: | ||
base-url: http://localhost:8080 | ||
heartbeat: | ||
interval: ${LEANIX_HEARTBEAT_INTERVAL:300000} # 5 minutes | ||
vsm: | ||
events-broker: | ||
base-url: http://localhost:8080 | ||
auth: | ||
access-token-uri: ${leanix.base-url}/mtm/v1 | ||
|
||
server: | ||
port: 8082 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
leanix: | ||
base-url: http://localhost:${wiremock.server.port:6666}/services | ||
heartbeat: | ||
interval: ${LEANIX_HEARTBEAT_INTERVAL:300000} # 5 minutes | ||
vsm: | ||
connector: | ||
api-user-token: ${LEANIX_TECHNICAL_USER_TOKEN} | ||
events-broker: | ||
base-url: http://localhost:${wiremock.server.port:6666} | ||
# events-broker: | ||
# base-url: http://localhost:${wiremock.server.port:6666} | ||
auth: | ||
access-token-uri: ${leanix.base-url}/mtm/v1 |