Skip to content

Commit 7047b84

Browse files
authored
optimize: call plugin sync method by async thead pool. (#342)
1 parent b72f860 commit 7047b84

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

server/src/main/java/run/ikaros/server/core/subject/service/impl/SubjectSyncPlatformServiceImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.springframework.util.Assert;
1313
import reactor.core.publisher.Flux;
1414
import reactor.core.publisher.Mono;
15+
import reactor.core.scheduler.Schedulers;
1516
import run.ikaros.api.core.subject.Subject;
1617
import run.ikaros.api.core.subject.SubjectSynchronizer;
1718
import run.ikaros.api.exception.NoAvailableSubjectPlatformSynchronizerException;
@@ -67,7 +68,8 @@ private Mono<Subject> syncBySubjectSynchronizer(@Nullable Long subjectId,
6768
"No found available subject platform synchronizer for platform-id: "
6869
+ platform.name() + "-" + platformId)))
6970
.map(subjectSynchronizes -> subjectSynchronizes.get(0))
70-
.flatMap(subjectSynchronizer -> Mono.justOrEmpty(subjectSynchronizer.pull(platformId)))
71+
.flatMap(subjectSynchronizer -> Mono.fromCallable(() ->
72+
subjectSynchronizer.pull(platformId)))
7173
.onErrorResume(Exception.class, e -> {
7274
String msg =
7375
"Operate not available, platform api domain can not access "
@@ -85,7 +87,8 @@ private Mono<Subject> syncBySubjectSynchronizer(@Nullable Long subjectId,
8587
.then(Mono.defer(() -> subjectService.findById(subjectId))))
8688
.doOnSuccess(subject -> applicationContext.publishEvent(
8789
new SubjectCoverImageDownloadAndUpdateEvent(this,
88-
subject.getId(), subject.getCover())));
90+
subject.getId(), subject.getCover())))
91+
.subscribeOn(Schedulers.boundedElastic());
8992
}
9093

9194

0 commit comments

Comments
 (0)