Skip to content
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

Add support for IAsyncEnumerable<TRequest> #804

Closed
iamxiaozhuang opened this issue Nov 23, 2022 · 5 comments
Closed

Add support for IAsyncEnumerable<TRequest> #804

iamxiaozhuang opened this issue Nov 23, 2022 · 5 comments
Labels

Comments

@iamxiaozhuang
Copy link

iamxiaozhuang commented Nov 23, 2022

I know MediatR provides a CreateStream method that returns IAsyncEnumerable with IResponse, but I am wondering if we can add support for IAsyncEnumerable with TRequest.
Because I'm working on a a MediatR-based RPC (Remote Procedure Calls) example. I need to implement some functionality for Client Stream/Bidirectional Stream, such as the GRPC framework.
Thank you.

@iamxiaozhuang iamxiaozhuang changed the title Add support for IAsyncEnumerable<TResquest> Add support for IAsyncEnumerable<TRequest> Nov 23, 2022
@jbogard
Copy link
Owner

jbogard commented Nov 28, 2022

Can the request type be IAsyncEnumerable directly?

@iamxiaozhuang
Copy link
Author

@jbogard
In GRPC, I can create a Bidirectional Stream method like this:
public async Task BidirectionalStream(IAsyncStreamReader<BidirectionalStreamRequest> requestStream, IServerStreamWriter<BidirectionalStreamResponse> responseStream, ServerCallContext context) { while (await requestStream.MoveNext()) { //todo } }
So I want to implement the same functionality in the MediatR Handler as follows:
public async IAsyncEnumerable<TestStreamResponse> Handle(IAsyncEnumerable<TestStreamRequest> request, CancellationToken cancellationToken) { await foreach (var item in request) { //todo } }

@jbogard
Copy link
Owner

jbogard commented Dec 7, 2022

Can your response type be the full async enumerable?

@github-actions
Copy link

github-actions bot commented Feb 6, 2023

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 6, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 14 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants