Compare commits

...

4 Commits

Author SHA1 Message Date
d0a959611d Merge pull request 'correction create opts' (#160) from devstigneev/micro-broker-kgo:fix_opts into v4
Some checks failed
coverage / build (push) Failing after 3m15s
test / test (push) Failing after 17m25s
sync / sync (push) Failing after 20s
Reviewed-on: #160
2026-01-30 09:58:17 +03:00
Evstigneev Denis
acb7fd2b11 correction create opts
Some checks failed
coverage / build (pull_request) Failing after 2m25s
test / test (pull_request) Failing after 4m35s
lint / lint (pull_request) Failing after 4m43s
2026-01-30 09:52:41 +03:00
5080a52834 fixup revoked error
Some checks failed
test / test (push) Failing after 12m26s
coverage / build (push) Failing after 18m17s
sync / sync (push) Failing after 51s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-12-02 21:50:53 +03:00
fe5d474f36 fixup error
Some checks failed
coverage / build (push) Has been cancelled
test / test (push) Has been cancelled
sync / sync (push) Successful in 11s
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2025-12-02 21:46:03 +03:00
2 changed files with 26 additions and 15 deletions

29
kgo.go
View File

@@ -568,19 +568,22 @@ func (b *Broker) fnSubscribe(ctx context.Context, topic string, handler interfac
messagePool: messagePool,
}
kopts := append(b.kopts,
kgo.ConsumerGroup(options.Group),
kgo.ConsumeTopics(topic),
kgo.ConsumeResetOffset(kgo.NewOffset().AtStart()),
kgo.FetchMaxWait(1*time.Second),
kgo.AutoCommitInterval(commitInterval),
kgo.OnPartitionsAssigned(sub.assigned),
kgo.OnPartitionsRevoked(sub.revoked),
kgo.StopProducerOnDataLossDetected(),
kgo.OnPartitionsLost(sub.lost),
kgo.AutoCommitCallback(sub.autocommit),
kgo.AutoCommitMarks(),
kgo.WithHooks(sub),
kopts := append(
[]kgo.Opt{
kgo.ConsumerGroup(options.Group),
kgo.ConsumeTopics(topic),
kgo.ConsumeResetOffset(kgo.NewOffset().AtStart()),
kgo.FetchMaxWait(1 * time.Second),
kgo.AutoCommitInterval(commitInterval),
kgo.OnPartitionsAssigned(sub.assigned),
kgo.OnPartitionsRevoked(sub.revoked),
kgo.StopProducerOnDataLossDetected(),
kgo.OnPartitionsLost(sub.lost),
kgo.AutoCommitCallback(sub.autocommit),
kgo.AutoCommitMarks(),
kgo.WithHooks(sub),
},
b.kopts...,
)
if options.Context != nil {

View File

@@ -123,7 +123,7 @@ func (s *Subscriber) poll(ctx context.Context) {
c := s.consumers[tps]
s.mu.Unlock()
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)
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)
}
}
}
}