Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporter - avoid sending to non-responsive connections #483

Merged
merged 1 commit into from
Dec 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions exporter/api/broadcaster_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package api

import (
"context"
"fmt"
"github.com/prysmaticlabs/prysm/async/event"
"github.com/stretchr/testify/require"
Expand All @@ -10,6 +11,15 @@ import (
"time"
)

func TestConn_Send_FullQueue(t *testing.T) {
logger := zaptest.NewLogger(t)
c := newConn(context.Background(), logger, nil, "test", 0)

for i := 0; i < chanSize+2; i++ {
c.Send([]byte(fmt.Sprintf("test-%d", i)))
}
}

func TestBroadcaster(t *testing.T) {
logger := zaptest.NewLogger(t)
b := newBroadcaster(logger)
Expand Down
4 changes: 4 additions & 0 deletions exporter/api/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ func (c *conn) ReadNext() []byte {

// Send sends the given message
func (c *conn) Send(msg []byte) {
if len(c.send) >= chanSize {
// don't send on full channel
return
}
c.send <- msg
}

Expand Down