Skip to content
Closed
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
34 changes: 34 additions & 0 deletions pkg/kgo/ring_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,43 @@
package kgo

import (
"context"
"fmt"
"sync/atomic"
"testing"
"time"
)

func TestPromises(t *testing.T) {

Check failure on line 11 in pkg/kgo/ring_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint-root on amd64

unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive)
ctx := context.Background()
cl, err := NewClient()
if err != nil {
panic(err)
}

var promised atomic.Int64
var finished atomic.Int64

p := &cl.producer
for range 8 {
go func() {
for {
promise := func(*Record, error) {
finished.Add(1)
}
r := new(Record)
p.promiseRecordBeforeBuf(promisedRec{ctx, promise, r}, ErrMaxBuffered)
promised.Add(1)
}
}()
}

for {
fmt.Println("promised", promised.Load(), "finished", finished.Load())
time.Sleep(time.Second)
}
}

func TestRing(t *testing.T) {
t.Run("push multiple elements and then drop them", func(t *testing.T) {
r := &ring[int]{}
Expand Down
Loading