reactor.core.publisher.Flux.getPrefetch()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(214)

本文整理了Java中reactor.core.publisher.Flux.getPrefetch()方法的一些代码示例,展示了Flux.getPrefetch()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flux.getPrefetch()方法的具体详情如下:
包路径:reactor.core.publisher.Flux
类名称:Flux
方法名:getPrefetch

Flux.getPrefetch介绍

[英]The prefetch configuration of the Flux
[中]助焊剂的预取配置

代码示例

代码示例来源:origin: reactor/reactor-core

@Test
public void defaultPrefetch() {
  assertThat(Flux.just(1, 2, 3)
          .flatMap(Flux::just)
          .getPrefetch()).isEqualTo(Queues.XS_BUFFER_SIZE);
}

代码示例来源:origin: reactor/reactor-core

@Test
public void getPrefetchAPI() {
  Flux<Integer> test = Flux.range(1, 10)
               .parallel()
               .ordered(Comparator.naturalOrder(), 123);
  assertThat(test.getPrefetch()).isEqualTo(123);
}

代码示例来源:origin: reactor/reactor-core

@Test
@SuppressWarnings("unchecked")
public void createZipWithPrefetchIterable() {
  List<Flux<Integer>> list = Arrays.asList(Flux.just(1), Flux.just(2));
  Flux<Integer> f = Flux.zip(list, 123, obj -> 0);
  assertThat(f.getPrefetch()).isEqualTo(123);
}

代码示例来源:origin: reactor/reactor-core

@Test
public void assertPrefetch() {
  assertThat(Flux.just("test", "test2", "test3")
          .hide()
          .take(2)
          .getPrefetch()).isEqualTo(Integer.MAX_VALUE);
}

代码示例来源:origin: reactor/reactor-core

@Test
@SuppressWarnings("unchecked")
public void createZipWithPrefetch() {
  Flux<Integer>[] list = new Flux[]{Flux.just(1), Flux.just(2)};
  Flux<Integer> f = Flux.zip(obj -> 0, 123, list);
  assertThat(f.getPrefetch()).isEqualTo(123);
}

代码示例来源:origin: reactor/reactor-core

@Test
public void noPrefetch() {
  assertThat(Flux.range(1, 10).limitRequest(3)
      .getPrefetch()).isZero();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void empty() {
  Flux<?> f = Flux.empty()
          .takeLast(1);
  assertThat(f.getPrefetch()).isEqualTo(Integer.MAX_VALUE);
  StepVerifier.create(f)
        .verifyComplete();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void reorderingAPIWithDefaultPrefetch() {
  Flux<Integer> test = Flux.mergeOrdered(Comparator.naturalOrder(),
      Flux.just(1, 3, 5, 7), Flux.just(2, 4, 6, 8, 10));
  assertThat(test.getPrefetch()).isEqualTo(Queues.SMALL_BUFFER_SIZE);
  StepVerifier.create(test)
        .expectNext(1, 2, 3, 4, 5, 6, 7, 8, 10)
        .verifyComplete();
}

代码示例来源:origin: reactor/reactor-core

PO applyStateScenario(OperatorScenario<I, PI, O, PO> scenario,
    boolean conditional,
    Flux<I> source) {
  PO f;
  if (conditional) {
    f = scenario.body()
          .andThen(this::conditional)
          .apply(withFluxSource(source));
  }
  else {
    f = scenario.body()
          .apply(withFluxSource(source));
    if ((f instanceof Flux || f instanceof ParallelFlux) && scenario.prefetch() != -1) {
      if (f instanceof Flux) {
        assertThat(Math.min(((Flux) f).getPrefetch(),
            Integer.MAX_VALUE)).isEqualTo(scenario.prefetch());
      }
      else {
        assertThat(Math.min(((ParallelFlux) f).getPrefetch(),
            Integer.MAX_VALUE)).isEqualTo(scenario.prefetch());
      }
    }
  }
  return f;
}

代码示例来源:origin: reactor/reactor-core

@Test
public void reorderingAPINaturalOrder() {
  Flux<Integer> test = Flux.mergeOrdered(Flux.just(1, 3, 5, 7), Flux.just(2, 4, 6, 8, 10));
  assertThat(test.getPrefetch()).isEqualTo(Queues.SMALL_BUFFER_SIZE);
  StepVerifier.create(test)
        .expectNext(1, 2, 3, 4, 5, 6, 7, 8, 10)
        .verifyComplete();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void fluxCreateBuffered() {
  AtomicInteger onDispose = new AtomicInteger();
  AtomicInteger onCancel = new AtomicInteger();
  Flux<String> created = Flux.create(s -> {
    s.onDispose(onDispose::getAndIncrement)
     .onCancel(onCancel::getAndIncrement);
    s.next("test1");
    s.next("test2");
    s.next("test3");
    s.complete();
  });
  assertThat(created.getPrefetch()).isEqualTo(-1);
  StepVerifier.create(created)
        .expectNext("test1", "test2", "test3")
        .verifyComplete();
  assertThat(onDispose.get()).isEqualTo(1);
  assertThat(onCancel.get()).isEqualTo(0);
}

代码示例来源:origin: reactor/reactor-core

if (source.getPrefetch() != -1 && scenario.prefetch() != -1) {
  assertThat(Math.min(source.getPrefetch(), Integer.MAX_VALUE)).isEqualTo(
      scenario.prefetch());

代码示例来源:origin: reactor/reactor-core

@Test
public void fluxCreateSerialized() {
  Flux<String> created = Flux.create(s -> {
    s.next("test1");
    s.next("test2");
    s.next("test3");
    s.complete();
  });
  assertThat(created.getPrefetch()).isEqualTo(-1);
  StepVerifier.create(created)
        .expectNext("test1", "test2", "test3")
        .verifyComplete();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void fluxCreateError() {
  Flux<String> created = Flux.create(s -> {
    s.next("test1");
    s.next("test2");
    s.next("test3");
    s.complete();
  }, FluxSink.OverflowStrategy.ERROR);
  assertThat(created.getPrefetch()).isEqualTo(-1);
  StepVerifier.create(created)
        .expectNext("test1", "test2", "test3")
        .verifyComplete();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void fluxCreateLatest() {
  Flux<String> created = Flux.create(s -> {
    s.next("test1");
    s.next("test2");
    s.next("test3");
    s.complete();
  }, FluxSink.OverflowStrategy.LATEST);
  assertThat(created.getPrefetch()).isEqualTo(-1);
  StepVerifier.create(created)
        .expectNext("test1", "test2", "test3")
        .verifyComplete();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void fluxCreateIgnore() {
  Flux<String> created = Flux.create(s -> {
    s.next("test1");
    s.next("test2");
    s.next("test3");
    s.complete();
  }, FluxSink.OverflowStrategy.IGNORE);
  assertThat(created.getPrefetch()).isEqualTo(-1);
  StepVerifier.create(created)
        .expectNext("test1", "test2", "test3")
        .verifyComplete();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void fluxPush() {
  Flux<String> created = Flux.push(s -> {
    s.next("test1");
    s.next("test2");
    s.next("test3");
    s.complete();
  });
  assertThat(created.getPrefetch()).isEqualTo(-1);
  StepVerifier.create(created)
        .expectNext("test1", "test2", "test3")
        .verifyComplete();
}

代码示例来源:origin: reactor/reactor-core

@Test
public void fluxCreateDrop() {
  Flux<String> created = Flux.create(s -> {
    s.next("test1");
    s.next("test2");
    s.next("test3");
    s.complete();
  }, FluxSink.OverflowStrategy.DROP);
  assertThat(created.getPrefetch()).isEqualTo(-1);
  StepVerifier.create(created)
        .expectNext("test1", "test2", "test3")
        .verifyComplete();
}

代码示例来源:origin: com.aol.cyclops/cyclops-reactor

/**
 * @return
 * @see reactor.core.publisher.Flux#getPrefetch()
 */
public long getPrefetch() {
  return boxed.getPrefetch();
}
/**

相关文章

Flux类方法