cloudevents / cloudevents/sdk-java

Make ProtoSerializer accessible

Open
#706 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
446
Forks
172
PR merge metrics
No merged PRs in 30d

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the package-local ProtoSerializer and ProtoDeserializer classes mentioned in the issue, along with the ProtobufFormat entry point. Make both serializers accessible to consumers while preserving the existing toProto and deserialization behavior. Verify that callers can convert directly between CloudEvent and io.cloudevents.v1.proto.CloudEvent without the intermediate byte-array conversion.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.