Skip to content

Commit

Permalink
- Attempting to remove H2 (for now).
Browse files Browse the repository at this point in the history
- Removed pool and repository config (no effect).
- Stack trace no longer cut at 480 chars (for now).
- Enabled debug mode to check bean resolution.

#deploy-levende-arbeidsforhold-ansettelse
  • Loading branch information
rfc3092 committed Oct 22, 2024
1 parent de47295 commit e82542d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 36 deletions.
2 changes: 0 additions & 2 deletions apps/levende-arbeidsforhold-ansettelse/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ dependencies {
runtimeOnly 'org.postgresql:postgresql'
runtimeOnly 'org.postgresql:r2dbc-postgresql'

implementation "io.r2dbc:r2dbc-h2"

implementation "io.micrometer:micrometer-registry-prometheus"
implementation "org.springdoc:springdoc-openapi-starter-webflux-ui:$versions.springdoc"
implementation "io.swagger.core.v3:swagger-annotations-jakarta:$versions.swagger"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.nav.testnav.levendearbeidsforholdansettelse.config;

import io.r2dbc.h2.H2ConnectionFactory;
//import io.r2dbc.h2.H2ConnectionFactory;
import io.r2dbc.spi.ConnectionFactory;
import lombok.RequiredArgsConstructor;
import org.flywaydb.core.Flyway;
Expand All @@ -14,25 +14,25 @@
@Configuration
@Profile("dev")
@RequiredArgsConstructor
class DatabaseR2dbcConfiguration extends AbstractR2dbcConfiguration
class DatabaseR2dbcConfiguration /*extends AbstractR2dbcConfiguration*/
{

private final Environment env;

@Bean
@Primary
public ConnectionFactory connectionFactory() {
return H2ConnectionFactory.inMemory("testdb");
}

@Bean(initMethod = "migrate")
public Flyway flyway() {
return new Flyway(Flyway.configure()
.baselineOnMigrate(true)
.dataSource(
env.getRequiredProperty("spring.flyway.url"),
env.getRequiredProperty("spring.flyway.username"),
env.getRequiredProperty("spring.flyway.password"))
);
}
// private final Environment env;
//
// @Bean
// @Primary
// public ConnectionFactory connectionFactory() {
// return H2ConnectionFactory.inMemory("testdb");
// }
//
// @Bean(initMethod = "migrate")
// public Flyway flyway() {
// return new Flyway(Flyway.configure()
// .baselineOnMigrate(true)
// .dataSource(
// env.getRequiredProperty("spring.flyway.url"),
// env.getRequiredProperty("spring.flyway.username"),
// env.getRequiredProperty("spring.flyway.password"))
// );
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
spring:
flyway:
# InMemmory database
url: jdbc:h2:mem:testdb
username: sa
url: jdbc:postgresql://localhost:5432/testnav-levende-arbeidsforhold
user: postgres
username: ${spring.flyway.user}
password:
driverClassName: org.h2.Driver
sql:
init:
mode: always
data-locations: classpath:/db/dev/h2-default-config.sql
r2dbc:
url: r2dbc:postgresql://localhost:5432/testnav-levende-arbeidsforhold
username: postgres
password:
# sql:
# init:
# mode: always
# data-locations: classpath:/db/dev/h2-default-config.sql

# main:
# allow-bean-definition-overriding: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
debug: true

spring:
data:
r2dbc:
repositories:
enabled: true
r2dbc:
pool:
enabled: false
url: r2dbc:postgresql://${NAIS_DATABASE_TESTNAV_LEVENDE_ARBEIDSFORHOLD_TESTNAV_LEVENDE_ARBEIDSFORHOLD_HOST}:${NAIS_DATABASE_TESTNAV_LEVENDE_ARBEIDSFORHOLD_TESTNAV_LEVENDE_ARBEIDSFORHOLD_PORT}/${NAIS_DATABASE_TESTNAV_LEVENDE_ARBEIDSFORHOLD_TESTNAV_LEVENDE_ARBEIDSFORHOLD_DATABASE}?ssl=true&sslMode=${NAIS_DATABASE_TESTNAV_LEVENDE_ARBEIDSFORHOLD_TESTNAV_LEVENDE_ARBEIDSFORHOLD_SSLMODE}&sslKey=${NAIS_DATABASE_TESTNAV_LEVENDE_ARBEIDSFORHOLD_TESTNAV_LEVENDE_ARBEIDSFORHOLD_SSLKEY}&sslCert=${NAIS_DATABASE_TESTNAV_LEVENDE_ARBEIDSFORHOLD_TESTNAV_LEVENDE_ARBEIDSFORHOLD_SSLCERT}&sslRootCert=${NAIS_DATABASE_TESTNAV_LEVENDE_ARBEIDSFORHOLD_TESTNAV_LEVENDE_ARBEIDSFORHOLD_SSLROOTCERT}
username: ${NAIS_DATABASE_TESTNAV_LEVENDE_ARBEIDSFORHOLD_TESTNAV_LEVENDE_ARBEIDSFORHOLD_USERNAME}
password: ${NAIS_DATABASE_TESTNAV_LEVENDE_ARBEIDSFORHOLD_TESTNAV_LEVENDE_ARBEIDSFORHOLD_PASSWORD}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public byte[] encode(ILoggingEvent event) {
for (StackTraceElement element : exception.getThrowable().getStackTrace()) {
pw.println("\tat " + element);
}
var stackTrace = sw.toString().substring(0, 480); //Limit the stack trace to 480 characters
var stackTrace = sw.toString()/*.substring(0, 480)*/; //Limit the stack trace to 480 characters
generator.writeStringField("stack_trace", stackTrace);
}
}
Expand Down

0 comments on commit e82542d

Please sign in to comment.