iter

package
v1.16.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iter

type Iter[T any] struct {
	// contains filtered or unexported fields
}

Iter defines an iterator type that list methods should return. The contained type should typically be a model that's returned in the results of a list method response.

func NewIter

func NewIter[T any](ctx context.Context, path string, params any, query Query[T]) *Iter[T]

NewIter returns a new initialized iterator. This method automatically makes the first query to populate the results. List methods should use this helper method when building domain specific iterators.

func (*Iter[T]) Err

func (it *Iter[T]) Err() error

Err returns any errors that occur during iteration.

func (*Iter[T]) Item

func (it *Iter[T]) Item() T

Item returns the result that the iterator is currently pointing to.

func (*Iter[T]) Next

func (it *Iter[T]) Next() bool

Next moves the iterator to the next result.

type ListResponse

type ListResponse interface {
	// NextPage returns a URL for retrieving the next page of list results.
	NextPage() string
}

ListResponse defines an interface that list API responses must implement.

type Query

type Query[T any] func(string) (ListResponse, []T, error)

Query defines a closure that domain specific iterators must implement. The implementation should include a call to the API and should return the API response with a separate slice of the results.

Jump to

Keyboard shortcuts

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