Offset returns the current absolute offset of the reader, or -1 if r is backed by a consumer group.
()
| 988 | // Offset returns the current absolute offset of the reader, or -1 |
| 989 | // if r is backed by a consumer group. |
| 990 | func (r *Reader) Offset() int64 { |
| 991 | if r.useConsumerGroup() { |
| 992 | return -1 |
| 993 | } |
| 994 | |
| 995 | r.mutex.Lock() |
| 996 | offset := r.offset |
| 997 | r.mutex.Unlock() |
| 998 | r.withLogger(func(log Logger) { |
| 999 | log.Printf("looking up offset of kafka reader for partition %d of %s: %s", r.config.Partition, r.config.Topic, toHumanOffset(offset)) |
| 1000 | }) |
| 1001 | return offset |
| 1002 | } |
| 1003 | |
| 1004 | // Lag returns the lag of the last message returned by ReadMessage, or -1 |
| 1005 | // if r is backed by a consumer group. |