pagers

package
v0.0.0-...-880cb89 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddedAndRemovedAddAll

func AddedAndRemovedAddAll[T any](
	items []T,
	filters ...func(T) bool,
) (map[string]time.Time, []string, error)

AddedAndRemovedAddAll indiscriminately adds every item to the added list, deleting nothing.

func AddedAndRemovedByAddtlData

func AddedAndRemovedByAddtlData[T any](
	items []T,
	filters ...func(T) bool,
) (map[string]time.Time, []string, error)

func AddedAndRemovedByDeletedDateTime

func AddedAndRemovedByDeletedDateTime[T any](
	items []T,
	filters ...func(T) bool,
) (map[string]time.Time, []string, error)

func BatchEnumerateItems

func BatchEnumerateItems[T any](
	ctx context.Context,
	pager NonDeltaHandler[T],
) ([]T, error)

func DeltaEnumerateItems

func DeltaEnumerateItems[T any](
	ctx context.Context,
	pager DeltaHandler[T],
	npr *nextPageResults[T],
	prevDeltaLink string,
)

enumerates pages of items, streaming each page to the provided channel. the DeltaUpdate, reset notifications, and any errors are also fed to the same channel.

func EnumerateItems

func EnumerateItems[T any](
	ctx context.Context,
	pager NonDeltaHandler[T],
	npr *nextPageResults[T],
)

func FilterIncludeAll

func FilterIncludeAll[T any](_ T) bool

func IsNextLinkValid

func IsNextLinkValid(next string) bool

IsNextLinkValid separate check to investigate whether error is

func NewNextPageResults

func NewNextPageResults[T any]() *nextPageResults[T]
func NextAndDeltaLink(pl DeltaLinker) (string, string)
func NextLink(pl NextLinker) string

Types

type AddedAndRemoved

type AddedAndRemoved struct {
	Added         map[string]time.Time
	Removed       []string
	DU            DeltaUpdate
	ValidModTimes bool
}

func GetAddedAndRemovedItemIDs

func GetAddedAndRemovedItemIDs[T any](
	ctx context.Context,
	pager NonDeltaHandler[T],
	deltaPager DeltaHandler[T],
	prevDeltaLink string,
	canMakeDeltaQueries bool,
	itemLimit int,
	aarh addedAndRemovedHandler[T],
	filters ...func(T) bool,
) (AddedAndRemoved, error)

GetAddedAndRemovedItemIDs returns the set of item IDs that were added or removed from this resource since the last delta query. If no delta query is passed in then returns all items found, not just changed/removed ones.

Use itemLimit to stop enumeration partway through and filters to pick which items should be returned.

type DeltaHandler

type DeltaHandler[T any] interface {
	GetPager[DeltaLinkValuer[T]]
	Resetter
	SetNextLinker
	ValidModTimer
}

type DeltaLinkValuer

type DeltaLinkValuer[T any] interface {
	DeltaLinker
	Valuer[T]
}

type DeltaLinker

type DeltaLinker interface {
	NextLinker
	GetOdataDeltaLink() *string
}

type DeltaUpdate

type DeltaUpdate struct {
	// the deltaLink itself
	URL string
	// true if the old delta was marked as invalid
	Reset bool
}

DeltaUpdate holds the results of a current delta token. It normally gets produced when aggregating the addition and removal of items in a delta-queryable folder.

type GetPager

type GetPager[T any] interface {
	GetPage(context.Context) (T, error)
}

type NextLinkValuer

type NextLinkValuer[T any] interface {
	NextLinker
	Valuer[T]
}

type NextLinker

type NextLinker interface {
	GetOdataNextLink() *string
}

type NextPageResulter

type NextPageResulter[T any] interface {
	NextPager[T]

	Cancel()
	Results() (DeltaUpdate, error)
}

type NextPager

type NextPager[T any] interface {
	// reset should only true on the iteration where the delta pager's Reset()
	// is called.  Callers can use it to reset any data aggregation they
	// currently use.  After that loop it can be false again, though the
	// DeltaUpdate will eventually contain the expected reset value.
	// Items may or may not be >0 when reset == true.  In that case, the
	// items should always represent the next page of data following a reset.
	// Callers should always handle the reset first, and follow-up with
	// item population.
	NextPage() (items []T, reset, done bool)
}

type NonDeltaHandler

type NonDeltaHandler[T any] interface {
	GetPager[NextLinkValuer[T]]
	SetNextLinker
	ValidModTimer
}

type Resetter

type Resetter interface {
	Reset(context.Context)
}

type SetNextLinker

type SetNextLinker interface {
	SetNextLink(nextLink string)
}

type ValidModTimer

type ValidModTimer interface {
	ValidModTimes() bool
}

type Valuer

type Valuer[T any] interface {
	GetValue() []T
}

Jump to

Keyboard shortcuts

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