-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This code diff introduces a significant change by migrating the appli…
…cation from a traditional Spring MVC architecture to a reactive Spring WebFlux architecture. This change is evident in the following modifications: **1. Reactive Dependencies:** - Removal of `spring-boot-starter-data-jpa` and addition of `spring-boot-starter-data-r2dbc` indicate a shift from blocking JPA to reactive R2DBC for database interactions. - Inclusion of `org.postgresql:r2dbc-postgresql` and `io.r2dbc:r2dbc-h2` provides drivers for reactive database connections. **2. Reactive Repositories:** - Repositories like `ParameterRepository`, `AnsettelseLoggRepository`, and `LoggRepository` now extend reactive interfaces like `ReactiveCrudRepository` and `ReactiveSortingRepository`. - Methods in these repositories now return reactive types like `Flux` and `Mono` instead of `List` and `Optional`. **3. Reactive Services:** - Service methods in `LoggService`, `ArbeidsforholdService`, `KodeverkService`, `AnsettelseLoggService`, and `ParameterService` are updated to return reactive types (`Flux`, `Mono`). - Usage of reactive operators like `flatMap`, `map`, and `collectList` is introduced for asynchronous data processing. **4. Reactive Controllers:** - Controllers like `ParameterController` and `LoggController` now return reactive types (`Flux`, `Mono`) from their endpoint methods. **5. Security Configuration:** - The `SecurityConfig` class is updated to use `EnableWebFluxSecurity` and `EnableReactiveMethodSecurity` annotations, indicating a shift to reactive security configurations. - The `springSecurityFilterChain` method now configures a `SecurityWebFilterChain` for reactive web requests. **6. Other Changes:** - Introduction of `NavHeaders` class for managing custom headers. - Update to OpenApiConfig to support reactive endpoints. - Removal of unused dependencies and code related to the previous Spring MVC architecture. **Impact:** This migration to a reactive architecture brings several benefits: - **Improved Performance and Scalability:** Reactive applications can handle more requests with fewer resources compared to traditional blocking applications. - **Non-Blocking Operations:** Asynchronous operations prevent threads from being blocked, leading to better resource utilization. - **Enhanced Responsiveness:** Reactive applications can respond to user requests faster, even under heavy load. **Considerations:** - Developers need to be familiar with reactive programming concepts and libraries like Reactor to work with this updated codebase. - Testing strategies need to be adapted for reactive components. - Existing code that interacts with the application might need adjustments to handle reactive types. This migration represents a significant architectural shift that can lead to a more performant and scalable application.
- Loading branch information
Showing
29 changed files
with
252 additions
and
189 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: 4 additions & 2 deletions
6
...rc/main/java/no/nav/testnav/levendearbeidsforholdansettelse/config/ApplicationConfig.java
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
39 changes: 39 additions & 0 deletions
39
...ava/no/nav/testnav/levendearbeidsforholdansettelse/config/DatabaseR2dbcConfiguration.java
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,39 @@ | ||
package no.nav.testnav.levendearbeidsforholdansettelse.config; | ||
|
||
import io.r2dbc.h2.H2ConnectionFactory; | ||
import io.r2dbc.spi.ConnectionFactory; | ||
import lombok.RequiredArgsConstructor; | ||
import org.flywaydb.core.Flyway; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration; | ||
import org.springframework.data.r2dbc.config.EnableR2dbcAuditing; | ||
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories; | ||
|
||
@Configuration | ||
@EnableR2dbcAuditing | ||
@EnableR2dbcRepositories | ||
@RequiredArgsConstructor | ||
class DatabaseR2dbcConfiguration extends AbstractR2dbcConfiguration { | ||
|
||
private final Environment env; | ||
|
||
@Bean | ||
@Profile("dev") | ||
public ConnectionFactory connectionFactory() { | ||
return H2ConnectionFactory.inMemory("testdb"); | ||
} | ||
|
||
@Bean(initMethod = "migrate") | ||
public Flyway flyway() { | ||
return new Flyway(Flyway.configure() | ||
.baselineOnMigrate(true) | ||
.dataSource( | ||
env.getRequiredProperty("spring.datasource.url"), | ||
env.getRequiredProperty("spring.datasource.username"), | ||
env.getRequiredProperty("spring.datasource.password")) | ||
); | ||
} | ||
} |
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
2 changes: 0 additions & 2 deletions
2
...src/main/java/no/nav/testnav/levendearbeidsforholdansettelse/consumers/AaregConsumer.java
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
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
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
Oops, something went wrong.