Documentation
¶
Overview ¶
Package dataloader provides a generic per-request batch loader. The Loader accumulates keys from concurrent Load calls that arrive within a short window and fires one fetch per window, distributing results back to all waiters. This is the standard gqlgen dataloader pattern.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Loader ¶
type Loader[K comparable, V any] struct { // contains filtered or unexported fields }
Loader batches concurrent Load calls into one fetch call. K is the key type and V is the value type. The zero value is not usable; construct with New.
func New ¶
func New[K comparable, V any](fetch func(context.Context, []K) (map[K]V, error), wait time.Duration) *Loader[K, V]
New returns a Loader that coalesces Load calls arriving within wait into a single fetch call.
Click to show internal directories.
Click to hide internal directories.