Add synchronous support to the DeliveryClient

Đang mở
#109 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

  • #112 của @cunhazera — đã đóng, không merge

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
java
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu bằng cách đọc các phương thức của DeliveryClient và các giá trị trả về dựa trên CompletionStage được mô tả trong issue, sau đó so sánh chúng với wrapper DeliveryClientHelper được cung cấp. Xác định cách các phương án đồng bộ nên cung cấp kết quả và lỗi, đồng thời coi các lệnh gọi mẫu là tiêu chí hoàn thành.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement good first issue groomed hacktoberfest help wanted up-for-grabs
Motivation

After updating a large application to the latest version of the Java SDK, all calls to the DeliveryClient had to wrapped in a synchronous wrapper. It would be helpful if there were a built-in way to call the DeliveryClient synchronously rather than introducing additional code to the project.

Proposed solution

Add alternate methods for working with the DeliveryClient synchronously, for example:

deliveryClient.getItems().toSync() or deliveryClient.getItemsSynchronously()

Additional context

Here is the wrapper class that I had to write:

public class DeliveryClientHelper {
    public static <T> T toSync(CompletionStage<T> completionStage) {
        try {
            return completionStage.toCompletableFuture().get();
        } catch (InterruptedException e) {
            log.error("Error converting completion stage: {}", e.getMessage());
        } catch (ExecutionException e) {
            log.error("Error converting completion stage: {}", e.getMessage());
        }
        return null;
    }
}

An example call using the wrapper:

List<AgencySiteBlogLanding> blogHomepages = DeliveryClientHelper.toSync(deliveryClient.getItems(AgencySiteBlogLanding.class));

An ideal way to use the DeliveryClient

List<AgencySiteBlogLanding> blogHomepages = deliveryClient.getItems(AgencySiteBlogLanding.class).toSync();
Ngôn ngữ chính
Java
Star
17
Fork
27
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của kontent-ai/java-packages

Tất cả issue của kontent-ai/java-packages

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.