-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Observe
and ToObservable
for IEncodedConnection
#554
Comments
Maybe I can expand a bit on what I was expecting when using an IEncodedConnection connection = this.connectionFactory.CreateEncodedConnection(configuration.Url)
connection.OnDeserialize = data =>
{
// Deserialization logic, e.g. using protocol buffers.
};
IEncodedAsyncSubscription subscription = connection.SubscribeAsync("Subject");
INATSObservable<object> observable = subscription.ToObservable()
.Select(decodedObject => {
// Mapping logic.
}); Note that in the above, the |
@hypdeb Can you please review this unit test https://github.com/nats-io/nats.net/blob/master/src/Tests/IntegrationTests/TestEncoding.cs |
@scottf Thanks for coming back to me on this. I don't think the test addresses my issue. I know I can receive the decoded messages, what I am missing is a handy way of extracting an observable sequence out of those messages, like it exists for the It is possible what I'm trying to do is somehow not smart, therefore let me add a bit more context: I have a messaging service with an interface looking like this: interface IMessagingService
{
IObservable<MessageType> ReadMessages();
} that I would like to implement like this: class NatsMessagingService
{
IObservable<MessageType> ReadMessages()
{
IEncodedConnection connection = this.connectionFactory.CreateEncodedConnection(configuration.Url)
connection.OnDeserialize = data =>
{
// Deserialization logic, e.g. using protocol buffers.
};
IEncodedAsyncSubscription subscription = connection.SubscribeAsync("Subject");
INATSObservable<MessageType> observable = subscription.ToObservable()
.Select(decodedObject => {
// Mapping logic.
});
return observable;
}
} I cannot do that at this time because there is no |
I think you might need some or an entire duplication of the RX package just for encoded connection. Maybe / maybe not, this is an area in the .NET client that I really don't use. You are welcome to fork the repo and propose a solution. |
The What is missing is a subscription with and Which part of the code are you referring to when you say that you are not using it ? Encoded connections or Rx ? Would you know of someone who is using that who could have a look ? |
I am noticing a further discrepancy between the functionality supported by |
Feature Request
Use Case:
Same use cases as for
IConnection
.Proposed Change:
Implement extension methods
Observe
andToObservable
forIEncodedConnection
.Who Benefits From The Change(s)?
Users of
Rx
andIEncodedConnection
.Alternative Approaches
There's none I can see. I'm new to NATS, maybe there's something I'm not understanding.
The text was updated successfully, but these errors were encountered: