Java Code Examples for reactor.core.publisher.Mono#flux()
The following examples show how to use
reactor.core.publisher.Mono#flux() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReactorGrpcPublisherManyToOneHalfFusedVerificationTest.java From reactive-grpc with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Publisher<Message> createPublisher(long elements) { ReactorTckGrpc.ReactorTckStub stub = ReactorTckGrpc.newReactorStub(channel); Flux<Message> request = Flux.range(0, (int)elements).map(this::toMessage); Mono<Message> publisher = stub.manyToOne(request.hide()); return publisher.flux(); }
Example 2
Source File: ReactorGrpcPublisherManyToOneHalfFusedVerificationTest.java From reactive-grpc with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Publisher<Message> createFailedPublisher() { ReactorTckGrpc.ReactorTckStub stub = ReactorTckGrpc.newReactorStub(channel); Flux<Message> request = Flux.just(toMessage(TckService.KABOOM)); Mono<Message> publisher = stub.manyToOne(request.hide()); return publisher.flux(); }
Example 3
Source File: ReactorGrpcPublisherManyToOneVerificationTest.java From reactive-grpc with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Publisher<Message> createPublisher(long elements) { ReactorTckGrpc.ReactorTckStub stub = ReactorTckGrpc.newReactorStub(channel); Flux<Message> request = Flux.range(0, (int)elements).map(this::toMessage); Mono<Message> publisher = stub.manyToOne(request.hide()).hide(); return publisher.flux(); }
Example 4
Source File: ReactorGrpcPublisherManyToOneVerificationTest.java From reactive-grpc with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Publisher<Message> createFailedPublisher() { ReactorTckGrpc.ReactorTckStub stub = ReactorTckGrpc.newReactorStub(channel); Flux<Message> request = Flux.just(toMessage(TckService.KABOOM)); Mono<Message> publisher = stub.manyToOne(request.hide()).hide(); return publisher.flux(); }
Example 5
Source File: ReactorGrpcPublisherOneToOneVerificationTest.java From reactive-grpc with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Publisher<Message> createPublisher(long elements) { ReactorTckGrpc.ReactorTckStub stub = ReactorTckGrpc.newReactorStub(channel); Mono<Message> request = Mono.just(toMessage((int) elements)); Mono<Message> publisher = stub.oneToOne(request); return publisher.flux(); }
Example 6
Source File: ReactorGrpcPublisherOneToOneVerificationTest.java From reactive-grpc with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Publisher<Message> createFailedPublisher() { ReactorTckGrpc.ReactorTckStub stub = ReactorTckGrpc.newReactorStub(channel); Mono<Message> request = Mono.just(toMessage(TckService.KABOOM)); Mono<Message> publisher = stub.oneToOne(request); return publisher.flux(); }
Example 7
Source File: ReactorGrpcPublisherManyToOneFusedVerificationTest.java From reactive-grpc with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Publisher<Message> createPublisher(long elements) { ReactorTckGrpc.ReactorTckStub stub = ReactorTckGrpc.newReactorStub(channel); Flux<Message> request = Flux.range(0, (int)elements).map(this::toMessage); Mono<Message> publisher = stub.manyToOne(request); return publisher.flux(); }
Example 8
Source File: ReactorGrpcPublisherManyToOneFusedVerificationTest.java From reactive-grpc with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Publisher<Message> createFailedPublisher() { ReactorTckGrpc.ReactorTckStub stub = ReactorTckGrpc.newReactorStub(channel); Flux<Message> request = Flux.just(toMessage(TckService.KABOOM)); Mono<Message> publisher = stub.manyToOne(request); return publisher.flux(); }
Example 9
Source File: ReactiveTargetResolver.java From promregator with Apache License 2.0 | 4 votes |
private Flux<IntermediateTarget> resolveOrg(IntermediateTarget it) { /* NB: Now we have to consider three cases: * Case 1: both orgName and orgRegex is empty => select all orgs * Case 2: orgName is null, but orgRegex is filled => filter all orgs with the regex * Case 3: orgName is filled, but orgRegex is null => select a single org * In cases 1 and 2, we need the list of all orgs on the platform. */ if (it.getConfigTarget().getOrgRegex() == null && it.getConfigTarget().getOrgName() != null) { // Case 3: we have the orgName, but we also need its id Mono<IntermediateTarget> itMono = this.cfAccessor.retrieveOrgId(it.getConfigTarget().getOrgName()) .map(ListOrganizationsResponse::getResources) .flatMap(resList -> { if (resList == null || resList.isEmpty()) { return Mono.empty(); } return Mono.just(resList.get(0)); }) .map(res -> { it.setResolvedOrgName(res.getEntity().getName()); it.setResolvedOrgId(res.getMetadata().getId()); return it; }) .doOnError(e -> log.warn(String.format("Error on retrieving org id for org '%s'", it.getConfigTarget().getOrgName()), e)) .onErrorResume(__ -> Mono.empty()); return itMono.flux(); } // Case 1 & 2: Get all orgs from the platform Mono<ListOrganizationsResponse> responseMono = this.cfAccessor.retrieveAllOrgIds(); Flux<OrganizationResource> orgResFlux = responseMono.map(ListOrganizationsResponse::getResources) .flatMapMany(Flux::fromIterable); if (it.getConfigTarget().getOrgRegex() != null) { // Case 2 final Pattern filterPattern = Pattern.compile(it.getConfigTarget().getOrgRegex(), Pattern.CASE_INSENSITIVE); orgResFlux = orgResFlux.filter(orgRes -> { Matcher m = filterPattern.matcher(orgRes.getEntity().getName()); return m.matches(); }); } return orgResFlux.map(orgRes -> { IntermediateTarget itnew = new IntermediateTarget(it); itnew.setResolvedOrgId(orgRes.getMetadata().getId()); itnew.setResolvedOrgName(orgRes.getEntity().getName()); return itnew; }); }
Example 10
Source File: ReactiveTargetResolver.java From promregator with Apache License 2.0 | 4 votes |
private Flux<IntermediateTarget> resolveSpace(IntermediateTarget it) { /* NB: Now we have to consider three cases: * Case 1: both spaceName and spaceRegex is empty => select all spaces (within the org) * Case 2: spaceName is null, but spaceRegex is filled => filter all spaces with the regex * Case 3: spaceName is filled, but spaceRegex is null => select a single space * In cases 1 and 2, we need the list of all spaces in the org. */ if (it.getConfigTarget().getSpaceRegex() == null && it.getConfigTarget().getSpaceName() != null) { // Case 3: we have the spaceName, but we also need its id Mono<IntermediateTarget> itMono = this.cfAccessor.retrieveSpaceId(it.getResolvedOrgId(), it.getConfigTarget().getSpaceName()) .map(ListSpacesResponse::getResources) .flatMap(resList -> { if (resList == null || resList.isEmpty()) { return Mono.empty(); } return Mono.just(resList.get(0)); }) .map(res -> { it.setResolvedSpaceName(res.getEntity().getName()); it.setResolvedSpaceId(res.getMetadata().getId()); return it; }).doOnError(e -> log.warn(String.format("Error on retrieving space id for org '%s' and space '%s'", it.getResolvedOrgName(), it.getConfigTarget().getSpaceName()), e)) .onErrorResume(__ -> Mono.empty()); return itMono.flux(); } // Case 1 & 2: Get all spaces in the current org Mono<ListSpacesResponse> responseMono = this.cfAccessor.retrieveSpaceIdsInOrg(it.getResolvedOrgId()); Flux<SpaceResource> spaceResFlux = responseMono.map(ListSpacesResponse::getResources) .flatMapMany(Flux::fromIterable); if (it.getConfigTarget().getSpaceRegex() != null) { // Case 2 final Pattern filterPattern = Pattern.compile(it.getConfigTarget().getSpaceRegex(), Pattern.CASE_INSENSITIVE); spaceResFlux = spaceResFlux.filter(spaceRes -> { Matcher m = filterPattern.matcher(spaceRes.getEntity().getName()); return m.matches(); }); } return spaceResFlux.map(spaceRes -> { IntermediateTarget itnew = new IntermediateTarget(it); itnew.setResolvedSpaceId(spaceRes.getMetadata().getId()); itnew.setResolvedSpaceName(spaceRes.getEntity().getName()); return itnew; }); }
Example 11
Source File: ReactiveTargetResolver.java From promregator with Apache License 2.0 | 4 votes |
private Flux<IntermediateTarget> resolveApplication(IntermediateTarget it) { /* NB: Now we have to consider three cases: * Case 1: both applicationName and applicationRegex is empty => select all applications (in the space) * Case 2: applicationName is null, but applicationRegex is filled => filter all applications with the regex * Case 3: applicationName is filled, but applicationRegex is null => select a single application * In cases 1 and 2, we need the list of all applications in the space. */ if (it.getConfigTarget().getApplicationRegex() == null && it.getConfigTarget().getApplicationName() != null) { // Case 3: we have the applicationName, but we also need its id String appNameToSearchFor = it.getConfigTarget().getApplicationName().toLowerCase(Locale.ENGLISH); Mono<IntermediateTarget> itMono = this.cfAccessor.retrieveAllApplicationIdsInSpace(it.getResolvedOrgId(), it.getResolvedSpaceId()) .map(ListApplicationsResponse::getResources) .flatMapMany(Flux::fromIterable) .filter(appResource -> appNameToSearchFor.equals(appResource.getEntity().getName().toLowerCase(Locale.ENGLISH))) .single() .doOnError(e -> { if (e instanceof NoSuchElementException) { logEmptyTarget.warn(String.format("Application id could not be found for org '%s', space '%s' and application '%s'. Check your configuration of targets; skipping it for now; this message may be muted by setting the log level of the emitting logger accordingly!", it.getResolvedOrgName(), it.getResolvedSpaceName(), it.getConfigTarget().getApplicationName())); } }) .onErrorResume(e -> Mono.empty()) .filter( res -> this.isApplicationInScrapableState(res.getEntity().getState())) .map(res -> { it.setResolvedApplicationName(res.getEntity().getName()); it.setResolvedApplicationId(res.getMetadata().getId()); return it; }).doOnError(e -> log.warn(String.format("Error on retrieving application id for org '%s', space '%s' and application '%s'", it.getResolvedOrgName(), it.getResolvedSpaceName(), it.getConfigTarget().getApplicationName()), e) ) .onErrorResume(__ -> Mono.empty()); return itMono.flux(); } // Case 1 & 2: Get all applications in the current space Mono<ListApplicationsResponse> responseMono = this.cfAccessor.retrieveAllApplicationIdsInSpace(it.getResolvedOrgId(), it.getResolvedSpaceId()); Flux<ApplicationResource> appResFlux = responseMono.map(ListApplicationsResponse::getResources) .flatMapMany(Flux::fromIterable) .doOnError(e -> log.warn(String.format("Error on retrieving list of applications in org '%s' and space '%s'", it.getResolvedOrgName(), it.getResolvedSpaceName()), e)) .onErrorResume(__ -> Flux.empty()); if (it.getConfigTarget().getApplicationRegex() != null) { // Case 2 final Pattern filterPattern = Pattern.compile(it.getConfigTarget().getApplicationRegex(), Pattern.CASE_INSENSITIVE); appResFlux = appResFlux.filter(appRes -> { Matcher m = filterPattern.matcher(appRes.getEntity().getName()); return m.matches(); }); } Flux<ApplicationResource> scrapableFlux = appResFlux.filter(appRes -> this.isApplicationInScrapableState(appRes.getEntity().getState())); return scrapableFlux.map(appRes -> { IntermediateTarget itnew = new IntermediateTarget(it); itnew.setResolvedApplicationId(appRes.getMetadata().getId()); itnew.setResolvedApplicationName(appRes.getEntity().getName()); return itnew; }); }