rticommunity / rticonnextdds-connector-go

RTI Connector for Connext DDS is a lightweight technology that enables DDS data to be accessed with Go.
Other
26 stars 12 forks source link

DynamicData Serialization #42

Closed metarsit closed 2 years ago

metarsit commented 3 years ago

Question:

Currently everything is defined and it is easy to subscribe/publish messages. However, is there a way for us to serialize the message

Desired behavior:

Blob of data (string or bytes) instead of given data structure

https://community.rti.com/howto/dynamicdata-serialization

metarsit commented 3 years ago

@kyoungho do we have something like this?

kyoungho commented 3 years ago

@metarsit I think to_cdr_buffer & from_cdr_buffer functions are not available in Connector. Can you tell me more about your use case with these functions?

metarsit commented 3 years ago

so.. i have a few tasks running and all are publishing different data structure.. We are not serializing yet, means my XML in my GO application has to reflect 1:1 data structure for everything.

I am hoping that if we have a feature similar where as long as I know the channel name, I can subscribe to it and read the messages in bytes form. I don’t have to deserialize it.

kyoungho commented 3 years ago

Go Connector does not encode/decode in JSON (reflected in Go struct) if you do not call Get/Set functions. Reflecting in Go struct is one way to set and get DDS data, but you can interact with Get* (e.g. GetInt) functions without having reflected Go struct like the following example.

https://github.com/rticommunity/rticonnextdds-connector-go/blob/develop/examples/simple/reader/reader.go

To avoid the encode/decode overhead between your tasks, you could pass DDS Sample objects as a Go channel and then you can consume and access the objects with reflected Go struct or Get* functions.

If multiple Go routines accesses the same Connector objects (e.g. Samples), they need to be protected from a race condition.

https://github.com/rticommunity/rticonnextdds-connector-go#threading-model