Merge pull request #1210 from echooymxq/master

Use the bounded elastic thread pool when subscribe.
pull/1215/head
Jim Fang 5 years ago committed by GitHub
commit 77d2ce8ef8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,6 +25,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient;
@ -51,7 +52,8 @@ public class NacosReactiveDiscoveryClient implements ReactiveDiscoveryClient {
@Override
public Flux<ServiceInstance> getInstances(String serviceId) {
return Mono.justOrEmpty(serviceId).flatMapMany(loadInstancesFromNacos());
return Mono.justOrEmpty(serviceId).flatMapMany(loadInstancesFromNacos())
.subscribeOn(Schedulers.boundedElastic());
}
private Function<String, Publisher<ServiceInstance>> loadInstancesFromNacos() {
@ -76,7 +78,7 @@ public class NacosReactiveDiscoveryClient implements ReactiveDiscoveryClient {
log.error("get services from nacos server fail,", e);
return Flux.empty();
}
});
}).subscribeOn(Schedulers.boundedElastic());
}
}

Loading…
Cancel
Save