當前位置: 首頁>>代碼示例>>Java>>正文


Java Flux.map方法代碼示例

本文整理匯總了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()));
	}
}
 
開發者ID:viniciusccarvalho,項目名稱:spring-cloud-sockets,代碼行數:17,代碼來源:DispatcherHandler.java

示例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);
	}
}
 
開發者ID:viniciusccarvalho,項目名稱:spring-cloud-sockets,代碼行數:20,代碼來源:DispatcherHandler.java

示例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);
}
 
開發者ID:viniciusccarvalho,項目名稱:spring-cloud-sockets,代碼行數:15,代碼來源:DispatchHandlerTests.java

示例4: manyToMany

import reactor.core.publisher.Flux; //導入方法依賴的package包/類
@Override
public Flux<Message> manyToMany(Flux<Message> request) {
    return request.map(this::maybeExplode);
}
 
開發者ID:salesforce,項目名稱:reactive-grpc,代碼行數:5,代碼來源:TckService.java

示例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);
}
 
開發者ID:viniciusccarvalho,項目名稱:spring-cloud-sockets,代碼行數:5,代碼來源:DispatchHandlerTests.java

示例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();
}
 
開發者ID:mp911de,項目名稱:reactive-spring,代碼行數:10,代碼來源:Step4Transformations.java


注:本文中的reactor.core.publisher.Flux.map方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。