Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateIndexGetter ¶
type CreateIndexGetter interface {
GetCreateIndex() uint64
}
CreateIndexGetter is the interface that must be implemented by structs that need to have their CreateIndex as part of the pagination token.
type Filter ¶
type Filter interface { // Evaluate returns true if the element should be added to the page. Evaluate(interface{}) (bool, error) }
Filter is the interface that must be implemented to skip values when using the Paginator.
type GenericFilter ¶
GenericFilter wraps a function that can be used to provide simple or in scope filtering.
func (GenericFilter) Evaluate ¶
func (f GenericFilter) Evaluate(raw interface{}) (bool, error)
type IDGetter ¶
type IDGetter interface {
GetID() string
}
IDGetter is the interface that must be implemented by structs that need to have their ID as part of the pagination token.
type Iterator ¶
type Iterator interface { // Next returns the next element to be considered for pagination. // The page will end if nil is returned. Next() interface{} }
Iterator is the interface that must be implemented to supply data to the Paginator.
type NamespaceFilter ¶
NamespaceFilter skips elements with a namespace value that is not in the allowable set.
func (NamespaceFilter) Evaluate ¶
func (f NamespaceFilter) Evaluate(raw interface{}) (bool, error)
type NamespaceGetter ¶
type NamespaceGetter interface {
GetNamespace() string
}
NamespaceGetter is the interface that must be implemented by structs that need to have their Namespace as part of the pagination token.
type Paginator ¶
type Paginator struct {
// contains filtered or unexported fields
}
Paginator wraps an iterator and returns only the expected number of pages.
func NewPaginator ¶
func NewPaginator(iter Iterator, tokenizer Tokenizer, filters []Filter, opts structs.QueryOptions, appendFunc func(interface{}) error) (*Paginator, error)
NewPaginator returns a new Paginator. Any error creating the paginator is due to bad user filter input, RPC functions should therefore return a 400 error code along with an appropriate message.
type StructsTokenizer ¶
type StructsTokenizer struct {
// contains filtered or unexported fields
}
StructsTokenizer is an pagination token generator that can create different formats of pagination tokens based on common fields found in the structs package.
func NewStructsTokenizer ¶
func NewStructsTokenizer(_ Iterator, opts StructsTokenizerOptions) StructsTokenizer
NewStructsTokenizer returns a new StructsTokenizer.
func (StructsTokenizer) GetToken ¶
func (it StructsTokenizer) GetToken(raw interface{}) string
type StructsTokenizerOptions ¶
StructsTokenizerOptions is the configuration provided to a StructsTokenizer.
These are some of the common use cases:
Structs that can be uniquely identified with only its own ID:
StructsTokenizerOptions { WithID: true, }
Structs that are only unique within their namespace:
StructsTokenizerOptions { WithID: true, WithNamespace: true, }
Structs that can be sorted by their create index should also set `WithCreateIndex` to `true` along with the other options:
StructsTokenizerOptions { WithID: true, WithNamespace: true, WithCreateIndex: true, }