token

package
v0.0.0-...-31c0fd8 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 8 Imported by: 0

README

An example implementation of using a continuation token for API paging

Inspired by:

To run...

# one session
docker-compose up

# another
go test

Possible improvements:

  • create a client/server with headers to indicate continuation token
  • play around with isolation levels in postgres transactions to expose possible phantom or nonrepeatable read

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Foo

type Foo struct {
	ID        int       `db:"id" json:"id"`
	Data      string    `db:"data" json:"data"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
}

Foo is the best data type

type FooPlusToken

type FooPlusToken struct {
	Foo       []Foo  `json:"foo"`
	LastToken string `json:"lastToken"`
	NewToken  string `json:"newToken"`
}

FooPlusToken is for serializing Foo and the token

type Token

type Token struct {
	// contains filtered or unexported fields
}

Token is a simple struct for the db and default limit

func NewToken

func NewToken() *Token

NewToken creates a Token instance

Jump to

Keyboard shortcuts

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