Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Are there any plans to implement prepared writes?

未关闭
#546 6 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
go

调研方向

首先审查库中现有的 websocket.Conn 写入 API 以及提议的 PrepareMessage 和 WritePrepared 入口点,然后比较所引用的 gorilla/websocket 和 lxzan/gws 的行为。在实现之前确定 API、压缩交互和消息生命周期;完成的标准是形成一个支持对相同广播进行复用的已达成一致的设计。

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

描述

I'm currently working on a websocket-based broadcasting server and would be more then happy to use this great library, but there is no prepared writes functionality, like in some other websocket libraries (e.g. gorilla/websocket and lxzan/gws). This would help a lot to optimize the broadcasting of identical messages. Are there any plans to implement this feature in some way (or accept PRs that implements it)?

I'm not sure how the API should look like, but it would be cool to have something similar.

var connections []*websocket.Conn

// Create prepared message without frames generation.
pm := websocket.PrepareMessage(websocket.MessageText, []byte("hello"))
defer pm.Close()

for _, c := range connections {
    // Lazily initialize frame buffer for "pm" and reuse it for other connections.
    // For each set of compression settings (mode and threshold), there will be separate pre-initialized frame
    // buffers, so if some connections don't have compression enabled and some do have, then two types of
    // frame buffers will be initialized for each of them.
	if err := c.WritePrepared(ctx, pm); err != nil {
		log.Printf("failed to write prepared message: %v\n", err)
	}
}
主要语言
Go
星标
5.5k
派生
377
PR 合并指标
30 天内没有已合并 PR

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

coder/websocket 的其他 Issue

查看 coder/websocket 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

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