当前位置: 首页>>代码示例>>Java>>正文


Java Flux.error方法代码示例

本文整理汇总了Java中reactor.core.publisher.Flux.error方法的典型用法代码示例。如果您正苦于以下问题:Java Flux.error方法的具体用法?Java Flux.error怎么用?Java Flux.error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reactor.core.publisher.Flux的用法示例。


在下文中一共展示了Flux.error方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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包/类
@Override
public Flux<Payload> requestStream(Payload payload) {
  try {
    ByteBuf metadata = Unpooled.wrappedBuffer(payload.getMetadata());
    int namespaceId = ProteusMetadata.namespaceId(metadata);
    int serviceId = ProteusMetadata.serviceId(metadata);

    ProteusService proteusService = getService(namespaceId, serviceId);

    if (proteusService == null) {
      return Flux.error(new ServiceNotFound(namespaceId, serviceId));
    }

    return proteusService.requestStream(payload);

  } catch (Throwable t) {
    return Flux.error(t);
  }
}
 
开发者ID:netifi,项目名称:proteus-java,代码行数:20,代码来源:RequestHandlingRSocket.java

示例4: requestChannel

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Flux<Payload> requestChannel(Publisher<Payload> payloads) {
  return new SwitchTransform<>(payloads, (payload, flux) -> {
    ByteBuf metadata = Unpooled.wrappedBuffer(payload.getMetadata());
    int namespaceId = ProteusMetadata.namespaceId(metadata);
    int serviceId = ProteusMetadata.serviceId(metadata);

    ProteusService proteusService = getService(namespaceId, serviceId);

    if (proteusService == null) {
      return Flux.error(new ServiceNotFound(namespaceId, serviceId));
    }

    return proteusService.requestChannel(payload, flux);
  });
}
 
开发者ID:netifi,项目名称:proteus-java,代码行数:17,代码来源:RequestHandlingRSocket.java

示例5: oneToMany

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
/**
 * Implements a unary -> stream call as {@link Mono} -> {@link Flux}, where the server responds with a
 * stream of messages.
 */
public static <TRequest, TResponse> Flux<TResponse> oneToMany(
        Mono<TRequest> rxRequest,
        BiConsumer<TRequest, StreamObserver<TResponse>> delegate) {
    try {
        ReactorConsumerStreamObserver<TRequest, TResponse> consumerStreamObserver = new ReactorConsumerStreamObserver<>();
        rxRequest.subscribe(request -> delegate.accept(request, consumerStreamObserver));
        return ((Flux<TResponse>) consumerStreamObserver.getRxConsumer())
                .transform(Operators.lift(new SubscribeOnlyOnceLifter<TResponse>()));
    } catch (Throwable throwable) {
        return Flux.error(throwable);
    }
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:17,代码来源:ClientCalls.java

示例6: manyToMany

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
/**
 * Implements a bidirectional stream -> stream call as {@link Flux} -> {@link Flux}, where both the client
 * and the server independently stream to each other.
 */
public static <TRequest, TResponse> Flux<TResponse> manyToMany(
        Flux<TRequest> rxRequest,
        Function<StreamObserver<TResponse>, StreamObserver<TRequest>> delegate) {
    try {
        ReactorProducerConsumerStreamObserver<TRequest, TResponse> consumerStreamObserver = new ReactorProducerConsumerStreamObserver<>(rxRequest);
        delegate.apply(new CancellableStreamObserver<>(consumerStreamObserver, consumerStreamObserver::cancel));
        consumerStreamObserver.rxSubscribe();
        return ((Flux<TResponse>) consumerStreamObserver.getRxConsumer())
                .transform(Operators.lift(new SubscribeOnlyOnceLifter<TResponse>()));
    } catch (Throwable throwable) {
        return Flux.error(throwable);
    }
}
 
开发者ID:salesforce,项目名称:reactive-grpc,代码行数:18,代码来源:ClientCalls.java

示例7: errorFlux

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
Flux<String> errorFlux() {
    return Flux.error(new NullPointerException("Boo!"));
}
 
开发者ID:aliaksei-lithium,项目名称:spring5demo,代码行数:4,代码来源:FluxSampleTest.java

示例8: requestChannel

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Flux<Payload> requestChannel(Payload payload, Flux<Payload> publisher) {
  return Flux.error(new UnsupportedOperationException("Request-Channel not implemented."));
}
 
开发者ID:netifi,项目名称:proteus-java,代码行数:5,代码来源:AbstractProteusService.java


注:本文中的reactor.core.publisher.Flux.error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。