Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Paginator ¶
func Paginator[T any](ctx context.Context, listFunc ListFunc[T], processFunc ProcessFunc[T], rateLimitFunc RateLimitFunc, Opts *PaginatorOpts) ([]T, error)
Types ¶
type ListFunc ¶
type ListFunc[T any] interface { List(ctx context.Context, opt *github.ListOptions) ([]T, *github.Response, error) }
ListFunc is an interface that returns a list of items for the given type for example it could be:
type listFunc struct {
client *github.Client
}
func (l *listFunc) List(ctx context.Context, opt *github.ListOptions) ([]*github.Repository, *github.Response, error) {
t, r, err := l.client.Apps.ListRepos(ctx, opt)
return t.Repositories, r, err
}
type PaginatorOpts ¶
type PaginatorOpts struct {
*github.ListOptions
}
type ProcessFunc ¶
ProcessFunc is a function that processes an item for the given type this is optional as the user may not want to process the items so they can input a skip function that does nothing example:
type processFunc struct {
client *github.Client
}
func (p *processFunc) Process(ctx context.Context, item *github.Repository) error {
fmt.Println(item.GetName())
return nil
}
type RateLimitFunc ¶
type RateLimitFunc interface {
RateLimit(ctx context.Context, resp *github.Response) (bool, error)
}
RateLimitFunc is a function that handles rate limiting it returns a bool to indicate if the pagination should continue and an error if the users wishes to return more information/errors example:
type rateLimitFunc struct {
}
func (r *rateLimitFunc) RateLimit(ctx context.Context, resp *github.Response) (bool, error) {
return true, nil
}
Click to show internal directories.
Click to hide internal directories.