nats.net
nats.net copied to clipboard
Creating JetStream context from encoded connection
Feature Request
I might be missing some piece of information or maybe it's possible to do this another way, but I can't find anything in the docs that enable this.
Use Case:
I have custom serializers and deserializers which I would like to use with JetStream.
Proposed Change:
Make it possible to create a JetStream context from IEncodedConnection
.
Who Benefits From The Change(s)?
Those who use encoded connections and JetStream.
Alternative Approaches
I would love to know the alternative way I can have custom serializers and deserializers alongside JetStream context
I need this, too.
Do you have any update or alternative approaches?
@tiliev I ended up using the regular IConnection
interface and created the IJetStream
connection, then before publishing messages I just manually called the serialization functionality. Same when receiving any data, I deserialize it manually.
If you manually write the code for this, over time it will of course be quite tedious, in my case I am generating the code so I found it acceptable 🙂
Since it is open source, you are welcome to offer a PR, in fact we would love that. It's just not that big a priority since you are not prevented from doing the encoding yourself. In the meantime, as already noted you can just serialize before the publish and deserialize when handling the message. Not sure how this is more tedious than setting up the encoded serialize/deserialize handler, since the bulk of the code is the implementation of serialize/deserialize which is reusable, not the calling of the implementation.
My teams stopped using IEncodedConnection
for a few reasons:
- It's an odd duck interface that we likely wouldn't include if we made NATS C# client again.
- You can build a much better one yourself that's usable in more instances.
Ultimately, I too don't think it's worth it.