offset

package
v0.8.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeTotalLag

func ComputeTotalLag(src, dst map[int32]int64) int64

ComputeTotalLag computes the total offset lag across all partitions. For partitions missing from dst, the full source offset counts as lag.

func SortedPartitionIDs

func SortedPartitionIDs(src, dst map[int32]int64) []int32

SortedPartitionIDs returns the union of partition IDs from two offset maps, sorted ascending.

Types

type Provider added in v0.7.1

type Provider interface {
	GetMany(ctx context.Context, topics []string) (map[string]map[int32]int64, error)
}

Provider abstracts offset retrieval for testability.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service provides offset operations against a Kafka cluster.

func NewOffsetService

func NewOffsetService(client sarama.Client) *Service

NewOffsetService creates a Service backed by the given Kafka client.

func (*Service) Close

func (t *Service) Close() error

Close closes the underlying Kafka client.

func (*Service) Exists

func (t *Service) Exists(topic string) (bool, error)

Exists checks whether a topic exists on the cluster by refreshing metadata.

func (*Service) Get

func (t *Service) Get(ctx context.Context, topic string) (map[int32]int64, error)

Get fetches the log end offset (LEO) for every partition of a topic. It is a single-topic wrapper over GetMany kept for the package tests and the offsetbench loop-vs-batch contrast; production sweeps call GetMany, which costs one request per broker instead of one per topic.

func (*Service) GetMany added in v0.8.8

func (t *Service) GetMany(ctx context.Context, topics []string) (map[string]map[int32]int64, error)

GetMany fetches the log end offset (LEO) for every partition of every topic in a single sweep. Partitions are grouped by leader broker across all topics and one ListOffsets request is sent per broker (concurrently), so a sweep of N topics costs one round trip instead of N.

Partitions that fail because cached metadata went stale mid-sweep (leader moved, replica unavailable, or the cached leader broker unreachable) are retried once against refreshed metadata before the sweep fails.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL