-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Support for Reactive Extensions within grains #315
Comments
By not supporting Reactive Extensions what exactly do you mean? It does not set or provide any IScheduler for RX operations, correct. And you want to support that by setting the So basically what I am asking is:
I thought that by being 100% TPL compatible we support anything that TPL supports (in a sense that support means "does not prevent from using"). EDIT: Cannot we just use that: |
@gabikliot, @ReubenBond I had this same issue. Some concrete meat to the discussion and a way to achieve this at SO: Is it in general dubious to call Task.Factory.StartNew(async () => {}) in Subscribe. Hmm, I wonder if I had a bit smarter code. I'll check when I get home. :) <edit: Yes, basically what's in the SO post, but with a modest modification:
|
Let me please make sure I understand the solution (please bear with me, I am new to RX internals).
Is that correct? For the context, this is also relevant: https://orleans.codeplex.com/discussions/560493. |
Just for the context, we think this is an important question, since in our Streaming we basically support "Rx-like" async stream. The grain can now subscribe to a stream with its The next question, for the future, would be how we can take this "conversion layer" and put it inside Orleans. |
That is how I understand it. I have wondered the relation between Orleans and ConfigureAwait(false). As I understand, calling it like that prevents capturing the |
That was my feeling as well. |
@ReubenBond , I thought how we can make progress on this issue. Then we can play around with the ideas above (using |
I think this could be implemented as you suggested, @gabikliot, by using var rxScheduler = new TaskPoolScheduler(new TaskFactory(RuntimeContext.Current)); I'll close this issue now. We can always re-open it if someone becomes interested/affected. Maybe if/when #940 is implemented and there's more impetus for Rx. |
Sounds good. |
Hello @gabikliot, @ReubenBond how is this issue progressing? I'm interested in developing some reactive logic independent of Orleans, and then use Orleans/Akka/Service Fabric to express actors. At least there is some gide on how to address this problem in Orleans? It is enough with the following code you posted before?
Thanks a lot |
We tried using the suggested workarounds and they dont work. |
I'll close this for now, since it's been unanswered (by me, mostly, my apologies) for a long period. Subscribing from within OnActivateAsync or a grain method, and providing the current TaskScheduler for both SubscribeOn and ObserveOn ought to work, though. If not, let's get a repro project and investigate in a new issue. Subscribing from a grain's constructor likely wouldn't work, at least not in the current version of Orleans, since it does not run on the grain's scheduler. If there is a deadlock then it most likely indicates that the grain is blocking synchronously on some code, or that a method is waiting to process some non-ending stream within a method (and therefore not exiting the async method) for a grain which is not marked |
Courtesy of @akourbat, here is a sample demonstrating Rx in Orleans: https://github.com/ReubenBond/TestOrleansRx The pertinent bit is this: var rxScheduler = new TaskPoolScheduler(new TaskFactory(TaskScheduler.Current));
Observable.Interval(TimeSpan.FromSeconds(1))
.ObserveOn(rxScheduler)
.Subscribe(x => _ticksSubj.OnNext(x)); Note that this leaks the Also note: do not call |
Currently, Orleans does not support Reactive Extensions.
This proposal is for us to set a
SynchronizationContext
within grain calls, so that Rx works when using.ObserveOn()
- I think it's fine if theSynchronizationContext
is lazily created on request, to make it pay-for-what-you-use rather than incurring a per-grain/per-call cost.This bit me in the foot today. I worked around it by shifting to a non-Rx implementation, but the Rx-based implementation was much more natural.
The text was updated successfully, but these errors were encountered: