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

Fix go vet issues: example tests, returning a mutex copy #783

Merged
merged 3 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions example_consumergroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/segmentio/kafka-go"
)

func ExampleConsumerGroupParallelReaders() {
func ExampleGeneration_Start_consumerGroupParallelReaders() {
group, err := kafka.NewConsumerGroup(kafka.ConsumerGroupConfig{
ID: "my-group",
Brokers: []string{"kafka:9092"},
Expand Down Expand Up @@ -60,7 +60,7 @@ func ExampleConsumerGroupParallelReaders() {
}
}

func ExampleConsumerGroupOverwriteOffsets() {
func ExampleGeneration_CommitOffsets_overwriteOffsets() {
group, err := kafka.NewConsumerGroup(kafka.ConsumerGroupConfig{
ID: "my-group",
Brokers: []string{"kafka:9092"},
Expand Down
10 changes: 5 additions & 5 deletions example_groupbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"time"
)

// ExampleAWSRackLocal shows how the RackAffinityGroupBalancer can be used to
// pair up consumers with brokers in the same AWS availability zone. This code
// assumes that each brokers' rack is configured to be the name of the AZ in
// which it is running.
func ExampleAWSRackLocal() {
// ExampleNewReader_rackAffinity shows how the RackAffinityGroupBalancer can be
// used to pair up consumers with brokers in the same AWS availability zone.
// This code assumes that each brokers' rack is configured to be the name of the
// AZ in which it is running.
func ExampleNewReader_rackAffinity() {
r := NewReader(ReaderConfig{
Brokers: []string{"kafka:9092"},
GroupID: "my-group",
Expand Down
8 changes: 5 additions & 3 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,8 @@ func (w *Writer) chooseTopic(msg Message) (string, error) {
type batchQueue struct {
queue []*writeBatch

mutex sync.Mutex
cond sync.Cond
mutex *sync.Mutex
cond *sync.Cond

closed bool
}
Expand Down Expand Up @@ -915,9 +915,11 @@ func (b *batchQueue) Close() {
func newBatchQueue(initialSize int) batchQueue {
bq := batchQueue{
queue: make([]*writeBatch, 0, initialSize),
mutex: &sync.Mutex{},
cond: &sync.Cond{},
}

bq.cond.L = &bq.mutex
bq.cond.L = bq.mutex

return bq
}
Expand Down