IAsyncEnumerable分块大小节流和HttpResponse JSON的格式约定。

huangapple go评论69阅读模式
英文:

IAsyncEnumerable chunk-size throttle(s) and format conventions for HttpResponse JSON

问题

I have observed that if I increase the interval between my .NET C# Controller method Yields like: -

我观察到,如果我增加.NET C#控制器方法中Yields之间的间隔,如下所示:-

await Task.Delay(100); // Slow down the Demo

等待 Task.Delay(100); // 减慢演示速度

That each server yield corresponds 1:1 to a Javascript: -

每个服务器 yield 对应于 JavaScript:-

response.body.getReader() read()

response.body.getReader() read() 一对一对应

But at full-speed the results are buffered to "N" byte chunks of JSON.

但以全速运行时,结果被缓冲为 "N" 字节的 JSON 块。

EDIT 2

编辑 2

My question is:

我的问题是:

Can someone please provide an example or a link to the appropriate documentation of the correct way for Javascript to process a FETCH response from a C# .NET IASyncEnumerable controller method?

是否有人可以提供一个示例或链接,展示JavaScript正确处理来自C# .NET IASyncEnumerable控制器方法的FETCH响应的方法?

Thank you for reading.

谢谢阅读。

Final EDIT Please re-open for others

最终编辑 请重新打开以供其他人查看

My question is, how can I replicate the C# functionality afforded by: -

我的问题是,如何复制由以下提供的C#功能:-

JsonSerializer.DeserializeAsyncEnumerable

JsonSerializer.DeserializeAsyncEnumerable 提供的功能

an example of which can be found here, in Javascript?

JavaScript 中可以找到示例,示例在此处

英文:

I have observed that if I increase the interval between my .NET C# Controller method Yields like: -

   await Task.Delay(100);  // Slow down the Demo

That each server yield corresponds 1:1 to a Javascript: -

response.body.getReader()  read()

But at full-speed the results are buffered to "N" byte chunks of JSON.

EDIT 2

My question is:

Can someone please provide an example or a link to the appropriate documentation of the correct way for Javascript to process a FETCH response from a C# .NET IASyncEnumerable controller method?
Thank you for reading.

Final EDIT Please re-open for others

My question is, how can I replicate the C# functionality afforded by: -

JsonSerializer.DeserializeAsyncEnumerable

an example of which can be found here, in Javascript?

答案1

得分: 0

A SSCCE of the correct Javascript answer can be found in this Visual Studio Solution: ChunkIt

If you look at the pipeFactory you see that, unfortunately, Javascript programmers have to write our own iterator to handle tears in the JSON but the end result is more than worth it!

英文:

A SSCCE of the correct Javascript answer can be found in this Visual Studio Solution: ChunkIt

If you look at the pipeFactory you see that, unfortunately, Javascript programmers have to write our own iterator to handle tears in the JSON but the end result is more than worth it!

huangapple
  • 本文由 发表于 2023年5月30日 08:10:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76360924.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定