本文整理汇总了Java中reactor.core.publisher.Flux.map方法的典型用法代码示例。如果您正苦于以下问题:Java Flux.map方法的具体用法?Java Flux.map怎么用?Java Flux.map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reactor.core.publisher.Flux
的用法示例。
在下文中一共展示了Flux.map方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requestStream
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Flux<Payload> requestStream(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()));
Flux result = (Flux)handler.invoke(handler.getInfo().buildInvocationArguments(converted, null));
return result.map(o ->
new PayloadImpl(converter.write(o))
);
} catch (Exception e){
return Flux.error(new ApplicationException("No path found for " + metadata.get("PATH").asText()));
}
}
示例2: requestChannel
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Flux<Payload> requestChannel(Publisher<Payload> payloads) {
Flux<Payload> flux = Flux.from(payloads);
Payload headerPayload = flux.take(1).next().block();
JsonNode metadata = readConnectionMetadata(headerPayload.getMetadataUtf8());
try{
MethodHandler handler = handlerFor(metadata);
Converter converter = converterFor(MimeType.valueOf(metadata.get("MIME_TYPE").textValue()));
Flux converted = flux.repeat().map(payload -> {
return converter.read(ServiceUtils.toByteArray(payload.getData()), getActualType( handler.getInfo().getParameterType()));
});
Flux result = (Flux)handler.invoke(handler.getInfo().buildInvocationArguments(converted, null));
return result.map(o ->
new PayloadImpl(converter.write(o))
);
}catch (Exception e){
return Flux.error(e);
}
}
示例3: requestStream
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Test
public void requestStream() throws Exception {
Flux<Integer> from = Flux.range(0,10);
Flux<io.rsocket.Payload> payloadFlux = from.map(integer -> {
return new PayloadImpl(converter.write(integer), getMetadataBytes(MimeType.valueOf("application/json") ,"/requestStream"));
});
Flux<io.rsocket.Payload> invocationResult = this.handler.requestChannel(payloadFlux);
List<Integer> results = invocationResult.map(payload -> {
return (Integer)converter.read(payload.getDataUtf8().getBytes(),Integer.class);
}).take(10).collectList().block();
assertThat(results).size().isEqualTo(10);
}
示例4: manyToMany
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Flux<Message> manyToMany(Flux<Message> request) {
return request.map(this::maybeExplode);
}
示例5: adder
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@RequestStreamMapping(value = "/requestStream", mimeType = "application/json")
public Flux<Integer> adder(Flux<Integer> input){
return input.map(integer -> integer+1);
}
示例6: fluxShouldMapValueToUpperCaseHelloWorld
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Test
public void fluxShouldMapValueToUpperCaseHelloWorld() {
Flux<String> flux = Flux.just("Mike", "Gustavo");
flux = flux.map(String::toUpperCase);
StepVerifier.create(flux).expectNext("MIKE", "GUSTAVO").verifyComplete();
}