From 9f80fd3a004fcabea03987db1fdfcb324deef14e Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Wed, 16 Feb 2022 06:47:11 +0800 Subject: [PATCH] Make SdkToProto and ProtoToSDK public (#758) * Make SdkToProto and ProtoToSDK public Signed-off-by: Kevin Su * Fixed tests Signed-off-by: Kevin Su --- binding/format/protobuf/v2/protobuf.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/binding/format/protobuf/v2/protobuf.go b/binding/format/protobuf/v2/protobuf.go index c70249e45..01b93d47b 100644 --- a/binding/format/protobuf/v2/protobuf.go +++ b/binding/format/protobuf/v2/protobuf.go @@ -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 } @@ -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 } @@ -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(), @@ -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)