|
@@ -6,21 +6,17 @@ import benchmark.repository.ReactiveFortuneRepository;
|
|
import benchmark.repository.ReactiveWorldRepository;
|
|
import benchmark.repository.ReactiveWorldRepository;
|
|
import io.micronaut.context.annotation.Requires;
|
|
import io.micronaut.context.annotation.Requires;
|
|
import io.micronaut.core.async.annotation.SingleResult;
|
|
import io.micronaut.core.async.annotation.SingleResult;
|
|
-import io.micronaut.http.HttpResponse;
|
|
|
|
import io.micronaut.http.annotation.Controller;
|
|
import io.micronaut.http.annotation.Controller;
|
|
import io.micronaut.http.annotation.Get;
|
|
import io.micronaut.http.annotation.Get;
|
|
import io.micronaut.http.annotation.QueryValue;
|
|
import io.micronaut.http.annotation.QueryValue;
|
|
import org.reactivestreams.Publisher;
|
|
import org.reactivestreams.Publisher;
|
|
import reactor.core.publisher.Flux;
|
|
import reactor.core.publisher.Flux;
|
|
import reactor.core.publisher.Mono;
|
|
import reactor.core.publisher.Mono;
|
|
-import views.fortunes;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Comparator;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
-import static java.util.Comparator.comparing;
|
|
|
|
-
|
|
|
|
@Requires(beans = {ReactiveWorldRepository.class, ReactiveFortuneRepository.class})
|
|
@Requires(beans = {ReactiveWorldRepository.class, ReactiveFortuneRepository.class})
|
|
@Controller
|
|
@Controller
|
|
public class ReactiveBenchmarkController extends AbstractBenchmarkController {
|
|
public class ReactiveBenchmarkController extends AbstractBenchmarkController {
|
|
@@ -61,15 +57,8 @@ public class ReactiveBenchmarkController extends AbstractBenchmarkController {
|
|
// https://github.com/TechEmpower/FrameworkBenchmarks/wiki/Project-Information-Framework-Tests-Overview#fortunes
|
|
// https://github.com/TechEmpower/FrameworkBenchmarks/wiki/Project-Information-Framework-Tests-Overview#fortunes
|
|
@Get(value = "/fortunes", produces = "text/html;charset=utf-8")
|
|
@Get(value = "/fortunes", produces = "text/html;charset=utf-8")
|
|
@SingleResult
|
|
@SingleResult
|
|
- public Mono<HttpResponse<String>> fortune() {
|
|
|
|
- return Mono.from(fortuneRepository.findAll()).map(fortuneList -> {
|
|
|
|
- List<Fortune> all = new ArrayList<>(fortuneList.size() + 1);
|
|
|
|
- all.add(new Fortune(0, "Additional fortune added at request time."));
|
|
|
|
- all.addAll(fortuneList);
|
|
|
|
- all.sort(comparing(Fortune::message));
|
|
|
|
- String body = fortunes.template(all).render().toString();
|
|
|
|
- return HttpResponse.ok(body).contentType("text/html;charset=utf-8");
|
|
|
|
- });
|
|
|
|
|
|
+ public Mono<List<Fortune>> fortune() {
|
|
|
|
+ return Mono.from(fortuneRepository.findAll()).map(this::prepareFortunes);
|
|
}
|
|
}
|
|
|
|
|
|
// https://github.com/TechEmpower/FrameworkBenchmarks/wiki/Project-Information-Framework-Tests-Overview#database-updates
|
|
// https://github.com/TechEmpower/FrameworkBenchmarks/wiki/Project-Information-Framework-Tests-Overview#database-updates
|