Skip to content

Commit

Permalink
bug: incorrect parallel loop usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Wil Simpson committed Dec 11, 2024
1 parent 4f9eea1 commit 2c63bb4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/bus/bus_kafka_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (k *kafkaBusReader[T]) Reset(ctx context.Context) error {
log.Logger.WithContext(ctx).WithField("func", "Bus Reset").Infof("Getting offsets for %d partitions", len(partitions))
for _, partition := range partitions {
wg.Add(1)
go func() {
go func(partition kafka.Partition) {
defer wg.Done()
leaderAddr := fmt.Sprintf("%s:%d", partition.Leader.Host, partition.Leader.Port)
c, err := kafka.DialLeader(ctx, "tcp", leaderAddr, k.topic, partition.ID)
Expand All @@ -139,7 +139,7 @@ func (k *kafkaBusReader[T]) Reset(ctx context.Context) error {
offsetMu.Lock()
offsets[partition.ID] = offset
offsetMu.Unlock()
}()
}(partition)
}

// Wait for all the offsets to be read
Expand Down

0 comments on commit 2c63bb4

Please sign in to comment.