Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config[In comparable, Out any] struct { // Fetch is a method that provides the data for the loader Fetch func(keys []In) ([]Out, []error) // Wait is how long wait before sending a batch Wait time.Duration // MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit MaxBatch int }
type DataLoader ¶
type DataLoader[In comparable, Out any] struct { // contains filtered or unexported fields }
func New ¶
func New[In comparable, Out any](config Config[In, Out]) *DataLoader[In, Out]
func (*DataLoader[In, Out]) Load ¶
func (l *DataLoader[In, Out]) Load(key In) (Out, error)
Load a string by key, batching and caching will be applied automatically
func (*DataLoader[In, Out]) LoadAll ¶
func (l *DataLoader[In, Out]) LoadAll(keys []In) ([]Out, []error)
LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured
func (*DataLoader[In, Out]) LoadAllThunk ¶
func (l *DataLoader[In, Out]) LoadAllThunk(keys []In) func() ([]Out, []error)
LoadAllThunk returns a function that when called will block waiting for a strings. This method should be used if you want one goroutine to make requests to many different data loaders without blocking until the thunk is called.
func (*DataLoader[In, Out]) LoadThunk ¶
func (l *DataLoader[In, Out]) LoadThunk(key In) func() (Out, error)
LoadThunk returns a function that when called will block waiting for a string. This method should be used if you want one goroutine to make requests to many different data loaders without blocking until the thunk is called.