Make ProtoSerializer accessible

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

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
52/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả 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 xác định các lớp ProtoSerializer và ProtoDeserializer cục bộ trong package được đề cập trong issue, cùng với điểm vào ProtobufFormat. Cho phép các consumer truy cập cả hai serializer, đồng thời giữ nguyên hành vi hiện có của toProto và quá trình giải tuần tự. Xác minh rằng các bên gọi có thể chuyển đổi trực tiếp giữa CloudEvent và io.cloudevents.v1.proto.CloudEvent mà không cần chuyển đổi trung gian qua mảng byte.

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

Mô tả

We use the io.cloudevents:cloudevents-protobuf:4.0.1 lib to serialize and deserialize CloudEvents as protobuf messages. Unfortunately, there is no direct access to the ProtoSerializer and ProtoDeserializer classes. For our use case it would be very helpful if we could convert a io.cloudevents.CloudEvent into a io.cloudevents.v1.proto.CloudEvent protobuf message. Which is basically what the toProto method in ProtoSerializer does.

class ProtoSerializer {  // <--- Can we make this class public?
    public static CloudEvent toProto(io.cloudevents.CloudEvent ce) throws InvalidProtocolBufferException {
        // ...
    }

    // ...
}

Unfortunately, this method is not accessible to consuming methods as the class is package-local, which does not allow us to call it from outside the io.cloudevents.protobuf package.

Currently, we can only use the ProtobufFormat to convert a CloudEvent to a byte[] which we can then decode as io.cloudevents.v1.proto.CloudEvent. This involves an unnecessary extra conversion step.

io.cloudevents.v1.proto.CloudEvent.parseFrom(new ProtobufFormat().serialize((io.cloudevents.CloudEvent) cloudEvent))

For symmetry reasons ProtoDeserializer should likely also be made public.

Ngôn ngữ chính
Java
Star
446
Fork
172
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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 cloudevents/sdk-java

Tất cả issue của cloudevents/sdk-java

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.