Commit 02379d4 1 parent 83e341c commit 02379d4 Copy full SHA for 02379d4
File tree 3 files changed +20
-3
lines changed
3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -253,7 +253,8 @@ func (b *List) Status() bool {
253
253
}
254
254
255
255
func ListUnmarshalMessage (msg * disq.Message , body string ) error {
256
- if err := msgpack .Unmarshal ([]byte (body ), (* disq .MessageRaw )(msg )); err != nil {
256
+ err := msg .UnmarshalBinary (disq .StringToBytes (body ))
257
+ if err != nil {
257
258
return err
258
259
}
259
260
return nil
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ import (
13
13
"github.com/go-redis/redis/v8"
14
14
"github.com/google/uuid"
15
15
log "github.com/sirupsen/logrus"
16
- "github.com/vmihailenco/msgpack"
17
16
)
18
17
19
18
// Broker based on redis STREAM and ZSET.
@@ -316,7 +315,8 @@ func unixMs(tm time.Time) int64 {
316
315
317
316
func StreamUnmarshalMessage (msg * disq.Message , xmsg * redis.XMessage ) error {
318
317
body := xmsg .Values ["body" ].(string )
319
- if err := msgpack .Unmarshal ([]byte (body ), (* disq .MessageRaw )(msg )); err != nil {
318
+ err := msg .UnmarshalBinary (disq .StringToBytes (body ))
319
+ if err != nil {
320
320
return err
321
321
}
322
322
msg .ID = xmsg .ID
Original file line number Diff line number Diff line change 5
5
"os"
6
6
"strconv"
7
7
"time"
8
+ "unsafe"
8
9
)
9
10
10
11
func UnixMs (tm time.Time ) int64 {
@@ -21,3 +22,18 @@ func ConsumerName() string {
21
22
func DurEqual (d1 , d2 time.Duration , threshold int ) bool {
22
23
return (d2 >= d1 && (d2 - d1 ) < time .Duration (threshold )* time .Second )
23
24
}
25
+
26
+ // BytesToString converts byte slice to string.
27
+ func BytesToString (b []byte ) string {
28
+ return * (* string )(unsafe .Pointer (& b ))
29
+ }
30
+
31
+ // StringToBytes converts string to byte slice.
32
+ func StringToBytes (s string ) []byte {
33
+ return * (* []byte )(unsafe .Pointer (
34
+ & struct {
35
+ string
36
+ Cap int
37
+ }{s , len (s )},
38
+ ))
39
+ }
You can’t perform that action at this time.
0 commit comments