Skip to content

Commit 8cacc38

Browse files
geiralundgtcno
andauthored
Added gRpc as an alternativ to getting inntekt [WIP] (#94)
* Added gRpc as an alternativ to getting inntekt [WIP] * Added method `getSpesifisertInntekt` to inntekt store - Retrieves inntekt and beregningsdato from db and converts it to Spesifisert inntekt as defined in dagpenger-events Todos - [ x ] Naiserator doesn't support more than one port binding from a pod. We may need two deploys - [ ] Create a small client wrapper which can serialize JSON to Inntekt as defined in dagpenger-events - [ ] Authentication navikt/dagpenger#406 Co-authored-by: Giao The Cung <[email protected]>
1 parent 56620da commit 8cacc38

File tree

109 files changed

+560
-120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+560
-120
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
**
33

44
# Except shadow jar
5-
!build/libs/*.jar
5+
!dp-inntekt-api/build/libs/dp-inntekt-api-all.jar

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
FROM navikt/java:11
1+
FROM navikt/java:13
22

3-
COPY build/libs/*-all.jar app.jar
3+
EXPOSE 50051
4+
5+
COPY dp-inntekt-api/build/libs/dp-inntekt-api-all.jar /app/app.jar

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pipeline {
5656
reportName: 'Test coverage'
5757
]
5858

59-
junit 'build/test-results/test/*.xml'
59+
junit '**/build/test-results/test/*.xml'
6060
}
6161
}
6262
}

build.gradle.kts

Lines changed: 60 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -2,148 +2,93 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
22
import org.gradle.api.tasks.testing.logging.TestLogEvent
33

44
plugins {
5-
application
65
kotlin("jvm") version Kotlin.version
76
id(Spotless.spotless) version Spotless.version
8-
id(Shadow.shadow) version Shadow.version
97
}
108

11-
buildscript {
12-
repositories {
13-
mavenCentral()
14-
}
15-
}
16-
17-
apply {
18-
plugin(Spotless.spotless)
19-
}
9+
val grpcVersion = "1.27.2"
2010

2111
repositories {
22-
mavenCentral()
2312
jcenter()
24-
maven("https://packages.confluent.io/maven/")
2513
maven("https://jitpack.io")
2614
}
2715

28-
application {
29-
applicationName = "dp-inntekt-api"
30-
mainClassName = "no.nav.dagpenger.inntekt.InntektApiKt"
31-
}
32-
33-
java {
34-
sourceCompatibility = JavaVersion.VERSION_11
35-
targetCompatibility = JavaVersion.VERSION_11
36-
}
37-
38-
dependencyLocking {
39-
lockAllConfigurations()
40-
}
41-
42-
configurations.all {
43-
resolutionStrategy.activateDependencyLocking()
44-
resolutionStrategy.preferProjectModules()
45-
resolutionStrategy.eachDependency { DependencyResolver.execute(this) }
46-
}
47-
48-
dependencies {
49-
implementation(kotlin("stdlib-jdk8"))
50-
51-
implementation(Dagpenger.Events)
16+
allprojects {
17+
group = "no.nav.dagpenger"
5218

53-
implementation(Ktor.server)
54-
implementation(Ktor.serverNetty)
55-
implementation(Ktor.auth)
56-
implementation(Ktor.authJwt)
57-
implementation(Ktor.micrometerMetrics)
58-
implementation(Dagpenger.Biblioteker.ktorUtils)
59-
implementation(Micrometer.prometheusRegistry)
19+
apply(plugin = "org.jetbrains.kotlin.jvm")
20+
apply(plugin = Spotless.spotless)
6021

61-
implementation(Moshi.moshi)
62-
implementation(Moshi.moshiAdapters)
63-
implementation(Moshi.moshiKotlin)
64-
implementation(Moshi.moshiKtor)
22+
dependencies {
23+
implementation(kotlin("stdlib-jdk8"))
6524

66-
implementation(Dagpenger.Streams)
67-
implementation(Kafka.clients)
25+
// ulid
26+
implementation(Ulid.ulid)
6827

69-
implementation(Kotlin.Logging.kotlinLogging)
70-
71-
implementation(Fuel.fuel)
72-
implementation(Fuel.fuelMoshi)
73-
implementation(Fuel.library("coroutines"))
28+
testImplementation(kotlin("test"))
29+
testImplementation(Junit5.api)
30+
testRuntimeOnly(Junit5.engine)
31+
testImplementation(KoTest.assertions)
32+
testImplementation(KoTest.runner)
33+
}
7434

75-
implementation(Log4j2.api)
76-
implementation(Log4j2.core)
77-
implementation(Log4j2.slf4j)
78-
implementation(Log4j2.Logstash.logstashLayout)
35+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
36+
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
37+
}
7938

80-
implementation(Ulid.ulid)
39+
java {
40+
sourceCompatibility = JavaVersion.VERSION_1_8
41+
targetCompatibility = JavaVersion.VERSION_1_8
42+
}
8143

82-
implementation(Dagpenger.Biblioteker.stsKlient)
44+
tasks.withType<Wrapper> {
45+
gradleVersion = "6.3"
46+
}
8347

84-
implementation(Database.Flyway)
85-
implementation(Database.HikariCP)
86-
implementation(Database.Postgres)
87-
implementation(Database.Kotlinquery)
88-
implementation(Konfig.konfig)
89-
implementation(Database.VaultJdbc) {
90-
exclude(module = "slf4j-simple")
91-
exclude(module = "slf4j-api")
48+
spotless {
49+
kotlin {
50+
targetExclude("**/generated/**") // ignore generated gRpc stuff
51+
ktlint()
52+
}
53+
kotlinGradle {
54+
target("*.gradle.kts", "buildSrc/**/*.kt*")
55+
ktlint()
56+
}
9257
}
9358

94-
implementation(Prometheus.common)
95-
implementation(Prometheus.hotspot)
96-
implementation(Prometheus.log4j2)
97-
98-
implementation(Bekk.nocommons)
99-
100-
implementation(Kotlinx.bimap)
101-
102-
testImplementation(kotlin("test"))
103-
testImplementation(Ktor.ktorTest)
104-
testImplementation(Junit5.api)
105-
testImplementation(Junit5.params)
106-
testRuntimeOnly(Junit5.engine)
107-
testImplementation(Wiremock.standalone)
108-
testImplementation(KoTest.assertions)
109-
testImplementation(KoTest.runner)
110-
testImplementation(KoTest.property)
111-
testImplementation(TestContainers.postgresql)
112-
testImplementation(TestContainers.kafka)
113-
testImplementation(Mockk.mockk)
114-
testImplementation(JsonAssert.jsonassert)
115-
}
59+
tasks.withType<Test> {
60+
useJUnitPlatform()
61+
testLogging {
62+
showExceptions = true
63+
showStackTraces = true
64+
exceptionFormat = TestExceptionFormat.FULL
65+
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
66+
}
67+
}
11668

117-
spotless {
118-
kotlin {
119-
ktlint()
69+
tasks.named("compileKotlin") {
70+
dependsOn("spotlessApply", "spotlessKotlinCheck")
12071
}
121-
kotlinGradle {
122-
target("*.gradle.kts", "buildSrc/**/*.kt*")
123-
ktlint()
72+
73+
tasks.named("jar") {
74+
dependsOn("test")
12475
}
12576
}
12677

127-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { kotlinOptions.jvmTarget = "1.8" }
78+
subprojects {
79+
apply(plugin = "org.jetbrains.kotlin.jvm")
12880

129-
tasks.withType<Test> {
130-
useJUnitPlatform()
131-
testLogging {
132-
showExceptions = true
133-
showStackTraces = true
134-
exceptionFormat = TestExceptionFormat.FULL
135-
events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
81+
repositories {
82+
jcenter()
83+
maven("https://jitpack.io")
13684
}
137-
}
13885

139-
tasks.withType<Wrapper> {
140-
gradleVersion = "6.0.1"
141-
}
86+
dependencies {
87+
implementation(kotlin("stdlib-jdk8"))
14288

143-
tasks.named("shadowJar") {
144-
dependsOn("test")
145-
}
146-
147-
tasks.named("compileKotlin") {
148-
dependsOn("spotlessKotlinCheck")
89+
testImplementation(kotlin("test"))
90+
testImplementation(Junit5.api)
91+
testRuntimeOnly(Junit5.engine)
92+
testImplementation(Mockk.mockk)
93+
}
14994
}

dp-inntekt-api/build.gradle.kts

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
plugins {
2+
application
3+
id(Shadow.shadow).version("5.2.0")
4+
}
5+
6+
repositories {
7+
maven("https://packages.confluent.io/maven/")
8+
}
9+
10+
application {
11+
applicationName = "dp-inntekt-api"
12+
mainClassName = "no.nav.dagpenger.inntekt.InntektApiKt"
13+
}
14+
15+
val grpcVersion = "1.29.0"
16+
17+
dependencies {
18+
implementation(project(":dp-inntekt-grpc"))
19+
20+
implementation(Dagpenger.Events)
21+
22+
implementation(Ktor.server)
23+
implementation(Ktor.serverNetty)
24+
implementation(Ktor.auth)
25+
implementation(Ktor.authJwt)
26+
implementation(Ktor.micrometerMetrics)
27+
implementation(Dagpenger.Biblioteker.ktorUtils)
28+
implementation(Micrometer.prometheusRegistry)
29+
30+
implementation(Moshi.moshi)
31+
implementation(Moshi.moshiAdapters)
32+
implementation(Moshi.moshiKotlin)
33+
implementation(Moshi.moshiKtor)
34+
35+
implementation(Dagpenger.Streams)
36+
implementation(Kafka.clients)
37+
38+
implementation(Kotlin.Logging.kotlinLogging)
39+
40+
implementation(Fuel.fuel)
41+
implementation(Fuel.fuelMoshi)
42+
implementation(Fuel.library("coroutines"))
43+
44+
implementation(Log4j2.api)
45+
implementation(Log4j2.core)
46+
implementation(Log4j2.slf4j)
47+
implementation(Log4j2.Logstash.logstashLayout)
48+
49+
implementation(Ulid.ulid)
50+
51+
implementation(Dagpenger.Biblioteker.stsKlient)
52+
53+
implementation(Database.Flyway)
54+
implementation(Database.HikariCP)
55+
implementation(Database.Postgres)
56+
implementation(Database.Kotlinquery)
57+
implementation(Konfig.konfig)
58+
implementation(Database.VaultJdbc) {
59+
exclude(module = "slf4j-simple")
60+
exclude(module = "slf4j-api")
61+
}
62+
63+
implementation(Prometheus.common)
64+
implementation(Prometheus.hotspot)
65+
implementation(Prometheus.log4j2)
66+
67+
implementation(Bekk.nocommons)
68+
69+
implementation(Kotlinx.bimap)
70+
71+
// grpc
72+
testImplementation("io.grpc:grpc-testing:$grpcVersion")
73+
runtimeOnly("io.grpc:grpc-netty-shaded:$grpcVersion")
74+
75+
testImplementation(kotlin("test"))
76+
testImplementation(Ktor.ktorTest)
77+
testImplementation(Junit5.api)
78+
testImplementation(Junit5.params)
79+
testRuntimeOnly(Junit5.engine)
80+
testRuntimeOnly(Junit5.vintageEngine)
81+
testImplementation(Wiremock.standalone)
82+
testImplementation(KoTest.assertions)
83+
testImplementation(KoTest.runner)
84+
testImplementation(KoTest.property)
85+
testImplementation(TestContainers.postgresql)
86+
testImplementation(TestContainers.kafka)
87+
testImplementation(Mockk.mockk)
88+
testImplementation(JsonAssert.jsonassert)
89+
}
90+
91+
dependencyLocking {
92+
lockAllConfigurations()
93+
}
94+
95+
configurations.all {
96+
resolutionStrategy.activateDependencyLocking()
97+
resolutionStrategy.preferProjectModules()
98+
resolutionStrategy.eachDependency { DependencyResolver.execute(this) }
99+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/main/kotlin/no/nav/dagpenger/inntekt/InntektApi.kt renamed to dp-inntekt-api/src/main/kotlin/no/nav/dagpenger/inntekt/InntektApi.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import java.net.URI
3434
import java.net.URL
3535
import java.util.concurrent.TimeUnit
3636
import kotlin.concurrent.fixedRateTimer
37+
import kotlinx.coroutines.launch
3738
import kotlinx.coroutines.runBlocking
3839
import mu.KotlinLogging
3940
import no.nav.dagpenger.inntekt.db.IllegalInntektIdException
@@ -46,6 +47,7 @@ import no.nav.dagpenger.inntekt.inntektskomponenten.v1.InntektskomponentClient
4647
import no.nav.dagpenger.inntekt.inntektskomponenten.v1.InntektskomponentHttpClient
4748
import no.nav.dagpenger.inntekt.inntektskomponenten.v1.InntektskomponentenHttpClientException
4849
import no.nav.dagpenger.inntekt.oppslag.OppslagClient
50+
import no.nav.dagpenger.inntekt.rpc.InntektGrpcServer
4951
import no.nav.dagpenger.inntekt.subsumsjonbrukt.KafkaSubsumsjonBruktDataConsumer
5052
import no.nav.dagpenger.inntekt.subsumsjonbrukt.Vaktmester
5153
import no.nav.dagpenger.inntekt.v1.InntektNotAuthorizedException
@@ -84,6 +86,13 @@ fun main() = runBlocking {
8486
listen()
8587
}
8688

89+
val gRpcServer = InntektGrpcServer(port = 50051, inntektStore = postgresInntektStore)
90+
91+
launch {
92+
gRpcServer.start()
93+
gRpcServer.blockUntilShutdown()
94+
}
95+
8796
val vaktmester = Vaktmester(dataSource)
8897

8998
fixedRateTimer(

0 commit comments

Comments
 (0)