Documentation ¶
Index ¶
- type Config
- type DataLoader
- type QualificationLoader
- func (l *QualificationLoader) Clear(key int)
- func (l *QualificationLoader) Load(key int) (*models.Qualification, error)
- func (l *QualificationLoader) LoadAll(keys []int) ([]*models.Qualification, []error)
- func (l *QualificationLoader) LoadAllThunk(keys []int) func() ([]*models.Qualification, []error)
- func (l *QualificationLoader) LoadThunk(key int) func() (*models.Qualification, error)
- func (l *QualificationLoader) Prime(key int, value *models.Qualification) bool
- type QualificationLoaderConfig
- type QualificationSliceByProfessionIDLoader
- func (l *QualificationSliceByProfessionIDLoader) Clear(key int)
- func (l *QualificationSliceByProfessionIDLoader) Load(key int) ([]*models.Qualification, error)
- func (l *QualificationSliceByProfessionIDLoader) LoadAll(keys []int) ([][]*models.Qualification, []error)
- func (l *QualificationSliceByProfessionIDLoader) LoadAllThunk(keys []int) func() ([][]*models.Qualification, []error)
- func (l *QualificationSliceByProfessionIDLoader) LoadThunk(key int) func() ([]*models.Qualification, error)
- func (l *QualificationSliceByProfessionIDLoader) Prime(key int, value []*models.Qualification) bool
- type QualificationSliceByProfessionIDLoaderConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { ProfessionRepo profession.Repository QualificationRepo qualification.Repository }
type DataLoader ¶
type DataLoader struct { QualificationByID *QualificationLoader QualificationsByProfessionID *QualificationSliceByProfessionIDLoader }
func New ¶
func New(cfg Config) *DataLoader
type QualificationLoader ¶
type QualificationLoader struct {
// contains filtered or unexported fields
}
QualificationLoader batches and caches requests
func NewQualificationLoader ¶
func NewQualificationLoader(config QualificationLoaderConfig) *QualificationLoader
NewQualificationLoader creates a new QualificationLoader given a fetch, wait, and maxBatch
func (*QualificationLoader) Clear ¶
func (l *QualificationLoader) Clear(key int)
Clear the value at key from the cache, if it exists
func (*QualificationLoader) Load ¶
func (l *QualificationLoader) Load(key int) (*models.Qualification, error)
Load a Qualification by key, batching and caching will be applied automatically
func (*QualificationLoader) LoadAll ¶
func (l *QualificationLoader) LoadAll(keys []int) ([]*models.Qualification, []error)
LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured
func (*QualificationLoader) LoadAllThunk ¶
func (l *QualificationLoader) LoadAllThunk(keys []int) func() ([]*models.Qualification, []error)
LoadAllThunk returns a function that when called will block waiting for a Qualifications. 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 (*QualificationLoader) LoadThunk ¶
func (l *QualificationLoader) LoadThunk(key int) func() (*models.Qualification, error)
LoadThunk returns a function that when called will block waiting for a Qualification. 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 (*QualificationLoader) Prime ¶
func (l *QualificationLoader) Prime(key int, value *models.Qualification) 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 QualificationLoaderConfig ¶
type QualificationLoaderConfig struct { // Fetch is a method that provides the data for the loader Fetch func(keys []int) ([]*models.Qualification, []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 }
QualificationLoaderConfig captures the config to create a new QualificationLoader
type QualificationSliceByProfessionIDLoader ¶
type QualificationSliceByProfessionIDLoader struct {
// contains filtered or unexported fields
}
QualificationSliceByProfessionIDLoader batches and caches requests
func NewQualificationSliceByProfessionIDLoader ¶
func NewQualificationSliceByProfessionIDLoader(config QualificationSliceByProfessionIDLoaderConfig) *QualificationSliceByProfessionIDLoader
NewQualificationSliceByProfessionIDLoader creates a new QualificationSliceByProfessionIDLoader given a fetch, wait, and maxBatch
func (*QualificationSliceByProfessionIDLoader) Clear ¶
func (l *QualificationSliceByProfessionIDLoader) Clear(key int)
Clear the value at key from the cache, if it exists
func (*QualificationSliceByProfessionIDLoader) Load ¶
func (l *QualificationSliceByProfessionIDLoader) Load(key int) ([]*models.Qualification, error)
Load a Qualification by key, batching and caching will be applied automatically
func (*QualificationSliceByProfessionIDLoader) LoadAll ¶
func (l *QualificationSliceByProfessionIDLoader) LoadAll(keys []int) ([][]*models.Qualification, []error)
LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured
func (*QualificationSliceByProfessionIDLoader) LoadAllThunk ¶
func (l *QualificationSliceByProfessionIDLoader) LoadAllThunk(keys []int) func() ([][]*models.Qualification, []error)
LoadAllThunk returns a function that when called will block waiting for a Qualifications. 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 (*QualificationSliceByProfessionIDLoader) LoadThunk ¶
func (l *QualificationSliceByProfessionIDLoader) LoadThunk(key int) func() ([]*models.Qualification, error)
LoadThunk returns a function that when called will block waiting for a Qualification. 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 (*QualificationSliceByProfessionIDLoader) Prime ¶
func (l *QualificationSliceByProfessionIDLoader) Prime(key int, value []*models.Qualification) 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 QualificationSliceByProfessionIDLoaderConfig ¶
type QualificationSliceByProfessionIDLoaderConfig struct { // Fetch is a method that provides the data for the loader Fetch func(keys []int) ([][]*models.Qualification, []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 }
QualificationSliceByProfessionIDLoaderConfig captures the config to create a new QualificationSliceByProfessionIDLoader