本文整理了Java中reactor.core.publisher.Mono.flux()
方法的一些代码示例,展示了Mono.flux()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mono.flux()
方法的具体详情如下:
包路径:reactor.core.publisher.Mono
类名称:Mono
方法名:flux
[英]Convert this Mono to a Flux
[中]把这个单声道转换成通量
代码示例来源:origin: spring-projects/spring-framework
encodeValue(value, mimeType, bufferFactory, elementType, hints, encoding)).flux();
return Flux.from(inputStream).collectList().map(list ->
encodeValue(list, mimeType, bufferFactory, listType, hints,
encoding)).flux();
});
代码示例来源:origin: requery/requery
@Override
public Flux<Person> apply(Person person) {
return data.insert(person).flux();
}
});
代码示例来源:origin: lettuce-io/lettuce-core
@Override
public Mono<Boolean> msetnx(Map<K, V> map) {
return pipeliningWithMap(map, kvMap -> RedisAdvancedClusterReactiveCommandsImpl.super.msetnx(kvMap).flux(),
booleanFlux -> booleanFlux).reduce((accu, next) -> accu && next);
}
代码示例来源:origin: lettuce-io/lettuce-core
@Override
public Mono<String> mset(Map<K, V> map) {
return pipeliningWithMap(map, kvMap -> RedisAdvancedClusterReactiveCommandsImpl.super.mset(kvMap).flux(),
booleanFlux -> booleanFlux).last();
}
代码示例来源:origin: reactor/reactor-core
@Override
@SuppressWarnings("unchecked")
protected Flux<I> sourceCallable(OperatorScenario<I, Flux<I>, O, Flux<O>> scenario) {
if(scenario.producerCount() == 0){
return (Flux<I>)Mono.fromRunnable(() -> {})
.flux();
}
return (Flux<I>)Mono.fromCallable(() -> scenario.producingMapper.apply(0))
.flux();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void monoFromFluxItselfMonoToFlux_fuseable() {
Mono<String> original = Mono.just("foo").map(v -> v + "bar");
Flux<String> firstConversion = original.flux();
Mono<String> secondConversion = Mono.from(firstConversion);
assertThat(original).isInstanceOf(Fuseable.class);
assertThat(secondConversion).isInstanceOf(Fuseable.class);
assertThat(secondConversion.block()).isEqualTo("foobar");
assertThat(secondConversion).as("conversions negated").isSameAs(original);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void monoFromFluxItselfMonoToFlux() {
Mono<String> original = Mono.just("foo").hide();
Flux<String> firstConversion = original.flux();
Mono<String> secondConversion = Mono.from(firstConversion);
assertThat(secondConversion.block()).isEqualTo("foo");
assertThat(secondConversion).as("conversions negated").isSameAs(original);
}
代码示例来源:origin: reactor/reactor-core
@Override
@SuppressWarnings("unchecked")
protected ParallelFlux<I> sourceCallable(OperatorScenario<I, ParallelFlux<I>, O, ParallelFlux<O>> scenario) {
if(scenario.producerCount() == 0){
return (ParallelFlux<I>)Mono.fromRunnable(() -> {})
.flux()
.parallel(4);
}
return (ParallelFlux<I>) Mono.fromCallable(() -> scenario.producingMapper.apply(0))
.flux()
.parallel(4);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void monoFromFluxItselfMonoToFlux_scalarCallableNotOptimized() {
Mono<String> original = Mono.just("foo");
Flux<String> firstConversion = original.flux();
Mono<String> secondConversion = Mono.from(firstConversion);
assertThat(secondConversion.block()).isEqualTo("foo");
assertThat(secondConversion).as("conversions not negated but equivalent")
.isNotSameAs(original)
.hasSameClassAs(original);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void fluxJust() {
StepVerifier.create(Mono.just(1).flux())
.expectNext(1)
.verifyComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void collectListCallable() {
StepVerifier.create(Mono.fromCallable(() -> 1)
.flux()
.collectList())
.assertNext(d -> assertThat(d).containsExactly(1))
.verifyComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void collectMultiMapCallable() {
StepVerifier.create(Mono.fromCallable(() -> new Pojo("test", 1L))
.flux()
.collectMultimap(p -> p.id))
.assertNext(p -> assertThat(p).containsOnlyKeys(1L)
.containsValues(Arrays.asList(new Pojo(
"test",
1L))))
.verifyComplete();
}
}
代码示例来源:origin: reactor/reactor-core
@Test
public void normal3() {
StepVerifier.create(Mono.fromCallable(() -> 100)
.flux()
.last(-1))
.expectNext(100)
.verifyComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void singleFallbackCallable() {
StepVerifier.create(Mono.fromCallable(() -> 1)
.flux()
.single(2))
.expectNext(1)
.verifyComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void singleCallable() {
StepVerifier.create(Mono.fromCallable(() -> 1)
.flux()
.single())
.expectNext(1)
.verifyComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void singleEmptyFallbackCallable() {
StepVerifier.create(Mono.fromCallable(() -> 1)
.flux()
.singleOrEmpty())
.expectNext(1)
.verifyComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void callableReturnsNull3() {
StepVerifier.create(Mono.fromCallable(() -> null)
.flux()
.subscribeOn(Schedulers.single()), 1)
.verifyComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void collectMapCallable() {
StepVerifier.create(Mono.fromCallable(() -> new Pojo("test", 1L))
.flux()
.collectMap(p -> p.id))
.assertNext(p -> assertThat(p).containsOnlyKeys(1L)
.containsValues(new Pojo("test", 1L)))
.verifyComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void callableReturnsNull() {
AssertSubscriber<Integer> ts = AssertSubscriber.create();
Mono.<Integer>fromCallable(() -> null).log().flux()
.subscribe(ts);
ts.assertNoValues()
.assertNoError()
.assertComplete();
}
代码示例来源:origin: reactor/reactor-core
@Test
public void normal() {
StepVerifier.create(Mono.fromCallable(() -> 1)
.flux()
.subscribeOn(Schedulers.single()))
.expectNext(1)
.expectComplete()
.verify();
}
内容来源于网络,如有侵权,请联系作者删除!