Skip to content

Commit

Permalink
Merge pull request #55 from pinealctx/cherry-pick
Browse files Browse the repository at this point in the history
rename interface "MarkedProto" to "FingerprintMsg"
  • Loading branch information
xpineal authored Jul 27, 2022
2 parents 45c3a68 + 77c7a1e commit 504c5ed
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mpb/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ var (
_defaultMsgPacker = NewMsgPacker()
)

// MarkedProto extends "Fingerprint() uint32" to proto message
type MarkedProto interface {
// FingerprintMsg extends "Fingerprint() uint32" to proto message
type FingerprintMsg interface {
proto.Message
Fingerprint() uint32
}
Expand All @@ -43,7 +43,7 @@ func NewMsgPacker() *MsgPacker {
}

// RegisterGenerator register a protobuf generator function with tag
func (x *MsgPacker) RegisterGenerator(genFn func() MarkedProto) {
func (x *MsgPacker) RegisterGenerator(genFn func() FingerprintMsg) {
var exist bool
var mo = genFn()
if mo == nil {
Expand Down Expand Up @@ -74,7 +74,7 @@ func (x *MsgPacker) RegisterGenerator(genFn func() MarkedProto) {
// and other proto message which extends "Fingerprint() uint32"
func (x *MsgPacker) MarshalMsg(msg proto.Message) ([]byte, error) {
switch v := msg.(type) {
case MarkedProto:
case FingerprintMsg:
return x.marshalMsg(v)
case *emptypb.Empty:
return tagEmptyMsg(), nil
Expand Down Expand Up @@ -134,7 +134,7 @@ func (x *MsgPacker) UnmarshalResponse(data []byte) (msg proto.Message, msgErr er
return m, nil, nil
}

func (x *MsgPacker) marshalMsg(msg MarkedProto) ([]byte, error) {
func (x *MsgPacker) marshalMsg(msg FingerprintMsg) ([]byte, error) {
var fingerprint = msg.Fingerprint()
var _, ok = x.genFuncMap[fingerprint]
if !ok {
Expand Down Expand Up @@ -168,7 +168,7 @@ func (x *MsgPacker) unmarshalErr(data []byte) (*spb.Status, error) {
}

// RegisterGenerator register a protobuf generator function with tag
func RegisterGenerator(genFn func() MarkedProto) {
func RegisterGenerator(genFn func() FingerprintMsg) {
_defaultMsgPacker.RegisterGenerator(genFn)
}

Expand Down

0 comments on commit 504c5ed

Please sign in to comment.