checkpoint

package
v3.65.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package checkpoint implements a mechanism for tracking checkpointed integer offsets for sequential read at-least-once queue systems such as Kafka or Kinesis.

Index

Constants

This section is empty.

Variables

View Source
var ErrOutOfSync = errors.New("provided offset was out of sync")

ErrOutOfSync is returned when an offset to be tracked is less than or equal to the current highest tracked offset.

View Source
var ErrResolvedOffsetNotTracked = errors.New("resolved offset was not tracked")

ErrResolvedOffsetNotTracked is returned when an offset to be resolved has not been tracked (or was already resolved).

Functions

This section is empty.

Types

type Type

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

Type receives an ordered feed of integer based offsets being tracked, and an unordered feed of integer based offsets that are resolved, and is able to return the highest offset currently able to be committed such that an unresolved offset is never committed.

WARNING: DEPRECATED TODO: V4 Remove this

func New

func New(base int) *Type

New returns a new checkpointer from a base offset, which is the value returned when no checkpoints have yet been resolved. The base can be zero.

func (*Type) Highest

func (t *Type) Highest() int

Highest returns the current highest checkpoint.

func (*Type) MustResolve

func (t *Type) MustResolve(offset int) int

MustResolve is the same as Resolve but panics instead of returning an error.

func (*Type) MustTrack

func (t *Type) MustTrack(i int)

MustTrack is the same as Track but panics instead of returning an error.

func (*Type) Pending added in v3.36.0

func (t *Type) Pending() int

Pending returns the number of pending checkpoints.

func (*Type) Resolve

func (t *Type) Resolve(offset int) (int, error)

Resolve a tracked offset by allowing it to be committed. The highest possible offset to be committed is returned, or an error if the provided offset was not recognised.

func (*Type) Track

func (t *Type) Track(i int) error

Track a new unresolved integer offset. This offset will be cached until it is marked as resolved. While it is cached no higher valued offset will ever be committed. If the provided value is lower than an already provided value an error is returned.

Jump to

Keyboard shortcuts

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