mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
added cbor toarray
This commit is contained in:
parent
3bf5fca5cd
commit
8e87caf30a
2 changed files with 9 additions and 5 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
// --- Message
|
||||
|
||||
type Message struct {
|
||||
_ struct{} `cbor:",toarray"`
|
||||
// The node to send the message to.
|
||||
ToNode Node `json:"toNode" yaml:"toNode"`
|
||||
// ToNodes to specify several hosts to send message to in the
|
||||
|
|
13
process.go
13
process.go
|
@ -338,7 +338,8 @@ func (p process) messageSubscriberHandler(natsConn *nats.Conn, thisNode string,
|
|||
|
||||
message := Message{}
|
||||
|
||||
// Is serializatio
|
||||
// Check if serialization is specified.
|
||||
// Will default to gob serialization if nothing is specified.
|
||||
if val, ok := msg.Header["serial"]; ok {
|
||||
// fmt.Printf(" * DEBUG: ok = %v, map = %v, len of val = %v\n", ok, msg.Header, len(val))
|
||||
switch val[0] {
|
||||
|
@ -351,8 +352,9 @@ func (p process) messageSubscriberHandler(natsConn *nats.Conn, thisNode string,
|
|||
return
|
||||
}
|
||||
default: // Deaults to gob if no match was found.
|
||||
buf := bytes.NewBuffer(msgData)
|
||||
gobDec := gob.NewDecoder(buf)
|
||||
r := bytes.NewReader(msgData)
|
||||
gobDec := gob.NewDecoder(r)
|
||||
|
||||
err := gobDec.Decode(&message)
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: gob decoding failed: %v", err)
|
||||
|
@ -364,8 +366,9 @@ func (p process) messageSubscriberHandler(natsConn *nats.Conn, thisNode string,
|
|||
|
||||
} else {
|
||||
// Default to gob if serialization flag was not specified.
|
||||
buf := bytes.NewBuffer(msgData)
|
||||
gobDec := gob.NewDecoder(buf)
|
||||
r := bytes.NewReader(msgData)
|
||||
gobDec := gob.NewDecoder(r)
|
||||
|
||||
err := gobDec.Decode(&message)
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: gob decoding failed: %v", err)
|
||||
|
|
Loading…
Reference in a new issue