-
Notifications
You must be signed in to change notification settings - Fork 0
#190 Registrere hendelser i cpa-repo #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
OleksandrChmyrNAV
merged 10 commits into
main
from
#190-registrere-hendelser-i-cpa-repo
May 23, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
815db9d
Lagt til requestId i ValidationRequest
OleksandrChmyrNAV 4af3bb9
Lagt til Hoplit configurasjon for cpa-repo
OleksandrChmyrNAV 6c23f8e
Lagt til registrering av MESSAGE_VALIDATED_AGAINST_CPA hendelse
OleksandrChmyrNAV 0c7f2c2
Fikset EndToEndTest
OleksandrChmyrNAV 74527d9
Registrert hendelse VALIDATION_AGAINST_CPA_FAILED
OleksandrChmyrNAV 4d8a312
Fjernet @OptIn markering fra klasser
OleksandrChmyrNAV b8b807e
Forbedret semantikken i logglinjer
OleksandrChmyrNAV 06987b2
Revert "Lagt til requestId i ValidationRequest"
OleksandrChmyrNAV 6611086
Tatt i bruk request ID fra GET parameter
OleksandrChmyrNAV 6ce15c2
Lagt til sender metadata for MESSAGE_VALIDATED_AGAINST_CPA hendelse
OleksandrChmyrNAV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
9 changes: 9 additions & 0 deletions
9
cpa-repo/src/main/kotlin/no/nav/emottak/cpa/configuration/Config.kt
This file contains hidden or 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,9 @@ | ||
| package no.nav.emottak.cpa.configuration | ||
|
|
||
| import no.nav.emottak.utils.config.EventLogging | ||
| import no.nav.emottak.utils.config.Kafka | ||
|
|
||
| data class Config( | ||
| val kafka: Kafka, | ||
| val eventLogging: EventLogging | ||
| ) |
14 changes: 14 additions & 0 deletions
14
cpa-repo/src/main/kotlin/no/nav/emottak/cpa/configuration/Configurator.kt
This file contains hidden or 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,14 @@ | ||
| package no.nav.emottak.cpa.configuration | ||
|
|
||
| import com.sksamuel.hoplite.ConfigLoader | ||
| import com.sksamuel.hoplite.addEnvironmentSource | ||
| import com.sksamuel.hoplite.addResourceSource | ||
|
|
||
| fun config() = ConfigLoader.builder() | ||
| .addEnvironmentSource() | ||
| .addResourceSource("/application-personal.conf", optional = true) | ||
| .addResourceSource("/kafka_common.conf") | ||
| .addResourceSource("/application.conf") | ||
| .withExplicitSealedTypes() | ||
| .build() | ||
| .loadConfigOrThrow<Config>() |
57 changes: 57 additions & 0 deletions
57
cpa-repo/src/main/kotlin/no/nav/emottak/cpa/util/EventRegistration.kt
This file contains hidden or 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,57 @@ | ||
| package no.nav.emottak.cpa.util | ||
|
|
||
| import no.nav.emottak.cpa.log | ||
| import no.nav.emottak.message.model.ValidationRequest | ||
| import no.nav.emottak.utils.common.parseOrGenerateUuid | ||
| import no.nav.emottak.utils.kafka.model.Event | ||
| import no.nav.emottak.utils.kafka.model.EventType | ||
| import no.nav.emottak.utils.kafka.service.EventLoggingService | ||
|
|
||
| interface EventRegistrationService { | ||
| suspend fun registerEvent( | ||
| eventType: EventType, | ||
| validationRequest: ValidationRequest, | ||
| requestId: String, | ||
| eventData: String = "{}" | ||
| ) | ||
| } | ||
|
|
||
| class EventRegistrationServiceImpl( | ||
| private val eventLoggingService: EventLoggingService | ||
| ) : EventRegistrationService { | ||
| override suspend fun registerEvent( | ||
| eventType: EventType, | ||
| validationRequest: ValidationRequest, | ||
| requestId: String, | ||
| eventData: String | ||
| ) { | ||
| log.debug("Registering event for requestId: $requestId") | ||
|
|
||
| try { | ||
| val event = Event( | ||
| eventType = eventType, | ||
| requestId = requestId.parseOrGenerateUuid(), | ||
| contentId = "", | ||
| messageId = validationRequest.messageId, | ||
| eventData = eventData | ||
| ) | ||
| log.debug("Registering event: {}", event) | ||
|
|
||
| eventLoggingService.logEvent(event) | ||
| log.debug("Event is registered successfully") | ||
| } catch (e: Exception) { | ||
| log.error("Error while registering event: ${e.message}", e) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| class EventRegistrationServiceFake : EventRegistrationService { | ||
| override suspend fun registerEvent( | ||
| eventType: EventType, | ||
| validationRequest: ValidationRequest, | ||
| requestId: String, | ||
| eventData: String | ||
| ) { | ||
| log.debug("Registering event $eventType for validationRequest: $validationRequest and eventData: $eventData") | ||
| } | ||
| } |
This file contains hidden or 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,4 @@ | ||
|
|
||
| kafka { | ||
| groupId = "cpa-repo" | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Synes denne ble fin og tydelig - vi ser raskt og enkelt at dette er en egen test implementasjon 👍