generator

package
v0.0.0-...-ed70e32 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT, MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Open batchStatus = iota
	Closed
)

Variables

This section is empty.

Functions

func Generate

func Generate(sqlcManifestPath string, outputDir string)

Types

type Dataloader

type Dataloader[TKey any, TResult any] struct {
	// contains filtered or unexported fields
}

func NewDataloader

func NewDataloader[TKey comparable, TResult any](ctx context.Context, maxBatchSize int, batchTimeout time.Duration, cacheResults bool, publishResults bool,
	fetchFunc func(context.Context, []TKey) ([]TResult, []error)) *Dataloader[TKey, TResult]

func NewDataloaderWithNonComparableKey

func NewDataloaderWithNonComparableKey[TKey any, TResult any](ctx context.Context, maxBatchSize int, batchTimeout time.Duration, cacheResults bool, publishResults bool,
	fetchFunc func(context.Context, []TKey) ([]TResult, []error)) *Dataloader[TKey, TResult]

func (*Dataloader[TKey, TResult]) Load

func (d *Dataloader[TKey, TResult]) Load(key TKey) (TResult, error)

Load a ContractCreator 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 ContractCreator. 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.

Jump to

Keyboard shortcuts

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