Documentation
¶
Index ¶
- func NewClient(base http.RoundTripper, opts ...Option) *http.Client
- func WithOverrideConfig(ctx context.Context, opts ...Option) context.Context
- type Async
- func (a *Async[DataType]) HandleError(resp *http.Response, err error)
- func (a *Async[DataType]) HandleFinish(resp *http.Response, pageCount int)
- func (a *Async[DataType]) HandlePage(data *searchresult.Typed[DataType], resp *http.Response) error
- func (a *Async[DataType]) Paginate(requestFn any, args ...any) error
- type Config
- func (c *Config) ApplyOptions(opts ...Option)
- func (c *Config) GetContextedConfig(ctx context.Context) *Config
- func (c *Config) GetDriver() PaginationDriver
- func (c *Config) GetRequestConfig(request *http.Request) *Config
- func (c *Config) IsPaginationOverflow(pageCount int) bool
- func (c *Config) UpdateRequest(request *http.Request) *http.Request
- type ConfigOverridesKey
- type GitHubPagination
- type OnNextResponse
- type OnNextResponseSlice
- type Option
- type PaginationDriver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Async ¶
type Async[DataType any] struct { OnNext OnNextResponse[DataType] // contains filtered or unexported fields }
func NewAsync ¶
func NewAsync[DataType any](onNext OnNextResponseSlice[DataType]) *Async[DataType]
NewAsync creates a new Async instance for non-search results. Note: you can use this with search results, but the incomplete_results and total_count fields will not be available.
func NewAsyncSearch ¶
func NewAsyncSearch[DataType any](onNext OnNextResponse[DataType]) *Async[DataType]
NewAsyncSearch creates a new Async instance for search results. It is designed to be used with search results, so that the incomplete_results and total_count fields are available.
func (*Async[DataType]) HandleError ¶
func (*Async[DataType]) HandleFinish ¶
func (*Async[DataType]) HandlePage ¶
type Config ¶
type Config struct {
Disabled bool
DefaultPerPage int
MaxNumOfPages int
Driver PaginationDriver
}
func (*Config) ApplyOptions ¶
ApplyOptions applies the options to the config.
func (*Config) GetContextedConfig ¶
GetContextedConfig returns the config overrides from the context, if any.
func (*Config) GetDriver ¶
func (c *Config) GetDriver() PaginationDriver
func (*Config) GetRequestConfig ¶
GetRequestConfig returns the config overrides from the request context, if any.
func (*Config) IsPaginationOverflow ¶
type ConfigOverridesKey ¶
type ConfigOverridesKey struct{}
type GitHubPagination ¶
type GitHubPagination struct {
Base http.RoundTripper
// contains filtered or unexported fields
}
func New ¶
func New(base http.RoundTripper, opts ...Option) *GitHubPagination
type OnNextResponse ¶
type OnNextResponseSlice ¶
type Option ¶
type Option func(*Config)
func GetConfigOverrides ¶
GetConfigOverrides returns the config overrides from the context, if any.
func WithDriver ¶
WithDriver sets the driver for paginated requests. Available drivers out-of-the-box: - sync (default): handle pagination synchronously. - raw_async: handle pagination asynchronously using raw HTTP requests/responses. - async: handle pagination asynchronously with github orientation.
func WithMaxNumOfPages ¶
WithMaxNumOfPages sets the maximum number of pages for paginated requests. This enables the client to limit the number of pages to be fetched.
func WithPaginationDisabled ¶
func WithPaginationDisabled() Option
WithPaginationDisabled disables the pagination for paginated requests. This may be used to override a previous WithPaginationEnabled option, e.g., on a per-request basis.
func WithPaginationEnabled ¶
func WithPaginationEnabled() Option
WithPaginationEnabled enables the pagination for paginated requests. This is the default behavior. This may be used to override a previous WithPaginationDisabled option, e.g., on a per-request basis.
func WithPerPage ¶
WithPerPage sets the default per-page value for paginated requests.