Skip to content

Commit

Permalink
Make SdkToProto and ProtoToSDK public (#758)
Browse files Browse the repository at this point in the history
* Make SdkToProto and ProtoToSDK public

Signed-off-by: Kevin Su <pingsutw@apache.org>

* Fixed tests

Signed-off-by: Kevin Su <pingsutw@apache.org>
  • Loading branch information
pingsutw authored Feb 15, 2022
1 parent 7601392 commit 9f80fd3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions binding/format/protobuf/v2/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (protobufFmt) MediaType() string {
}

func (protobufFmt) Marshal(e *event.Event) ([]byte, error) {
pbe, err := sdkToProto(e)
pbe, err := ToProto(e)
if err != nil {
return nil, err
}
Expand All @@ -67,7 +67,7 @@ func (protobufFmt) Unmarshal(b []byte, e *event.Event) error {
if err := proto.Unmarshal(b, pbe); err != nil {
return err
}
e2, err := protoToSDK(pbe)
e2, err := FromProto(pbe)
if err != nil {
return err
}
Expand All @@ -76,7 +76,7 @@ func (protobufFmt) Unmarshal(b []byte, e *event.Event) error {
}

// convert an SDK event to a protobuf variant of the event that can be marshaled.
func sdkToProto(e *event.Event) (*pb.CloudEvent, error) {
func ToProto(e *event.Event) (*pb.CloudEvent, error) {
container := &pb.CloudEvent{
Id: e.ID(),
Source: e.Source(),
Expand Down Expand Up @@ -191,7 +191,7 @@ func valueFrom(attr *pb.CloudEventAttributeValue) (interface{}, error) {
}

// Convert from a protobuf variant into the generic, SDK event.
func protoToSDK(container *pb.CloudEvent) (*event.Event, error) {
func FromProto(container *pb.CloudEvent) (*event.Event, error) {
e := event.New()
e.SetID(container.Id)
e.SetSource(container.Source)
Expand Down

0 comments on commit 9f80fd3

Please sign in to comment.