good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 4bfe0e9b authored by Anmol Sethi's avatar Anmol Sethi
Browse files

Document wspb and wsjson buffer reuse

See #71
parent 76d3a107
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,8 @@ import (
)
// Read reads a json message from c into v.
// If the message is larger than 128 bytes, it will use a buffer
// from a pool instead of performing an allocation.
func Read(ctx context.Context, c *websocket.Conn, v interface{}) error {
err := read(ctx, c, v)
if err != nil {
......@@ -39,6 +41,7 @@ func read(ctx context.Context, c *websocket.Conn, v interface{}) error {
}
// Write writes the json message v to c.
// It uses json.Encoder which automatically reuses buffers.
func Write(ctx context.Context, c *websocket.Conn, v interface{}) error {
err := write(ctx, c, v)
if err != nil {
......
......@@ -11,6 +11,7 @@ import (
)
// Read reads a protobuf message from c into v.
// It will reuse buffers to avoid allocations.
func Read(ctx context.Context, c *websocket.Conn, v proto.Message) error {
err := read(ctx, c, v)
if err != nil {
......@@ -39,6 +40,7 @@ func read(ctx context.Context, c *websocket.Conn, v proto.Message) error {
}
// Write writes the protobuf message v to c.
// It will reuse buffers to avoid allocations.
func Write(ctx context.Context, c *websocket.Conn, v proto.Message) error {
err := write(ctx, c, v)
if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment