當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。