func (as *Proto) Encode(obj gbus.Message) (buffer []byte, err error) {
	msg, ok := obj.(proto.Message)
	if !ok {
		err = fmt.Errorf("could not cast message into proto.Message")
		as.logger.WithError(err).Error("invalid type of object")
		return nil, err
	}
	buffer, err = proto.Marshal(msg)
	if err != nil {
		as.logger.WithError(err).Error("could not Marshal msg")
		return nil, err
	}
	return
}
Encode encodes an object into a byte array
package serialization
import (
	"fmt"
	"reflect"
	"sync"
	"github.com/golang/protobuf/proto"
	"github.com/sirupsen/logrus"
	"github.com/wework/grabbit/gbus"
)
var _ gbus.Serializer = &Proto{}
const ProtoContentType = "application/x-protobuf"
type Proto struct {
	lock              *sync.Mutex
	registeredSchemas map[string]reflect.Type
	logger            logrus.FieldLogger
}
func NewProtoSerializer(logger logrus.FieldLogger) gbus.Serializer {
	return &Proto{
		registeredSchemas: make(map[string]reflect.Type),
		lock:              &sync.Mutex{},
		logger:            logger.WithField("serializer", "proto"),
	}
}
func (as *Proto) Name() string {
	return ProtoContentType
}