Documentation
¶
Index ¶
- func Generate(sqlcManifestPath string, outputDir string)
- type Dataloader
- func NewDataloader[TKey comparable, TResult any](ctx context.Context, maxBatchSize int, batchTimeout time.Duration, ...) *Dataloader[TKey, TResult]
- func NewDataloaderWithNonComparableKey[TKey any, TResult any](ctx context.Context, maxBatchSize int, batchTimeout time.Duration, ...) *Dataloader[TKey, TResult]
- func (d *Dataloader[TKey, TResult]) Load(key TKey) (TResult, error)
- func (d *Dataloader[TKey, TResult]) LoadAll(keys []TKey) ([]TResult, []error)
- func (d *Dataloader[TKey, TResult]) LoadAllThunk(keys []TKey) func() ([]TResult, []error)
- func (d *Dataloader[TKey, TResult]) LoadThunk(key TKey) func() (TResult, error)
- func (d *Dataloader[TKey, TResult]) Prime(key TKey, result TResult)
- func (d *Dataloader[TKey, TResult]) RegisterResultSubscriber(subscriber func(TResult))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dataloader ¶
Dataloader is a thin wrapper around the Batcher type that provides idiomatic dataloader function names (i.e. "Load" instead of "Do")
func NewDataloader ¶
func (*Dataloader[TKey, TResult]) Load ¶
func (d *Dataloader[TKey, TResult]) Load(key TKey) (TResult, error)
Load a TResult by key, batching and caching will be applied automatically
func (*Dataloader[TKey, TResult]) LoadAll ¶
func (d *Dataloader[TKey, TResult]) LoadAll(keys []TKey) ([]TResult, []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[TKey, TResult]) LoadAllThunk ¶
func (d *Dataloader[TKey, TResult]) LoadAllThunk(keys []TKey) func() ([]TResult, []error)
LoadAllThunk returns a function that when called will block waiting for results. 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[TKey, TResult]) LoadThunk ¶
func (d *Dataloader[TKey, TResult]) LoadThunk(key TKey) func() (TResult, error)
LoadThunk returns a function that when called will block waiting for a TResult. 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[TKey, TResult]) Prime ¶
func (d *Dataloader[TKey, TResult]) Prime(key TKey, result TResult)
func (*Dataloader[TKey, TResult]) RegisterResultSubscriber ¶
func (d *Dataloader[TKey, TResult]) RegisterResultSubscriber(subscriber func(TResult))
RegisterResultSubscriber registers a function that will be called with every result that is loaded.