From 881f2e187d040c0735f0aa390c8c7a83eaea50e6 Mon Sep 17 00:00:00 2001 From: Daniel Canessa Date: Thu, 5 Nov 2020 07:36:27 -0800 Subject: [PATCH] Extend message struct to include a raw interface Add a new field to the message struct in order to pass user data such as a struct of pointers. Despite of the data can be stored on the message payload it have two dissavantages: 1) It forces the user to marshall/unmarshall the data each time that the message is passed in the pipeline 2) Data such as signaling channels or pointers can not be casted to a []byte. Signed-off-by: Daniel Canessa --- message/message.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/message/message.go b/message/message.go index d15fdaa16..8983f21e6 100644 --- a/message/message.go +++ b/message/message.go @@ -32,6 +32,9 @@ type Message struct { // Payload is message's payload. Payload Payload + // Interface to store user data. + UserData interface{} + // ack is closed, when acknowledge is received. ack chan struct{} // noACk is closed, when negative acknowledge is received. @@ -180,5 +183,10 @@ func (m *Message) Copy() *Message { for k, v := range m.Metadata { msg.Metadata.Set(k, v) } + + // Copy the user data to the message passed to the next + // handler + msg.UserData = m.UserData + return msg }