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

x33g5p2x  于2022-01-20 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(147)

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

Hooks.resetOnLastOperator介绍

[英]Reset global "subscriber" hook tracking
[中]重置全局“订户”挂钩跟踪

代码示例

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

@PreDestroy
public void cleanupHooks() {
  if (log.isTraceEnabled()) {
    log.trace("Cleaning up hooks");
  }
  Hooks.resetOnLastOperator(SLEUTH_TRACE_REACTOR_KEY);
  Schedulers.resetFactory();
}

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

@Test
public void onLastOperatorResetSpecific() {
  List<String> applied = new ArrayList<>(3);
  Function<? super Publisher<Object>, ? extends Publisher<Object>> hook1 = p -> {
    applied.add("h1");
    return p;
  };
  Function<? super Publisher<Object>, ? extends Publisher<Object>> hook2 = p -> {
    applied.add("h2");
    return p;
  };
  Hooks.onLastOperator("1", hook1);
  Hooks.onLastOperator(hook2);
  Hooks.onLastOperatorHook.apply(s -> {});
  assertThat(Hooks.getOnLastOperatorHooks()).hasSize(2);
  assertThat(applied).containsExactly("h1", "h2");
  applied.clear();
  Hooks.resetOnLastOperator("1");
  Hooks.onLastOperatorHook.apply(s -> {});
  assertThat(Hooks.getOnLastOperatorHooks()).hasSize(1);
  assertThat(applied).containsExactly("h2");
}

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

@Test
public void onLastOperatorClearByName() {
  Hooks.onLastOperator("some", p -> p);
  Hooks.onLastOperator("other", p -> p);
  assertThat(Hooks.onLastOperatorHook).isNotNull();
  assertThat(Hooks.getOnLastOperatorHooks()).hasSize(2);
  Hooks.resetOnLastOperator("some");
  assertThat(Hooks.onLastOperatorHook).isNotNull();
  assertThat(Hooks.getOnLastOperatorHooks())
      .hasSize(1)
      .containsOnlyKeys("other");
  Hooks.resetOnLastOperator("other");
  assertThat(Hooks.onLastOperatorHook).isNull();
  assertThat(Hooks.getOnLastOperatorHooks()).isEmpty();
}

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

@Test
public void onLastOperatorReset() {
  Hooks.onLastOperator("some", p -> p);
  assertThat(Hooks.onLastOperatorHook).isNotNull();
  assertThat(Hooks.getOnLastOperatorHooks()).hasSize(1);
  Hooks.resetOnLastOperator();
  assertThat(Hooks.onLastOperatorHook).isNull();
  assertThat(Hooks.getOnLastOperatorHooks()).isEmpty();
}

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

final void resetHooks() {
  Hooks.resetOnErrorDropped();
  Hooks.resetOnNextDropped();
  Hooks.resetOnEachOperator();
  Hooks.resetOnOperatorError();
  Hooks.resetOnLastOperator();
}

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

@Test
public void testOnLastPublisher() throws Exception {
  List<Publisher> l = new ArrayList<>();
  Hooks.onLastOperator(p -> {
    System.out.println(Scannable.from(p).parents().count());
    System.out.println(Scannable.from(p).stepName());
    l.add(p);
    return p;
  });
  StepVerifier.create(Flux.just(1, 2, 3)
              .map(m -> m)
              .takeUntilOther(Mono.never())
              .flatMap(d -> Mono.just(d).hide()))
        .expectNext(1, 2, 3)
        .verifyComplete();
  Hooks.resetOnLastOperator();
  assertThat(l).hasSize(5);
}

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

@Test
public void testOnLastPublisher() throws Exception {
  List<Publisher> l = new ArrayList<>();
  Hooks.onLastOperator(p -> {
    System.out.println(Scannable.from(p).parents().count());
    System.out.println(Scannable.from(p).stepName());
    l.add(p);
    return p;
  });
  StepVerifier.create(Flux.just(1, 2, 3)
              .map(m -> m)
              .takeUntilOther(Mono.never())
              .flatMap(d -> Mono.just(d).hide()))
        .expectNext(1, 2, 3)
        .verifyComplete();
  Hooks.resetOnLastOperator();
  assertThat(l).hasSize(5);
}

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

@After
public void resetAllHooks() {
  Hooks.resetOnOperatorError();
  Hooks.resetOnNextDropped();
  Hooks.resetOnErrorDropped();
  Hooks.resetOnOperatorDebug();
  Hooks.resetOnEachOperator();
  Hooks.resetOnLastOperator();
}

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

@After
public void resetAllHooks() {
  Hooks.resetOnOperatorError();
  Hooks.resetOnNextDropped();
  Hooks.resetOnErrorDropped();
  Hooks.resetOnOperatorDebug();
  Hooks.resetOnEachOperator();
  Hooks.resetOnLastOperator();
}

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

.verifyComplete();
Hooks.resetOnLastOperator();

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

.verifyComplete();
Hooks.resetOnLastOperator();

代码示例来源:origin: org.springframework.security/spring-security-test

@Override
public void afterTestMethod(TestContext testContext) throws Exception {
  Hooks.resetOnLastOperator(CONTEXT_OPERATOR_KEY);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public void afterTestMethod(TestContext testContext) throws Exception {
  Hooks.resetOnLastOperator(CONTEXT_OPERATOR_KEY);
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-sleuth-core

@PreDestroy
public void cleanupHooks() {
  if (log.isTraceEnabled()) {
    log.trace("Cleaning up hooks");
  }
  Hooks.resetOnLastOperator(SLEUTH_TRACE_REACTOR_KEY);
  Schedulers.resetFactory();
}

相关文章