Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make SdkToProto and ProtoToSDK public #758

Merged
merged 2 commits into from Feb 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions binding/format/protobuf/v2/protobuf.go
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) {
n3wscott marked this conversation as resolved.
Show resolved Hide resolved
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