本文整理匯總了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();
}