Skip to content

Commit

Permalink
Fix the problem of blocking while site while getting link details (#93)
Browse files Browse the repository at this point in the history
This PR wraps the blocking operation in blocking threads instead of non-blocking threads, which might block all requests from outside.

/kind bug

Fixes #92 

```release-note
修复无法通过当前站点地址获取站点信息的问题
```
  • Loading branch information
JohnNiang authored Sep 5, 2024
1 parent 01bdf3b commit 2c2c32b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/run/halo/links/LinkRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.RequiredArgsConstructor;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
import run.halo.app.extension.ListOptions;
import run.halo.app.extension.ListResult;
import run.halo.app.extension.ReactiveExtensionClient;
Expand Down Expand Up @@ -104,7 +105,9 @@ private Mono<ServerResponse> getLinkDetail(ServerRequest request) {
final var url = request.queryParam("url")
.filter(PathUtils::isAbsoluteUri)
.orElseThrow(() -> new ServerWebInputException("Invalid url."));
return Mono.just(LinkRequest.getLinkDetail(url))
return Mono.fromSupplier(() -> LinkRequest.getLinkDetail(url))
.subscribeOn(Schedulers.boundedElastic())
.publishOn(Schedulers.parallel())
.flatMap(dto -> ServerResponse.ok().bodyValue(dto));
}

Expand Down

0 comments on commit 2c2c32b

Please sign in to comment.