From 875761aa6942a44867c720cc05cad744551e7fef Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Fri, 7 Jul 2023 18:12:49 -0600 Subject: [PATCH] kgo Offset: add EpochOffset getter field There was no way to actually inspect what epoch or offset an Offset was at, which made some adjust functions less useful. --- pkg/kgo/consumer.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/kgo/consumer.go b/pkg/kgo/consumer.go index 094ca4cf..f516a06d 100644 --- a/pkg/kgo/consumer.go +++ b/pkg/kgo/consumer.go @@ -46,6 +46,15 @@ func (o Offset) String() string { } } +// EpochOffset returns this offset as an EpochOffset, allowing visibility into +// what this offset actually currently is. +func (o Offset) EpochOffset() EpochOffset { + return EpochOffset{ + Epoch: o.epoch, + Offset: o.at, + } +} + // NewOffset creates and returns an offset to use in ConsumePartitions or // ConsumeResetOffset. //