本文整理汇总了Java中reactor.core.publisher.Mono.map方法的典型用法代码示例。如果您正苦于以下问题:Java Mono.map方法的具体用法?Java Mono.map怎么用?Java Mono.map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reactor.core.publisher.Mono
的用法示例。
在下文中一共展示了Mono.map方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requestResponse
import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<Payload> requestResponse(Payload payload) {
JsonNode metadata = readConnectionMetadata(payload.getMetadataUtf8());
try {
MethodHandler handler = handlerFor(metadata);
Converter converter = converterFor(MimeType.valueOf(metadata.get("MIME_TYPE").textValue()));
Object converted = converter.read(ServiceUtils.toByteArray(payload.getData()), getActualType(handler.getInfo().getParameterType()));
Object result = handler.invoke(handler.getInfo().buildInvocationArguments(converted, null));
Mono monoResult = monoOF(result);
return monoResult.map(o -> {
byte[] data = converter.write(o);
return new PayloadImpl(data);
});
}catch (Exception e){
return Mono.error(e);
}
}
示例2: getTransaction
import reactor.core.publisher.Mono; //导入方法依赖的package包/类
public Mono<SignedBigchaindbTransaction> getTransaction(final String transactionId) {
ClientRequest<Void> request =
ClientRequest.GET("http://{hostAddress}:{port}/transactions/{id}", hostAddress, port, transactionId)
.build();
Mono<ObjectNode> monoObject = webClient.exchange(request).then(response -> response.body(toMono(ObjectNode.class)));
return monoObject.map(object -> new SignedBigchaindbTransactionImpl(object));
}
示例3: getActiveProfiles
import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<ProfileInfo> getActiveProfiles(Mono<Empty> request) {
return request.map(e -> {
ProfileInfo.Builder builder = ProfileInfo.newBuilder();
String[] activeProfiles = DefaultProfileUtil.getActiveProfiles(env);
if (activeProfiles != null) {
builder.addAllActiveProfiles(Arrays.asList(activeProfiles));
}
String ribbonEnv = getRibbonEnv(activeProfiles);
if (ribbonEnv != null) {
builder.setRibbonEnv(ribbonEnv);
}
return builder.build();
});
}
示例4: getHealth
import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<Health> getHealth(Mono<Empty> request) {
Map<String, HealthIndicator> healthIndicatorProtos = new HashMap<>();
this.healthIndicators.forEach((key, indicator) -> healthIndicatorProtos.put(key, healthIndicatorToHealthIndicatorProto(indicator)));
return request.map( e ->
Health.newBuilder()
.setStatus(Status.valueOf(this.healthIndicator.health().getStatus().toString()))
.putAllHealthIndicators(healthIndicatorProtos)
.build()
);
}
示例5: getEnv
import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<Environment> getEnv(Mono<Empty> request) {
return request.map( empty -> {
ObjectMapper mapper = new ObjectMapper();
try {
return Environment.newBuilder()
.setValue(mapper.writeValueAsString(endpoint.invoke()))
.build();
} catch (JsonProcessingException e) {
throw Status.INTERNAL.withCause(e).asRuntimeException();
}
});
}
示例6: isAuthenticated
import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<StringValue> isAuthenticated(Mono<Empty> request) {
return request.map(e -> {
log.debug("gRPC request to check if the current user is authenticated");
Authentication principal = SecurityContextHolder.getContext().getAuthentication();
StringValue.Builder builder = StringValue.newBuilder();
if (principal != null) {
builder.setValue(principal.getName());
}
return builder.build();
});
}
示例7: postMessage
import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<Empty> postMessage(Mono<ChatProto.ChatMessage> request) {
return request.map(this::broadcast);
}
示例8: oneToOne
import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<Message> oneToOne(Mono<Message> request) {
return request.map(this::maybeExplode);
}
示例9: getConfigurationProperties
import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Override
public Mono<ConfigurationPropertiesReport> getConfigurationProperties(Mono<Empty> request) {
return request.map(e -> mapToConfigurationPropertiesReport(endpoint.invoke()));
}
示例10: monoShouldMapValueToUpperCaseHelloWorld
import reactor.core.publisher.Mono; //导入方法依赖的package包/类
@Test
public void monoShouldMapValueToUpperCaseHelloWorld() {
Mono<String> mono = Mono.just("Heisenberg");
mono = mono.map(String::toUpperCase);
StepVerifier.create(mono).expectNext("HEISENBERG").verifyComplete();
}