2
0
mirror of https://github.com/hibiken/asynq.git synced 2025-10-22 22:06:12 +08:00

Update base.DecodeMessage to take byte slice

This commit is contained in:
Ken Hibino
2021-03-02 22:14:55 -08:00
parent e408550d76
commit 9ac0475d4b
4 changed files with 8 additions and 9 deletions

View File

@@ -218,11 +218,10 @@ func EncodeMessage(msg *TaskMessage) ([]byte, error) {
return proto.Marshal(&pbmsg)
}
// DecodeMessage unmarshals the given encoded string and returns a decoded task message.
// TODO: should take []byte instead of string
func DecodeMessage(s string) (*TaskMessage, error) {
// DecodeMessage unmarshals the given bytes and returns a decoded task message.
func DecodeMessage(data []byte) (*TaskMessage, error) {
var pbmsg pb.TaskMessage
if err := proto.Unmarshal([]byte(s), &pbmsg); err != nil {
if err := proto.Unmarshal(data, &pbmsg); err != nil {
return nil, err
}
d := json.NewDecoder(bytes.NewReader(pbmsg.Payload))