dataloader

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLoadersKey

func GetLoadersKey() contextKey

func Middleware

func Middleware(fac models.Repo) func(next http.Handler) http.Handler

Types

type BodyModificationsLoader

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

BodyModificationsLoader batches and caches requests

func NewBodyModificationsLoader

func NewBodyModificationsLoader(config BodyModificationsLoaderConfig) *BodyModificationsLoader

NewBodyModificationsLoader creates a new BodyModificationsLoader given a fetch, wait, and maxBatch

func (*BodyModificationsLoader) Clear

func (l *BodyModificationsLoader) Clear(key uuid.UUID)

Clear the value at key from the cache, if it exists

func (*BodyModificationsLoader) Load

Load a BodyModification by key, batching and caching will be applied automatically

func (*BodyModificationsLoader) LoadAll

func (l *BodyModificationsLoader) LoadAll(keys []uuid.UUID) ([][]*models.BodyModification, []error)

LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured

func (*BodyModificationsLoader) LoadAllThunk

func (l *BodyModificationsLoader) LoadAllThunk(keys []uuid.UUID) func() ([][]*models.BodyModification, []error)

LoadAllThunk returns a function that when called will block waiting for a BodyModifications. 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 (*BodyModificationsLoader) LoadThunk

func (l *BodyModificationsLoader) LoadThunk(key uuid.UUID) func() ([]*models.BodyModification, error)

LoadThunk returns a function that when called will block waiting for a BodyModification. 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 (*BodyModificationsLoader) Prime

func (l *BodyModificationsLoader) Prime(key uuid.UUID, value []*models.BodyModification) bool

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

type BodyModificationsLoaderConfig

type BodyModificationsLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []uuid.UUID) ([][]*models.BodyModification, []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
}

BodyModificationsLoaderConfig captures the config to create a new BodyModificationsLoader

type FingerprintsLoader

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

FingerprintsLoader batches and caches requests

func NewFingerprintsLoader

func NewFingerprintsLoader(config FingerprintsLoaderConfig) *FingerprintsLoader

NewFingerprintsLoader creates a new FingerprintsLoader given a fetch, wait, and maxBatch

func (*FingerprintsLoader) Clear

func (l *FingerprintsLoader) Clear(key uuid.UUID)

Clear the value at key from the cache, if it exists

func (*FingerprintsLoader) Load

func (l *FingerprintsLoader) Load(key uuid.UUID) ([]*models.Fingerprint, error)

Load a Fingerprint by key, batching and caching will be applied automatically

func (*FingerprintsLoader) LoadAll

func (l *FingerprintsLoader) LoadAll(keys []uuid.UUID) ([][]*models.Fingerprint, []error)

LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured

func (*FingerprintsLoader) LoadAllThunk

func (l *FingerprintsLoader) LoadAllThunk(keys []uuid.UUID) func() ([][]*models.Fingerprint, []error)

LoadAllThunk returns a function that when called will block waiting for a Fingerprints. 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 (*FingerprintsLoader) LoadThunk

func (l *FingerprintsLoader) LoadThunk(key uuid.UUID) func() ([]*models.Fingerprint, error)

LoadThunk returns a function that when called will block waiting for a Fingerprint. 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 (*FingerprintsLoader) Prime

func (l *FingerprintsLoader) Prime(key uuid.UUID, value []*models.Fingerprint) bool

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

type FingerprintsLoaderConfig

type FingerprintsLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []uuid.UUID) ([][]*models.Fingerprint, []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
}

FingerprintsLoaderConfig captures the config to create a new FingerprintsLoader

type ImageLoader

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

ImageLoader batches and caches requests

func NewImageLoader

func NewImageLoader(config ImageLoaderConfig) *ImageLoader

NewImageLoader creates a new ImageLoader given a fetch, wait, and maxBatch

func (*ImageLoader) Clear

func (l *ImageLoader) Clear(key uuid.UUID)

Clear the value at key from the cache, if it exists

func (*ImageLoader) Load

func (l *ImageLoader) Load(key uuid.UUID) (*models.Image, error)

Load a Image by key, batching and caching will be applied automatically

func (*ImageLoader) LoadAll

func (l *ImageLoader) LoadAll(keys []uuid.UUID) ([]*models.Image, []error)

LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured

func (*ImageLoader) LoadAllThunk

func (l *ImageLoader) LoadAllThunk(keys []uuid.UUID) func() ([]*models.Image, []error)

LoadAllThunk returns a function that when called will block waiting for a Images. 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 (*ImageLoader) LoadThunk

func (l *ImageLoader) LoadThunk(key uuid.UUID) func() (*models.Image, error)

LoadThunk returns a function that when called will block waiting for a Image. 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 (*ImageLoader) Prime

func (l *ImageLoader) Prime(key uuid.UUID, value *models.Image) bool

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

type ImageLoaderConfig

type ImageLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []uuid.UUID) ([]*models.Image, []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
}

ImageLoaderConfig captures the config to create a new ImageLoader

type Loaders

type Loaders struct {
	SceneFingerprintsByID  FingerprintsLoader
	ImageByID              ImageLoader
	PerformerByID          PerformerLoader
	PerformerAliasesByID   StringsLoader
	PerformerImageIDsByID  UUIDsLoader
	PerformerMergeIDsByID  UUIDsLoader
	PerformerPiercingsByID BodyModificationsLoader
	PerformerTattoosByID   BodyModificationsLoader
	PerformerUrlsByID      URLLoader
	SceneImageIDsByID      UUIDsLoader
	SceneAppearancesByID   SceneAppearancesLoader
	SceneUrlsByID          URLLoader
	StudioImageIDsByID     UUIDsLoader
	StudioUrlsByID         URLLoader
	SceneTagIDsByID        UUIDsLoader
	SiteByID               SiteLoader
	TagByID                TagLoader
	TagCategoryByID        TagCategoryLoader
}

func For

func For(ctx context.Context) *Loaders

func GetLoaders

func GetLoaders(ctx context.Context, fac models.Repo) *Loaders

type PerformerLoader

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

PerformerLoader batches and caches requests

func NewPerformerLoader

func NewPerformerLoader(config PerformerLoaderConfig) *PerformerLoader

NewPerformerLoader creates a new PerformerLoader given a fetch, wait, and maxBatch

func (*PerformerLoader) Clear

func (l *PerformerLoader) Clear(key uuid.UUID)

Clear the value at key from the cache, if it exists

func (*PerformerLoader) Load

func (l *PerformerLoader) Load(key uuid.UUID) (*models.Performer, error)

Load a Performer by key, batching and caching will be applied automatically

func (*PerformerLoader) LoadAll

func (l *PerformerLoader) LoadAll(keys []uuid.UUID) ([]*models.Performer, []error)

LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured

func (*PerformerLoader) LoadAllThunk

func (l *PerformerLoader) LoadAllThunk(keys []uuid.UUID) func() ([]*models.Performer, []error)

LoadAllThunk returns a function that when called will block waiting for a Performers. 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 (*PerformerLoader) LoadThunk

func (l *PerformerLoader) LoadThunk(key uuid.UUID) func() (*models.Performer, error)

LoadThunk returns a function that when called will block waiting for a Performer. 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 (*PerformerLoader) Prime

func (l *PerformerLoader) Prime(key uuid.UUID, value *models.Performer) bool

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

type PerformerLoaderConfig

type PerformerLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []uuid.UUID) ([]*models.Performer, []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
}

PerformerLoaderConfig captures the config to create a new PerformerLoader

type SceneAppearancesLoader

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

SceneAppearancesLoader batches and caches requests

func NewSceneAppearancesLoader

func NewSceneAppearancesLoader(config SceneAppearancesLoaderConfig) *SceneAppearancesLoader

NewSceneAppearancesLoader creates a new SceneAppearancesLoader given a fetch, wait, and maxBatch

func (*SceneAppearancesLoader) Clear

func (l *SceneAppearancesLoader) Clear(key uuid.UUID)

Clear the value at key from the cache, if it exists

func (*SceneAppearancesLoader) Load

Load a PerformersScenes by key, batching and caching will be applied automatically

func (*SceneAppearancesLoader) LoadAll

func (l *SceneAppearancesLoader) LoadAll(keys []uuid.UUID) ([]models.PerformersScenes, []error)

LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured

func (*SceneAppearancesLoader) LoadAllThunk

func (l *SceneAppearancesLoader) LoadAllThunk(keys []uuid.UUID) func() ([]models.PerformersScenes, []error)

LoadAllThunk returns a function that when called will block waiting for a PerformersSceness. 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 (*SceneAppearancesLoader) LoadThunk

func (l *SceneAppearancesLoader) LoadThunk(key uuid.UUID) func() (models.PerformersScenes, error)

LoadThunk returns a function that when called will block waiting for a PerformersScenes. 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 (*SceneAppearancesLoader) Prime

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

type SceneAppearancesLoaderConfig

type SceneAppearancesLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []uuid.UUID) ([]models.PerformersScenes, []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
}

SceneAppearancesLoaderConfig captures the config to create a new SceneAppearancesLoader

type SiteLoader added in v0.1.0

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

SiteLoader batches and caches requests

func NewSiteLoader added in v0.1.0

func NewSiteLoader(config SiteLoaderConfig) *SiteLoader

NewSiteLoader creates a new SiteLoader given a fetch, wait, and maxBatch

func (*SiteLoader) Clear added in v0.1.0

func (l *SiteLoader) Clear(key uuid.UUID)

Clear the value at key from the cache, if it exists

func (*SiteLoader) Load added in v0.1.0

func (l *SiteLoader) Load(key uuid.UUID) (*models.Site, error)

Load a Site by key, batching and caching will be applied automatically

func (*SiteLoader) LoadAll added in v0.1.0

func (l *SiteLoader) LoadAll(keys []uuid.UUID) ([]*models.Site, []error)

LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured

func (*SiteLoader) LoadAllThunk added in v0.1.0

func (l *SiteLoader) LoadAllThunk(keys []uuid.UUID) func() ([]*models.Site, []error)

LoadAllThunk returns a function that when called will block waiting for a Sites. 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 (*SiteLoader) LoadThunk added in v0.1.0

func (l *SiteLoader) LoadThunk(key uuid.UUID) func() (*models.Site, error)

LoadThunk returns a function that when called will block waiting for a Site. 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 (*SiteLoader) Prime added in v0.1.0

func (l *SiteLoader) Prime(key uuid.UUID, value *models.Site) bool

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

type SiteLoaderConfig added in v0.1.0

type SiteLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []uuid.UUID) ([]*models.Site, []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
}

SiteLoaderConfig captures the config to create a new SiteLoader

type StringsLoader

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

StringsLoader batches and caches requests

func NewStringsLoader

func NewStringsLoader(config StringsLoaderConfig) *StringsLoader

NewStringsLoader creates a new StringsLoader given a fetch, wait, and maxBatch

func (*StringsLoader) Clear

func (l *StringsLoader) Clear(key uuid.UUID)

Clear the value at key from the cache, if it exists

func (*StringsLoader) Load

func (l *StringsLoader) Load(key uuid.UUID) ([]string, error)

Load a string by key, batching and caching will be applied automatically

func (*StringsLoader) LoadAll

func (l *StringsLoader) LoadAll(keys []uuid.UUID) ([][]string, []error)

LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured

func (*StringsLoader) LoadAllThunk

func (l *StringsLoader) LoadAllThunk(keys []uuid.UUID) func() ([][]string, []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 (*StringsLoader) LoadThunk

func (l *StringsLoader) LoadThunk(key uuid.UUID) func() ([]string, 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.

func (*StringsLoader) Prime

func (l *StringsLoader) Prime(key uuid.UUID, value []string) bool

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

type StringsLoaderConfig

type StringsLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []uuid.UUID) ([][]string, []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
}

StringsLoaderConfig captures the config to create a new StringsLoader

type TagCategoryLoader

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

TagCategoryLoader batches and caches requests

func NewTagCategoryLoader

func NewTagCategoryLoader(config TagCategoryLoaderConfig) *TagCategoryLoader

NewTagCategoryLoader creates a new TagCategoryLoader given a fetch, wait, and maxBatch

func (*TagCategoryLoader) Clear

func (l *TagCategoryLoader) Clear(key uuid.UUID)

Clear the value at key from the cache, if it exists

func (*TagCategoryLoader) Load

Load a TagCategory by key, batching and caching will be applied automatically

func (*TagCategoryLoader) LoadAll

func (l *TagCategoryLoader) LoadAll(keys []uuid.UUID) ([]*models.TagCategory, []error)

LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured

func (*TagCategoryLoader) LoadAllThunk

func (l *TagCategoryLoader) LoadAllThunk(keys []uuid.UUID) func() ([]*models.TagCategory, []error)

LoadAllThunk returns a function that when called will block waiting for a TagCategorys. 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 (*TagCategoryLoader) LoadThunk

func (l *TagCategoryLoader) LoadThunk(key uuid.UUID) func() (*models.TagCategory, error)

LoadThunk returns a function that when called will block waiting for a TagCategory. 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 (*TagCategoryLoader) Prime

func (l *TagCategoryLoader) Prime(key uuid.UUID, value *models.TagCategory) bool

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

type TagCategoryLoaderConfig

type TagCategoryLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []uuid.UUID) ([]*models.TagCategory, []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
}

TagCategoryLoaderConfig captures the config to create a new TagCategoryLoader

type TagLoader

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

TagLoader batches and caches requests

func NewTagLoader

func NewTagLoader(config TagLoaderConfig) *TagLoader

NewTagLoader creates a new TagLoader given a fetch, wait, and maxBatch

func (*TagLoader) Clear

func (l *TagLoader) Clear(key uuid.UUID)

Clear the value at key from the cache, if it exists

func (*TagLoader) Load

func (l *TagLoader) Load(key uuid.UUID) (*models.Tag, error)

Load a Tag by key, batching and caching will be applied automatically

func (*TagLoader) LoadAll

func (l *TagLoader) LoadAll(keys []uuid.UUID) ([]*models.Tag, []error)

LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured

func (*TagLoader) LoadAllThunk

func (l *TagLoader) LoadAllThunk(keys []uuid.UUID) func() ([]*models.Tag, []error)

LoadAllThunk returns a function that when called will block waiting for a Tags. 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 (*TagLoader) LoadThunk

func (l *TagLoader) LoadThunk(key uuid.UUID) func() (*models.Tag, error)

LoadThunk returns a function that when called will block waiting for a Tag. 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 (*TagLoader) Prime

func (l *TagLoader) Prime(key uuid.UUID, value *models.Tag) bool

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

type TagLoaderConfig

type TagLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []uuid.UUID) ([]*models.Tag, []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
}

TagLoaderConfig captures the config to create a new TagLoader

type URLLoader

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

URLLoader batches and caches requests

func NewURLLoader

func NewURLLoader(config URLLoaderConfig) *URLLoader

NewURLLoader creates a new URLLoader given a fetch, wait, and maxBatch

func (*URLLoader) Clear

func (l *URLLoader) Clear(key uuid.UUID)

Clear the value at key from the cache, if it exists

func (*URLLoader) Load

func (l *URLLoader) Load(key uuid.UUID) ([]*models.URL, error)

Load a URL by key, batching and caching will be applied automatically

func (*URLLoader) LoadAll

func (l *URLLoader) LoadAll(keys []uuid.UUID) ([][]*models.URL, []error)

LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured

func (*URLLoader) LoadAllThunk

func (l *URLLoader) LoadAllThunk(keys []uuid.UUID) func() ([][]*models.URL, []error)

LoadAllThunk returns a function that when called will block waiting for a URLs. 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 (*URLLoader) LoadThunk

func (l *URLLoader) LoadThunk(key uuid.UUID) func() ([]*models.URL, error)

LoadThunk returns a function that when called will block waiting for a URL. 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 (*URLLoader) Prime

func (l *URLLoader) Prime(key uuid.UUID, value []*models.URL) bool

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

type URLLoaderConfig

type URLLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []uuid.UUID) ([][]*models.URL, []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
}

URLLoaderConfig captures the config to create a new URLLoader

type UUIDsLoader

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

UUIDsLoader batches and caches requests

func NewUUIDsLoader

func NewUUIDsLoader(config UUIDsLoaderConfig) *UUIDsLoader

NewUUIDsLoader creates a new UUIDsLoader given a fetch, wait, and maxBatch

func (*UUIDsLoader) Clear

func (l *UUIDsLoader) Clear(key uuid.UUID)

Clear the value at key from the cache, if it exists

func (*UUIDsLoader) Load

func (l *UUIDsLoader) Load(key uuid.UUID) ([]uuid.UUID, error)

Load a UUID by key, batching and caching will be applied automatically

func (*UUIDsLoader) LoadAll

func (l *UUIDsLoader) LoadAll(keys []uuid.UUID) ([][]uuid.UUID, []error)

LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured

func (*UUIDsLoader) LoadAllThunk

func (l *UUIDsLoader) LoadAllThunk(keys []uuid.UUID) func() ([][]uuid.UUID, []error)

LoadAllThunk returns a function that when called will block waiting for a UUIDs. 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 (*UUIDsLoader) LoadThunk

func (l *UUIDsLoader) LoadThunk(key uuid.UUID) func() ([]uuid.UUID, error)

LoadThunk returns a function that when called will block waiting for a UUID. 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 (*UUIDsLoader) Prime

func (l *UUIDsLoader) Prime(key uuid.UUID, value []uuid.UUID) bool

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

type UUIDsLoaderConfig

type UUIDsLoaderConfig struct {
	// Fetch is a method that provides the data for the loader
	Fetch func(keys []uuid.UUID) ([][]uuid.UUID, []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
}

UUIDsLoaderConfig captures the config to create a new UUIDsLoader

Jump to

Keyboard shortcuts

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