Creating a jetstream.Msg #1677
Replies: 3 comments 5 replies
-
Hello @samborkent. While that indeed may seem counter-intuitive, a What we could do is expose a different wrapper type around |
Beta Was this translation helpful? Give feedback.
-
Good day, +1 for converting nats.Msg to jetstream.Msg or vice versa. We have a lot of legacy code and we need to gradually migrate to new api. If it is not possible to convert either way then we need to maintain two version of code working with nats.Msg and jetstream.Msg. |
Beta Was this translation helpful? Give feedback.
-
The disconnect here is that |
Beta Was this translation helpful? Give feedback.
-
Hello, I am currently in the process of migrating to the new JetStream API, but I'm confused about something. I find it strange that the publish methods take messages of type
*nats.Msg
, which does not implement thejetstream.Msg
interface received by the consumer. So, if I change my utility functions to take ajetstream.Msg
instead, there is no straightforward way for creating such a message. I would expect there to be some initializer for ajetstream.Msg
or for there to be a conversion function to convert from the old API struct message type*nats.Msg
to the newjetstream.Msg
interface message type, or at least extract a*nats.Msg
from ajetstream.Msg
. Personally, I think it would have been better to just create a v2 of the API, as now there seem to be some inconsistencies when working with JetStream messages.Am I overlooking something? How can I create a
jetstream.Msg
from a*nats.Msg
? The only way I see now is to define my own message type that implementsjetstream.Msg
and write a conversion function myself, but I would expect this to be part of the API or at least have some explanation included in the migration guide: https://natsbyexample.com/examples/jetstream/api-migration/go.Beta Was this translation helpful? Give feedback.
All reactions