Repository navigation
AsyncEnumerable - #6044
AsyncEnumerable#6044
Conversation
| //TODO: when to dispose async enumerable? Should this be a part of ownership of current stage, or should it | ||
| // be a responsibility of the caller? | ||
| _asyncEnumerable = asyncEnumerable; |
There was a problem hiding this comment.
Not entirely related but Should we be taking a Func<IAsyncEnumerable<T>> here? (In my opinion yes, in ideal-state, a Source itself should be idempotent and able to be materialized multiple times.)
As to this question, for whatever my opinion is worth I'd think that since we are consuming the stream till the end, we should be disposing when we are done whether it is provided by a func producer or live instance.
There was a problem hiding this comment.
Not entirely related but Should we be taking a Func<IAsyncEnumerable> here? (In my opinion yes, in ideal-state, a Source itself should be idempotent and able to be materialized multiple times.)
Now that is a good question. We should absolutely program this component to accept this Func so we can restart the stream in the event of errors. That'll also make disposal of the IAsyncEnumerable less ambigious too: we created it, we own it, so we clean it up.
There was a problem hiding this comment.
There was a problem hiding this comment.
ty_IAsyncEnumerable_Is_Passed_In
Source: AsyncEnumerableSpec.cs line 163
Duration: 1.7 sec
Message:
Failed: Expected a message of type Akka.Streams.TestKit.TestSubscriber+OnComplete, but received {TestSubscriber.OnNext(21)} (type Akka.Streams.TestKit.TestSubscriber+OnNext`1[System.Int32]) instead from [akka://AsyncEnumerableSpec-1/user/StreamSupervisor-0/Flow-0-0-enumerableSource#1834516904]
Expected: True
Actual: False
Stack Trace:
XunitAssertions.Fail(String format, Object[] args) line 26
d__1361.MoveNext() line 455 --- End of stack trace from previous location where exception was thrown --- TaskAwaiter.ThrowForNonSuccess(Task task) TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) ValueTask1.get_Result()
ConfiguredValueTaskAwaiter.GetResult()
d__1351.MoveNext() line 421 --- End of stack trace from previous location where exception was thrown --- TaskAwaiter.ThrowForNonSuccess(Task task) TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) ValueTask1.get_Result()
ConfiguredValueTaskAwaiter.GetResult()
d__1331.MoveNext() line 389 --- End of stack trace from previous location where exception was thrown --- TaskAwaiter.ThrowForNonSuccess(Task task) TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) ValueTask1.get_Result()
ConfiguredValueTaskAwaiter.GetResult()
d__1311.MoveNext() line 367 --- End of stack trace from previous location where exception was thrown --- TaskAwaiter.ThrowForNonSuccess(Task task) TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) ValueTask1.get_Result()
ConfiguredValueTaskAwaiter.GetResult()
d__1151.MoveNext() line 52 --- End of stack trace from previous location where exception was thrown --- TaskAwaiter.ThrowForNonSuccess(Task task) TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) ValueTask1.get_Result()
ValueTaskAwaiter1.GetResult() <ExpectCompleteTask>d__85.MoveNext() line 117 --- End of stack trace from previous location where exception was thrown --- TaskAwaiter.ThrowForNonSuccess(Task task) TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) ConfiguredTaskAwaiter.GetResult() ManualProbe1.ExpectComplete(CancellationToken cancellationToken) line 186
AsyncEnumerableSpec.AsyncEnumerableSource_Must_Complete_Immediately_With_No_elements_When_An_Empty_IAsyncEnumerable_Is_Passed_In() line 182
Standard Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[DEBUG][7/16/2022 2:09:57 PM][Thread 0027][ActorSystem(AsyncEnumerableSpec-1)] System shutdown initiated
[DEBUG][7/16/2022 2:09:57 PM][Thread 0020][EventStream] Shutting down: StandardOutLogger started
[DEBUG][7/16/2022 2:09:57 PM][Thread 0020][EventStream] All default loggers stopped
|
the code in this PR is copied from @Horusiath Akka.Persistence.Pulsar - and while the copyright headers and licenses are identical to Akka.NET's we'll need to obtain his permission before proceeding. |
|
@Aaronontheweb @eaba I don't mind coping the code. Feel free to use it. |
|
thanks @Horusiath - we'll move forward with these changes then. |
|
Once this is merged we'll need to backport it to the |
|
Compilation error on Linux... |
|
Weird that we'd have that problem given that we already have |
|
Current test failures are unrelated to your PR I think - looks like mostly Akka.Persistence issues. |
| [Akka.Annotations.InternalApiAttribute()] | ||
| public sealed class AsyncEnumerable<T> : Akka.Streams.Stage.GraphStage<Akka.Streams.SourceShape<T>> | ||
| { | ||
| public AsyncEnumerable(System.Func<System.Collections.Generic.IAsyncEnumerable<T>> factory) { } |
| } | ||
| else | ||
| { | ||
| vtask.AsTask().ContinueWith(_handleContinuation); |
There was a problem hiding this comment.
This would probably be better with a local function that does await but we can refactor this later.
Changes
IAsyncEnumerable as a streams source