mirror of
https://github.com/postmannen/ctrl.git
synced 2025-01-07 04:49:17 +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
|
// --- Message
|
||||||
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
|
_ struct{} `cbor:",toarray"`
|
||||||
// The node to send the message to.
|
// The node to send the message to.
|
||||||
ToNode Node `json:"toNode" yaml:"toNode"`
|
ToNode Node `json:"toNode" yaml:"toNode"`
|
||||||
// ToNodes to specify several hosts to send message to in the
|
// 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{}
|
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 {
|
if val, ok := msg.Header["serial"]; ok {
|
||||||
// fmt.Printf(" * DEBUG: ok = %v, map = %v, len of val = %v\n", ok, msg.Header, len(val))
|
// fmt.Printf(" * DEBUG: ok = %v, map = %v, len of val = %v\n", ok, msg.Header, len(val))
|
||||||
switch val[0] {
|
switch val[0] {
|
||||||
|
@ -351,8 +352,9 @@ func (p process) messageSubscriberHandler(natsConn *nats.Conn, thisNode string,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
default: // Deaults to gob if no match was found.
|
default: // Deaults to gob if no match was found.
|
||||||
buf := bytes.NewBuffer(msgData)
|
r := bytes.NewReader(msgData)
|
||||||
gobDec := gob.NewDecoder(buf)
|
gobDec := gob.NewDecoder(r)
|
||||||
|
|
||||||
err := gobDec.Decode(&message)
|
err := gobDec.Decode(&message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
er := fmt.Errorf("error: gob decoding failed: %v", err)
|
er := fmt.Errorf("error: gob decoding failed: %v", err)
|
||||||
|
@ -364,8 +366,9 @@ func (p process) messageSubscriberHandler(natsConn *nats.Conn, thisNode string,
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Default to gob if serialization flag was not specified.
|
// Default to gob if serialization flag was not specified.
|
||||||
buf := bytes.NewBuffer(msgData)
|
r := bytes.NewReader(msgData)
|
||||||
gobDec := gob.NewDecoder(buf)
|
gobDec := gob.NewDecoder(r)
|
||||||
|
|
||||||
err := gobDec.Decode(&message)
|
err := gobDec.Decode(&message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
er := fmt.Errorf("error: gob decoding failed: %v", err)
|
er := fmt.Errorf("error: gob decoding failed: %v", err)
|
||||||
|
|
Loading…
Reference in a new issue