Are there any plans to implement prepared writes?
- Lenguaje dominante
- Go
- Estrellas
- 5.5k
- Forks
- 372
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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](https://github.com/gorilla/websocket) and [lxzan/gws](https://github.com/lxzan/gws/tree/main)). 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.
```Go
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)
}
}
````
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Comience revisando la API de escritura existente de websocket.Conn de la biblioteca y los puntos de entrada propuestos PrepareMessage y WritePrepared, y compare después el comportamiento citado de gorilla/websocket y lxzan/gws. Establezca la API, las interacciones con la compresión y el ciclo de vida de los mensajes antes de la implementación; se considera terminado cuando exista un diseño acordado que admita la reutilización para broadcasts idénticos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- go
- Área
- backend-api-design, networking
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100