Skip to content

Commit

Permalink
optimize: call plugin sync method by async thead pool. (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
chivehao authored Jun 21, 2023
1 parent b72f860 commit 7047b84
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.util.Assert;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
import run.ikaros.api.core.subject.Subject;
import run.ikaros.api.core.subject.SubjectSynchronizer;
import run.ikaros.api.exception.NoAvailableSubjectPlatformSynchronizerException;
Expand Down Expand Up @@ -67,7 +68,8 @@ private Mono<Subject> syncBySubjectSynchronizer(@Nullable Long subjectId,
"No found available subject platform synchronizer for platform-id: "
+ platform.name() + "-" + platformId)))
.map(subjectSynchronizes -> subjectSynchronizes.get(0))
.flatMap(subjectSynchronizer -> Mono.justOrEmpty(subjectSynchronizer.pull(platformId)))
.flatMap(subjectSynchronizer -> Mono.fromCallable(() ->
subjectSynchronizer.pull(platformId)))
.onErrorResume(Exception.class, e -> {
String msg =
"Operate not available, platform api domain can not access "
Expand All @@ -85,7 +87,8 @@ private Mono<Subject> syncBySubjectSynchronizer(@Nullable Long subjectId,
.then(Mono.defer(() -> subjectService.findById(subjectId))))
.doOnSuccess(subject -> applicationContext.publishEvent(
new SubjectCoverImageDownloadAndUpdateEvent(this,
subject.getId(), subject.getCover())));
subject.getId(), subject.getCover())))
.subscribeOn(Schedulers.boundedElastic());
}


Expand Down

0 comments on commit 7047b84

Please sign in to comment.