Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d0a959611d | |||
|
|
acb7fd2b11 | ||
| 5080a52834 | |||
| fe5d474f36 |
29
kgo.go
29
kgo.go
@@ -568,19 +568,22 @@ func (b *Broker) fnSubscribe(ctx context.Context, topic string, handler interfac
|
|||||||
messagePool: messagePool,
|
messagePool: messagePool,
|
||||||
}
|
}
|
||||||
|
|
||||||
kopts := append(b.kopts,
|
kopts := append(
|
||||||
kgo.ConsumerGroup(options.Group),
|
[]kgo.Opt{
|
||||||
kgo.ConsumeTopics(topic),
|
kgo.ConsumerGroup(options.Group),
|
||||||
kgo.ConsumeResetOffset(kgo.NewOffset().AtStart()),
|
kgo.ConsumeTopics(topic),
|
||||||
kgo.FetchMaxWait(1*time.Second),
|
kgo.ConsumeResetOffset(kgo.NewOffset().AtStart()),
|
||||||
kgo.AutoCommitInterval(commitInterval),
|
kgo.FetchMaxWait(1 * time.Second),
|
||||||
kgo.OnPartitionsAssigned(sub.assigned),
|
kgo.AutoCommitInterval(commitInterval),
|
||||||
kgo.OnPartitionsRevoked(sub.revoked),
|
kgo.OnPartitionsAssigned(sub.assigned),
|
||||||
kgo.StopProducerOnDataLossDetected(),
|
kgo.OnPartitionsRevoked(sub.revoked),
|
||||||
kgo.OnPartitionsLost(sub.lost),
|
kgo.StopProducerOnDataLossDetected(),
|
||||||
kgo.AutoCommitCallback(sub.autocommit),
|
kgo.OnPartitionsLost(sub.lost),
|
||||||
kgo.AutoCommitMarks(),
|
kgo.AutoCommitCallback(sub.autocommit),
|
||||||
kgo.WithHooks(sub),
|
kgo.AutoCommitMarks(),
|
||||||
|
kgo.WithHooks(sub),
|
||||||
|
},
|
||||||
|
b.kopts...,
|
||||||
)
|
)
|
||||||
|
|
||||||
if options.Context != nil {
|
if options.Context != nil {
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ func (s *Subscriber) poll(ctx context.Context) {
|
|||||||
c := s.consumers[tps]
|
c := s.consumers[tps]
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
if c != nil {
|
if c != nil {
|
||||||
c.recs <- newErrorFetchTopicPartition(kgo.ErrClientClosed, t, p)
|
c.recs <- newErrorFetchTopicPartition(err, t, p)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -199,7 +199,15 @@ func (s *Subscriber) revoked(ctx context.Context, c *kgo.Client, revoked map[str
|
|||||||
}
|
}
|
||||||
s.killConsumers(ctx, revoked)
|
s.killConsumers(ctx, revoked)
|
||||||
if err := c.CommitMarkedOffsets(ctx); err != nil {
|
if err := c.CommitMarkedOffsets(ctx); err != nil {
|
||||||
s.kopts.Logger.Error(ctx, "[kgo] revoked CommitMarkedOffsets error", err)
|
s.mu.Lock()
|
||||||
|
tpc := make(map[tp]*consumer, len(s.consumers))
|
||||||
|
maps.Copy(tpc, s.consumers)
|
||||||
|
s.mu.Unlock()
|
||||||
|
for tp, c := range tpc {
|
||||||
|
if c != nil {
|
||||||
|
c.recs <- newErrorFetchTopicPartition(err, tp.t, tp.p)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user