mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-22 10:03:41 +02:00
ship_processor.go: move encodeMessage to transport/message/encoding.go
This commit is contained in:
parent
f589f5c0ed
commit
5c5d7e57a9
2 changed files with 21 additions and 14 deletions
18
transport/message/encoder.go
Normal file
18
transport/message/encoder.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package message
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func Encode(v interface{}) ([]byte, bool) {
|
||||
payload, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
log.WithError(err).
|
||||
WithField("v", v).
|
||||
Warn("Failed to encode message to json")
|
||||
return nil, false
|
||||
}
|
||||
return payload, true
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue