• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Promise类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中ratpack.exec.Promise的典型用法代码示例。如果您正苦于以下问题:Java Promise类的具体用法?Java Promise怎么用?Java Promise使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Promise类属于ratpack.exec包,在下文中一共展示了Promise类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: flow

import ratpack.exec.Promise; //导入依赖的package包/类
/**
 * @param promise
 * @param strategy The {@link BackpressureStrategy} to use
 * @param <T>
 * @return
 * @see RxRatpack#observe(Promise)
 */
public static <T> Flowable<T> flow(Promise<T> promise, BackpressureStrategy strategy) {
  return Flowable.create(subscriber ->
      promise.onError(subscriber::onError).then(value -> {
        subscriber.onNext(value);
        subscriber.onComplete();
      }),
    strategy);
}
 
开发者ID:drmaas,项目名称:ratpack-rx2,代码行数:16,代码来源:RxRatpack.java


示例2: accept

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
public void accept(Throwable e) throws Exception {
  if (e instanceof OnErrorNotImplementedException) {
    Promise.error(e.getCause()).then(Action.noop());
  } else if (e instanceof UndeliverableException) {
    Promise.error(e.getCause()).then(Action.noop());
  } else {
    Promise.error(e).then(Action.noop());
  }
}
 
开发者ID:drmaas,项目名称:ratpack-rx2,代码行数:11,代码来源:ErrorHandler.java


示例3: backoff

import ratpack.exec.Promise; //导入依赖的package包/类
public Promise<Void> backoff() {
    return Blocking.op(() -> {
        log.debug("Circuit is OPEN.  Waiting...");
        Thread.sleep(waitTime());
        mark();
    }).promise();
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:8,代码来源:ExponentialBackoff.java


示例4: check

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
public Promise<Result> check(Registry registry) throws Exception {
    return eurekaService.isAvailable().map(available -> {
        if (available) {
            return Result.healthy();
        }
        return Result.unhealthy("EurekaService: Not available");
    });
}
 
开发者ID:schibsted,项目名称:ratpack-eureka,代码行数:10,代码来源:EurekaHealthCheck.java


示例5: consume

import ratpack.exec.Promise; //导入依赖的package包/类
private Promise<Void> consume(ReceiveMessageResult result) {
    List<Promise<Void>> promises = result.getMessages().stream()
        .map(this::consume)
        .collect(Collectors.toList());

    return SerialBatch.of(promises)
        .yieldAll()
        .flatMap(v -> Promise.value(null));
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:10,代码来源:ConsumerAction.java


示例6: deleteMessage

import ratpack.exec.Promise; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Promise<Void> deleteMessage(Message message) {
    return getQueueUrl()
        .map(url -> new DeleteMessageRequest(url, message.getReceiptHandle()))
        .flatMap(sqs::deleteMessage)
        .transform(transformer.recover(t -> new DeleteMessageResult()));
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:8,代码来源:ConsumerAction.java


示例7: getReceiveMessageRequest

import ratpack.exec.Promise; //导入依赖的package包/类
private Promise<ReceiveMessageRequest> getReceiveMessageRequest() {
    ReceiveMessageRequest request = consumer.getReceiveMessageRequest();
    if (request.getQueueUrl() == null || request.getQueueUrl().isEmpty()) {
        return getQueueUrl()
            .map((url) -> {
               request.withQueueUrl(url);
               return request;
            });
    }
    return Promise.value(request);
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:12,代码来源:ConsumerAction.java


示例8: getBook

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
public Promise<Book> getBook(String isbn) {
  // TODO - Implement getBooks function
  // Hint - checkout Blocking#get(Block) to see how to integrate blocking code with Ratpack
  // Hint - lab07.jooq.tables.Book.BOOK is the representation for the underlying `book` table
  // Hint - checkout SelectWhereStep#where(Condition...) and ResultQuery#fetchOneInto(Class)
  return Blocking.get(() ->
    create.select().from(BOOK).where(BOOK.ISBN.equal(isbn)).fetchOneInto(Book.class)
  );
}
 
开发者ID:danveloper,项目名称:hands-on-ratpack-java,代码行数:11,代码来源:DefaultBookRepository.java


示例9: setTopicAttributes

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Promise<SetTopicAttributesResult> setTopicAttributes(
    String topicArn,
    String attributeName,
    String attributeValue
) {
    return Blocking.get(() -> sns().setTopicAttributes(topicArn, attributeName, attributeValue))
        .transform(breaker);
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:11,代码来源:DefaultSnsService.java


示例10: requestStream

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
public Promise<StreamedResponse> requestStream(URI uri, Action<? super RequestSpec> action) {
    final AtomicReference<Span> span = new AtomicReference<>();

    return delegate
        .requestStream(uri, (RequestSpec requestSpec) -> {
            WrappedRequestSpec captor = new WrappedRequestSpec(handler, injector, requestSpec, span);
            // streamed request doesn't set the http method.
            // start span here until a better solution presents itself.
            span.set(handler.handleSend(injector, captor.getHeaders(), captor));
            action.execute(captor);
        })
        .wiretap(response -> streamedResponseWithSpan(response, span));
}
 
开发者ID:hyleung,项目名称:ratpack-zipkin,代码行数:15,代码来源:ZipkinHttpClientImpl.java


示例11: createTopic

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Promise<CreateTopicResult> createTopic(CreateTopicRequest request) {
    LOG.trace("creating sns topic request={}", request);
    return Blocking.get(() -> sns().createTopic(request))
        .transform(breaker);
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:8,代码来源:DefaultSnsService.java


示例12: deleteTopic

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Promise<DeleteTopicResult> deleteTopic(DeleteTopicRequest request) {
    LOG.debug("deleting sns topic request={}", request);
    return Blocking.get(() -> sns().deleteTopic(request))
        .transform(breaker);
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:8,代码来源:DefaultSnsService.java


示例13: addPermission

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Promise<AddPermissionResult> addPermission(
    String topicArn,
    String label,
    List<String> aWSAccountIds,
    List<String> actionNames
) {
    return Blocking.get(() -> sns().addPermission(topicArn, label, actionNames, actionNames))
        .transform(breaker);
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:12,代码来源:DefaultSnsService.java


示例14: checkIfPhoneNumberIsOptedOut

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Promise<CheckIfPhoneNumberIsOptedOutResult> checkIfPhoneNumberIsOptedOut(
    CheckIfPhoneNumberIsOptedOutRequest request
) {
    return Blocking.get(() -> sns().checkIfPhoneNumberIsOptedOut(request))
        .transform(breaker);
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:9,代码来源:DefaultSnsService.java


示例15: confirmSubscription

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Promise<ConfirmSubscriptionResult> confirmSubscription(
    String topicArn,
    String token,
    String authenticateOnUnsubscribe
) {
    return Blocking.get(() -> sns().confirmSubscription(topicArn, token, authenticateOnUnsubscribe))
        .transform(breaker);
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:11,代码来源:DefaultSnsService.java


示例16: getBooks

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
public Promise<List<Book>> getBooks() {
  // TODO - Implement getBooks function
  // Hint - checkout Blocking#get(Block) to see how to integrate blocking code with Ratpack
  // Hint - lab07.jooq.tables.Book.BOOK is the representation for the underlying `book` table
  // Hint - checkout DSLContext#select() and ResultQuery#fetchInto(Class)
  return null;
}
 
开发者ID:danveloper,项目名称:hands-on-ratpack-java,代码行数:9,代码来源:DefaultBookRepository.java


示例17: createPlatformApplication

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Promise<CreatePlatformApplicationResult> createPlatformApplication(
    CreatePlatformApplicationRequest request
) {
    return Blocking.get(() -> sns().createPlatformApplication(request))
        .transform(breaker);
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:9,代码来源:DefaultSnsService.java


示例18: setPlatformApplicationAttributes

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Promise<SetPlatformApplicationAttributesResult> setPlatformApplicationAttributes(
    SetPlatformApplicationAttributesRequest request
) {
    return Blocking.get(() -> sns().setPlatformApplicationAttributes(request))
        .transform(breaker);
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:9,代码来源:DefaultSnsService.java


示例19: setSubscriptionAttributes

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Promise<SetSubscriptionAttributesResult> setSubscriptionAttributes(
    SetSubscriptionAttributesRequest request
) {
    return Blocking.get(() -> sns().setSubscriptionAttributes(request))
        .transform(breaker);
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:9,代码来源:DefaultSnsService.java


示例20: getPlatformApplicationAttributes

import ratpack.exec.Promise; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Promise<GetPlatformApplicationAttributesResult> getPlatformApplicationAttributes(
    GetPlatformApplicationAttributesRequest request
) {
    return Blocking.get(() -> sns().getPlatformApplicationAttributes(request))
        .transform(breaker);
}
 
开发者ID:SmartThingsOSS,项目名称:ratpack-sqs,代码行数:9,代码来源:DefaultSnsService.java



注:本文中的ratpack.exec.Promise类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Nullable类代码示例发布时间:2022-05-22
下一篇:
Java Code39Bean类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap