当前位置: 首页>>代码示例>>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;未经允许,请勿转载。