paginate

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultPaginatedQuerySize = 1000

Variables

This section is empty.

Functions

This section is empty.

Types

type Paginator

type Paginator struct {

	// Max number of documents to get. Defaults to DefaultPaginatedQuerySize, and must be a value less than 100,000
	PageSize int
	// contains filtered or unexported fields
}

func New

func New(rc RockClient) *Paginator

New creates a new Paginator with PageSize set to DefaultPaginatedQuerySize

func (Paginator) GetQueryResults added in v0.22.5

func (p Paginator) GetQueryResults(ctx context.Context, documentCh chan<- map[string]any, queryID string) error

GetQueryResults gets all query results from the previously executed query with queryID, and sends the result to the document channel, which is closed once everything has been retrieved.

func (Paginator) Query

func (p Paginator) Query(ctx context.Context, documentCh chan<- map[string]any, sql string, options ...option.QueryOption) error

Query executes a query and blocks until it has retrieved all results using pagination and sent them to the document channel, which is closed when all documents have been sent. This sets option.WithMaxInitialResults(DefaultPaginatedQuerySize), which is also used to fetch the paginated results using the GetQueryResults(), but it can be overridden by setting the PageSize on the Paginator.

type RockClient

type RockClient interface {
	Query(ctx context.Context, sql string, options ...option.QueryOption) (openapi.QueryResponse, error)
	GetQueryResults(ctx context.Context, queryID string, options ...option.QueryResultOption) (openapi.QueryPaginationResponse, error)
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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