本文整理汇总了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()));
}
}
示例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包/类
@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);
}
}
示例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);
});
}
示例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);
}
}
示例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);
}
}
示例7: errorFlux
import reactor.core.publisher.Flux; //导入方法依赖的package包/类
Flux<String> errorFlux() {
return Flux.error(new NullPointerException("Boo!"));
}
示例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."));
}