Feature Proposal: report progress writing to sockets

未关闭
#3,773 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

@reardonj 已经在做这个了。

开始于 2026年10月8日。

  • #3776 来自 @reardonj —— 未关闭

评估

难度
5/5
预计耗时
一周以上
新手友好度
45/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
scala
领域
networking

调研方向

Start by reading the Stream trait and locating the fs2 socket implementations that write incrementally. Review how default implementations can preserve bincompat and where each subclass would need an override; the work is done when socket writes report incremental progress through both proposed APIs.

由索引模型根据 Issue 内容生成。

描述

https://github.com/http4s/http4s/issues/7824 reports that spurious http4s timeouts occur writing very large chunks to a socket. The fs2 socket implementations (all?) actually write to the socket incrementally, but do not provide any indication to the caller that they are making progress.

This could take the form of two new methods on the Stream trait:

  /** Writes `bytes` to the peer, reporting as bytes are written.
    *
    * Completes when the bytes are written to the socket.
    */
  def writeProgress(bytes: Chunk[Byte]): Stream[F, Int] =
    Stream.eval(write(bytes)) >> Stream(bytes.size)

  /** Writes the supplied stream of bytes to this socket via `writeProgress` semantics.
    */
  def writesProgress: Pipe[F, Byte, Int] = s => s.chunks.flatMap(writeProgress)

By returning a stream of their progress, a caller can implement a timeout that only triggers if individual writes to the underlying socket take too long.

Unfortunately, default implementations must be provided to preserve bincompat. The writesProgress implementation would work in general, but writeProgress would need a useful override in each subclass to report incremental progress.

主要语言
Scala
星标
2.5k
派生
633
平均合并
3 天 21 小时
30 天内合并 PR
13

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

typelevel/fs2 的其他 Issue

查看 typelevel/fs2 的全部 Issue

相似的 Issue

更多 Scala Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。