Skip to content

Commit

Permalink
Merge pull request #13 from vimeda/clean-up
Browse files Browse the repository at this point in the history
Clean up
  • Loading branch information
mpraski authored Jun 8, 2020
2 parents b195cd3 + 1da6962 commit 1d3ecd1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions any/any.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ func Pack(m proto.Message) (pb.Envelope, error) {
return pb.Envelope{}, err
}

fullName := m.ProtoReflect().Descriptor().FullName()
const pkg = "github.com/lykon/pletter/%s"

fmt.Println(fullName)
fullName := m.ProtoReflect().Descriptor().FullName()

return pb.Envelope{
InnerMessage: &anypb.Any{
TypeUrl: fmt.Sprintf("github.com/lykon/pletter/%s", fullName),
TypeUrl: fmt.Sprintf(pkg, fullName),
Value: raw,
},
}, nil
Expand All @@ -56,10 +56,7 @@ func Unpack(m []byte, t proto.Message) error {
return err
}

return ptypes.UnmarshalAny(
e.GetInnerMessage(),
proto_old.MessageV1(t),
)
return ptypes.UnmarshalAny(e.GetInnerMessage(), proto_old.MessageV1(t))
}

// GetMessageName returns the message name from the wrapped proto message
Expand All @@ -70,11 +67,14 @@ func GetMessageName(m []byte) (string, error) {
}

splits := strings.Split(e.GetInnerMessage().GetTypeUrl(), "/")

return splits[len(splits)-1], nil
}

func getEnvelope(m []byte) (pb.Envelope, error) {
var receivingEnvelope pb.Envelope

err := proto.Unmarshal(m, &receivingEnvelope)

return receivingEnvelope, err
}

0 comments on commit 1d3ecd1

Please sign in to comment.