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

x33g5p2x  于2022-01-24 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(165)

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

Mono.onLastAssembly介绍

[英]To be used by custom operators: invokes assembly Hooks pointcut given a Mono, potentially returning a new Mono. This is for example useful to activate cross-cutting concerns at assembly time, eg. a generalized #checkpoint().
[中]供自定义运算符使用:调用给定Mono的程序集钩子切入点,可能返回新的Mono。例如,这对于在组装时激活横切关注点非常有用,例如,广义的#检查点()。

代码示例

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

@Override
public final void subscribe(Subscriber<? super T> actual) {
  onLastAssembly(this).subscribe(Operators.toCoreSubscriber(actual));
}

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

/**
 * Subscribe to this {@link Mono} and <strong>block</strong> until a next signal is
 * received, the Mono completes empty or a timeout expires. Returns an {@link Optional}
 * for the first two cases, which can be used to replace the empty case with an
 * Exception via {@link Optional#orElseThrow(Supplier)}.
 * In case the Mono itself errors, the original exception is thrown (wrapped in a
 * {@link RuntimeException} if it was a checked exception).
 * If the provided timeout expires, a {@link RuntimeException} is thrown.
 *
 * <p>
 * <img class="marble" src="doc-files/marbles/blockOptionalWithTimeout.svg" alt="">
 * <p>
 * Note that each block() will trigger a new subscription: in other words, the result
 * might miss signal from hot publishers.
 *
 * @param timeout maximum time period to wait for before raising a {@link RuntimeException}
 *
 * @return T the result
 */
public Optional<T> blockOptional(Duration timeout) {
  BlockingOptionalMonoSubscriber<T> subscriber = new BlockingOptionalMonoSubscriber<>();
  onLastAssembly(this).subscribe(Operators.toCoreSubscriber(subscriber));
  return subscriber.blockingGet(timeout.toMillis(), TimeUnit.MILLISECONDS);
}

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

/**
 * Subscribe to this {@link Mono} and <strong>block indefinitely</strong> until a next signal is
 * received or the Mono completes empty. Returns an {@link Optional}, which can be used
 * to replace the empty case with an Exception via {@link Optional#orElseThrow(Supplier)}.
 * In case the Mono itself errors, the original exception is thrown (wrapped in a
 * {@link RuntimeException} if it was a checked exception).
 *
 * <p>
 * <img class="marble" src="doc-files/marbles/blockOptional.svg" alt="">
 * <p>
 * Note that each blockOptional() will trigger a new subscription: in other words, the result
 * might miss signal from hot publishers.
 *
 * @return T the result
 */
public Optional<T> blockOptional() {
  BlockingOptionalMonoSubscriber<T> subscriber = new BlockingOptionalMonoSubscriber<>();
  onLastAssembly(this).subscribe(Operators.toCoreSubscriber(subscriber));
  return subscriber.blockingGet();
}

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

/**
 * Subscribe to this {@link Mono} and <strong>block</strong> until a next signal is
 * received or a timeout expires. Returns that value, or null if the Mono completes
 * empty. In case the Mono errors, the original exception is thrown (wrapped in a
 * {@link RuntimeException} if it was a checked exception).
 * If the provided timeout expires,a {@link RuntimeException} is thrown.
 *
 * <p>
 * <img class="marble" src="doc-files/marbles/blockWithTimeout.svg" alt="">
 * <p>
 * Note that each block() will trigger a new subscription: in other words, the result
 * might miss signal from hot publishers.
 *
 * @param timeout maximum time period to wait for before raising a {@link RuntimeException}
 *
 * @return T the result
 */
@Nullable
public T block(Duration timeout) {
  BlockingMonoSubscriber<T> subscriber = new BlockingMonoSubscriber<>();
  onLastAssembly(this).subscribe(Operators.toCoreSubscriber(subscriber));
  return subscriber.blockingGet(timeout.toMillis(), TimeUnit.MILLISECONDS);
}

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

/**
 * Subscribe to this {@link Mono} and <strong>block indefinitely</strong> until a next signal is
 * received. Returns that value, or null if the Mono completes empty. In case the Mono
 * errors, the original exception is thrown (wrapped in a {@link RuntimeException} if
 * it was a checked exception).
 *
 * <p>
 * <img class="marble" src="doc-files/marbles/block.svg" alt="">
 * <p>
 * Note that each block() will trigger a new subscription: in other words, the result
 * might miss signal from hot publishers.
 *
 * @return T the result
 */
@Nullable
public T block() {
  BlockingMonoSubscriber<T> subscriber = new BlockingMonoSubscriber<>();
  onLastAssembly(this).subscribe(Operators.toCoreSubscriber(subscriber));
  return subscriber.blockingGet();
}

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

@Override
public final void subscribe(Subscriber<? super T> actual) {
  onLastAssembly(this).subscribe(Operators.toCoreSubscriber(actual));
}

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

/**
 * Subscribe to this {@link Mono} and <strong>block</strong> until a next signal is
 * received, the Mono completes empty or a timeout expires. Returns an {@link Optional}
 * for the first two cases, which can be used to replace the empty case with an
 * Exception via {@link Optional#orElseThrow(Supplier)}.
 * In case the Mono itself errors, the original exception is thrown (wrapped in a
 * {@link RuntimeException} if it was a checked exception).
 * If the provided timeout expires, a {@link RuntimeException} is thrown.
 *
 * <p>
 * <img class="marble" src="doc-files/marbles/blockOptionalWithTimeout.svg" alt="">
 * <p>
 * Note that each block() will trigger a new subscription: in other words, the result
 * might miss signal from hot publishers.
 *
 * @param timeout maximum time period to wait for before raising a {@link RuntimeException}
 *
 * @return T the result
 */
public Optional<T> blockOptional(Duration timeout) {
  BlockingOptionalMonoSubscriber<T> subscriber = new BlockingOptionalMonoSubscriber<>();
  onLastAssembly(this).subscribe(Operators.toCoreSubscriber(subscriber));
  return subscriber.blockingGet(timeout.toMillis(), TimeUnit.MILLISECONDS);
}

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

/**
 * Subscribe to this {@link Mono} and <strong>block</strong> until a next signal is
 * received or a timeout expires. Returns that value, or null if the Mono completes
 * empty. In case the Mono errors, the original exception is thrown (wrapped in a
 * {@link RuntimeException} if it was a checked exception).
 * If the provided timeout expires,a {@link RuntimeException} is thrown.
 *
 * <p>
 * <img class="marble" src="doc-files/marbles/blockWithTimeout.svg" alt="">
 * <p>
 * Note that each block() will trigger a new subscription: in other words, the result
 * might miss signal from hot publishers.
 *
 * @param timeout maximum time period to wait for before raising a {@link RuntimeException}
 *
 * @return T the result
 */
@Nullable
public T block(Duration timeout) {
  BlockingMonoSubscriber<T> subscriber = new BlockingMonoSubscriber<>();
  onLastAssembly(this).subscribe(Operators.toCoreSubscriber(subscriber));
  return subscriber.blockingGet(timeout.toMillis(), TimeUnit.MILLISECONDS);
}

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

/**
 * Subscribe to this {@link Mono} and <strong>block indefinitely</strong> until a next signal is
 * received or the Mono completes empty. Returns an {@link Optional}, which can be used
 * to replace the empty case with an Exception via {@link Optional#orElseThrow(Supplier)}.
 * In case the Mono itself errors, the original exception is thrown (wrapped in a
 * {@link RuntimeException} if it was a checked exception).
 *
 * <p>
 * <img class="marble" src="doc-files/marbles/blockOptional.svg" alt="">
 * <p>
 * Note that each blockOptional() will trigger a new subscription: in other words, the result
 * might miss signal from hot publishers.
 *
 * @return T the result
 */
public Optional<T> blockOptional() {
  BlockingOptionalMonoSubscriber<T> subscriber = new BlockingOptionalMonoSubscriber<>();
  onLastAssembly(this).subscribe(Operators.toCoreSubscriber(subscriber));
  return subscriber.blockingGet();
}

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

/**
 * Subscribe to this {@link Mono} and <strong>block indefinitely</strong> until a next signal is
 * received. Returns that value, or null if the Mono completes empty. In case the Mono
 * errors, the original exception is thrown (wrapped in a {@link RuntimeException} if
 * it was a checked exception).
 *
 * <p>
 * <img class="marble" src="doc-files/marbles/block.svg" alt="">
 * <p>
 * Note that each block() will trigger a new subscription: in other words, the result
 * might miss signal from hot publishers.
 *
 * @return T the result
 */
@Nullable
public T block() {
  BlockingMonoSubscriber<T> subscriber = new BlockingMonoSubscriber<>();
  onLastAssembly(this).subscribe(Operators.toCoreSubscriber(subscriber));
  return subscriber.blockingGet();
}

相关文章

Mono类方法