在Project Reactor中,我有一定数量的要以Mono格式进行的请求。为了不使目标服务不堪重负,我需要将请求数量限制为每秒最多X,并且要确保我最多有N个等待完成的未决请求。
时间限制部分很容易将通量中的Monos列表转换为public static void DownloadStream(MemoryStream inputStream, string filename)
{
byte[] bytes = inputStream.ToArray();
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
HttpContext.Current.Response.AddHeader("Content-Length", bytes.Length.ToString());
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.BinaryWrite(bytes);
HttpContext.Current.Response.End(); // This is the key
}
函数,但我想不出第二个必要条件。
如何限制等待完成的Mono的数量?