02-18-2021, 07:22 AM
So this is gonna be another one of my late night threads, and not really a tutorial, be warned.
Have you ever had to deliver a HUGE list of JSON objects, and hate the latency? Well this is your solution. Here's a bit of code:
Ok, why did I just give you all that code? Well, the answer is HTTP/2. There's no reason you can't async stream your responses with .net5, and that's required to do it. Here's a real world example:
Is the exception BS really necessary? no. but its in my code.
Alright, so what does this do?
well, on its own, nothing. However, if you understand IAsyncEnumerable and its applications in your code, you will be delighted to know that this is the network equivalent. However, on its own, it's useless. HttpClient will buffer the data and receive it as normal. But lets say you want that stream to be available as an async enumerable or equivalent? Well, here's my client code:
And....this is (for now) presented without comment. Enjoy.
Have you ever had to deliver a HUGE list of JSON objects, and hate the latency? Well this is your solution. Here's a bit of code:
Hidden Content
Ok, why did I just give you all that code? Well, the answer is HTTP/2. There's no reason you can't async stream your responses with .net5, and that's required to do it. Here's a real world example:
Hidden Content
Is the exception BS really necessary? no. but its in my code.
Alright, so what does this do?
well, on its own, nothing. However, if you understand IAsyncEnumerable and its applications in your code, you will be delighted to know that this is the network equivalent. However, on its own, it's useless. HttpClient will buffer the data and receive it as normal. But lets say you want that stream to be available as an async enumerable or equivalent? Well, here's my client code:
Hidden Content
And....this is (for now) presented without comment. Enjoy.