-
Notifications
You must be signed in to change notification settings - Fork 168
Description
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.