iter

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: MIT Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iter

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

Iter defines an iterator type that is returned by list methods. It's intended to be embedded in a domain specific iterator struct.

func NewIter

func NewIter(ctx context.Context, path string, params interface{}, query Query) Iter

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) Err

func (it *Iter) Err() error

Err returns any errors that occur during iteration.

func (*Iter) Item

func (it *Iter) Item() interface{}

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

func (*Iter) Next

func (it *Iter) 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 func(string) (ListResponse, []interface{}, 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