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

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

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

Mono.and介绍

[英]Join the termination signals from this mono and another source into the returned void mono
[中]将来自此单声道和另一个源的终止信号连接到返回的void单声道中

代码示例

代码示例来源:origin: spring-projects/spring-data-redis

private static Mono<Void> subscribe(ByteBuffer[] patterns, ByteBuffer[] channels, ReactiveSubscription it) {
  Assert.isTrue(!ObjectUtils.isEmpty(channels) || !ObjectUtils.isEmpty(patterns),
      "Must provide either channels or patterns!");
  Mono<Void> subscribe = null;
  if (!ObjectUtils.isEmpty(patterns)) {
    subscribe = it.pSubscribe(patterns);
  }
  if (!ObjectUtils.isEmpty(channels)) {
    Mono<Void> channelsSubscribe = it.subscribe(channels);
    if (subscribe == null) {
      subscribe = channelsSubscribe;
    } else {
      subscribe = subscribe.and(channelsSubscribe);
    }
  }
  return subscribe;
}

代码示例来源:origin: spring-projects/spring-session

private Mono<Void> saveDelta() {
  if (this.delta.isEmpty()) {
    return Mono.empty();
  }
  String sessionKey = getSessionKey(getId());
  Mono<Boolean> update = ReactiveRedisOperationsSessionRepository.this.sessionRedisOperations
      .opsForHash().putAll(sessionKey, this.delta);
  Mono<Boolean> setTtl = ReactiveRedisOperationsSessionRepository.this.sessionRedisOperations
      .expire(sessionKey, getMaxInactiveInterval());
  return update.and(setTtl).and((s) -> {
    this.delta.clear();
    s.onComplete();
  }).then();
}

代码示例来源:origin: spring-projects/spring-session

@Override
public Mono<Void> save(RedisSession session) {
  Mono<Void> result = session.saveChangeSessionId().and(session.saveDelta())
      .and((s) -> {
        session.isNew = false;
        s.onComplete();
      });
  if (session.isNew) {
    return result;
  }
  else {
    String sessionKey = getSessionKey(
        session.hasChangedSessionId() ? session.originalSessionId
            : session.getId());
    return this.sessionRedisOperations.hasKey(sessionKey)
        .flatMap((exists) -> exists ? result
            : Mono.error(new IllegalStateException(
                "Session was invalidated")));
  }
}

代码示例来源:origin: spring-projects/spring-session

private Mono<Void> saveChangeSessionId() {
  if (!hasChangedSessionId()) {
    return Mono.empty();
  }
  String sessionId = getId();
  Publisher<Void> replaceSessionId = (s) -> {
    this.originalSessionId = sessionId;
    s.onComplete();
  };
  if (this.isNew) {
    return Mono.from(replaceSessionId);
  }
  else {
    String originalSessionKey = getSessionKey(this.originalSessionId);
    String sessionKey = getSessionKey(sessionId);
    return ReactiveRedisOperationsSessionRepository.this.sessionRedisOperations
        .rename(originalSessionKey, sessionKey).and(replaceSessionId);
  }
}

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

@Test
public void pairWise() {
  Mono<Void> f = Mono.just(1)
            .and(Mono.just("test2"));
  Assert.assertTrue(f instanceof MonoWhen);
  MonoWhen s = (MonoWhen) f;
  Assert.assertTrue(s.sources != null);
  Assert.assertTrue(s.sources.length == 2);
  f.subscribeWith(AssertSubscriber.create())
   .assertComplete()
  .assertNoValues();
}

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

/**
 * @param other
 * @return
 * @see reactor.core.publisher.Mono#and(reactor.core.publisher.Mono)
 */
public final <T2> Mono<Tuple2<T, T2>> and(Mono<? extends T2> other) {
  return boxed.and(other);
}
/**

代码示例来源:origin: org.springframework.data/spring-data-redis

private static Mono<Void> subscribe(ByteBuffer[] patterns, ByteBuffer[] channels, ReactiveSubscription it) {
  Assert.isTrue(!ObjectUtils.isEmpty(channels) || !ObjectUtils.isEmpty(patterns),
      "Must provide either channels or patterns!");
  Mono<Void> subscribe = null;
  if (!ObjectUtils.isEmpty(patterns)) {
    subscribe = it.pSubscribe(patterns);
  }
  if (!ObjectUtils.isEmpty(channels)) {
    Mono<Void> channelsSubscribe = it.subscribe(channels);
    if (subscribe == null) {
      subscribe = channelsSubscribe;
    } else {
      subscribe = subscribe.and(channelsSubscribe);
    }
  }
  return subscribe;
}

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

private static Mono<Void> subscribe(ByteBuffer[] patterns, ByteBuffer[] channels, ReactiveSubscription it) {
  Assert.isTrue(!ObjectUtils.isEmpty(channels) || !ObjectUtils.isEmpty(patterns),
      "Must provide either channels or patterns!");
  Mono<Void> subscribe = null;
  if (!ObjectUtils.isEmpty(patterns)) {
    subscribe = it.pSubscribe(patterns);
  }
  if (!ObjectUtils.isEmpty(channels)) {
    Mono<Void> channelsSubscribe = it.subscribe(channels);
    if (subscribe == null) {
      subscribe = channelsSubscribe;
    } else {
      subscribe = subscribe.and(channelsSubscribe);
    }
  }
  return subscribe;
}

代码示例来源:origin: org.cloudfoundry/cloudfoundry-client-spring

@Override
public void check() {
  this.info
    .get(GetInfoRequest.builder()
      .build())
    .map(response -> Version.valueOf(response.getApiVersion()))
    .and(Mono.just(Version.valueOf(CloudFoundryClient.SUPPORTED_API_VERSION)))
    .doOnSuccess(consumer((server, supported) -> logCompatibility(server, supported, this.logger)))
    .subscribe();
}

相关文章

Mono类方法