RxDave / Qactive

Reactive queryable observable framework.
Apache License 2.0
157 stars 20 forks source link

Ability to take Serialization of Qbservables without the tcp component? #19

Closed ronnyek closed 6 years ago

ronnyek commented 8 years ago

I'm super interested in this stuff, since ms seems to be dropping the ball on it in a bad way. I'd like to be able to just serialize the Qbservable... is it reasonable to just convert an expression to a SerializableExpression and then serialize via whatever serializer I choose to and push that over to other end via websockets or rest endpoint?

RxDave commented 8 years ago

Thanks for your interest. I'm actually in the same boat. I really needed this for work and have been waiting for MS to release theirs for a while. Also, seeing Bart's presentation made me think that their implementation is probably much larger and more complicated than what I actually needed (e.g., Azure dependency and persistence), and I'm doubtful whether it will support Qactive's features, which I find absolutely necessary for my needs; e.g., a simple extension method to convert an IObservable<T> into an IQbservable<T> over a TCP socket, anonymous type serialization and the full-duplex callback mechanism (which I simply refer to as "duplex").

I'm aware that not everyone is going to want to use my TCP implementation, so I've separated the Qactive core and Streaming components away from TCP so that custom providers can be built on top of them. I'd be interested in accepting a pull request for (or building, or helping to build) a WebSocket provider.

I'm not sure how Qactive would work with REST though, since I designed it for persistent socket connections. Writing a provider for it would be tricky, especially because of the callback mechanism; i.e., if you close over an IObservable<T>, then the server subscribes to the observable on the client. Perhaps the solution is to just not support callbacks in the REST provider. Would have to think some more about it though.

The unit tests actually have an example of a custom provider that I built just for test purposes. I basically copied the TCP provider and systematically refactored until I got what I needed. So that proves that it's possible.

Reviewing the TCP provider is a good starting point to see how a WebSocket version could be built. That seems like it might be pretty easy, actually.

If you'd like to provide some more context about how you'd like to use it, then maybe I can help.

RxDave commented 8 years ago

Btw, if you really just want to use the serializable expressions and do your own thing, then that's possible too. Actually, I've been using the serializable expression trees to send Func<T> as part of the payload in one of my Qactive queries at work; e.g., as an IComparer<T> implementation for sorting on the server-side via a duplex subscription.

To serialize expressions, simply create an instance of SerializableExpressionConverter and call any of its TryConvert methods. (Don't reuse the instance though, because it's stateful and doesn't clear itself.)

To deserialize, call the static TryConvert method.

RxDave commented 8 years ago

Fyi, I'm working on a WebSocket provider now. It'll probably be checked in within the week. It may not be exactly what you're looking for but at least it's a step in the right direction.