Documentation
¶
Index ¶
Constants ¶
View Source
const ( PaginationCursorItemAttribute = "pagination_cursor" // references the page cursor in the page record. PaginationKeyItemAttribute = "pagination_key" // references the last evaluated key in the page record. )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Getter ¶
type Getter interface {
Get(context.Context, *dynamodb.GetItemInput, ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, error)
}
Getter implements the DynamoDB client Get API.
type Pagination ¶
type Pagination struct {
Provider PaginationKeyProvider // The provider to manage the pagination table.
TimeToLiveAttribute string // The optional attribute that stores the TTL attribute.
Lifespan time.Duration // The optional lifespace of a page record. Default is 24 hours.
}
Pagination structs provide a way to generate and store pagination cursors within a DynamoDB table.
func NewPagination ¶
func NewPagination(provider PaginationKeyProvider, options ...func(*Pagination)) Pagination
NewPagination creates a new pagination instance.
func (Pagination) GetCursor ¶
func (p Pagination) GetCursor(ctx context.Context, lastEvaluatedKey Record, putter Putter, options ...func(*dynamodb.Options)) (string, error)
GetCursor generates a new page cursor from the last evaluated key that is returned from a DynamoDB query or scan. If the key is nil, then an empty string is returned.
type PaginationKeyProvider ¶
type PaginationKeyProvider interface {
// GenerateCursor generates a unique string that can be used by jsonapi clients
// for pagination.
GenerateCursor() string
// GetPaginationKeyInput returns a DynamoDB GetItemInput struct that must contain
// the following fields:
// - the table name
// - the record key associated with the provided cursor
GetPaginationKeyInput(cursor string) dynamodb.GetItemInput
// SetPaginationKeyInput returns a DynamoDB PutItemInput struct that must contain
// the following fields:
// - the table name
// - the partial record item associated with the provided cursor
SetPaginationKeyInput(cursor string) dynamodb.PutItemInput
}
PaginationKeyProvider is responsible for generating DynamoDB API input structs that allows the client to retrieve and store page records to a dynamodb table.
type Putter ¶
type Putter interface {
Put(context.Context, *dynamodb.PutItemInput, ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)
}
Putter implements the DynamoDB client Put API.
type Record ¶
type Record = map[string]types.AttributeValue
Record is a type alias for DynamoDB attribute value map.
Click to show internal directories.
Click to hide internal directories.