dataloader

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: GPL-3.0, GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware() func(handlerFunc echo.HandlerFunc) echo.HandlerFunc

Types

type Loaders

type Loaders struct {
	VersionDependenciesByVersionID VersionDependencyLoader
	UserModsByModID                UserModLoader
	VersionsByModID                VersionLoader
	VersionsByModIDNoMeta          VersionLoaderNoMeta
	UserByID                       UserLoader
}

func For

func For(ctx context.Context) *Loaders

type UserLoader

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

UserLoader batches and caches requests

func NewUserLoader

func NewUserLoader(config UserLoaderConfig) *UserLoader

NewUserLoader creates a new UserLoader given a fetch, wait, and maxBatch

func (*UserLoader) Clear

func (l *UserLoader) Clear(key string)

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

func (*UserLoader) Load

func (l *UserLoader) Load(key string) (*postgres.User, error)

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

func (*UserLoader) LoadAll

func (l *UserLoader) LoadAll(keys []string) ([]*postgres.User, []error)

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

func (*UserLoader) LoadAllThunk

func (l *UserLoader) LoadAllThunk(keys []string) func() ([]*postgres.User, []error)

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

func (l *UserLoader) LoadThunk(key string) func() (*postgres.User, error)

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

func (l *UserLoader) Prime(key string, value *postgres.User) 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 UserLoaderConfig

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

UserLoaderConfig captures the config to create a new UserLoader

type UserModLoader

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

UserModLoader batches and caches requests

func NewUserModLoader

func NewUserModLoader(config UserModLoaderConfig) *UserModLoader

NewUserModLoader creates a new UserModLoader given a fetch, wait, and maxBatch

func (*UserModLoader) Clear

func (l *UserModLoader) Clear(key string)

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

func (*UserModLoader) Load

func (l *UserModLoader) Load(key string) ([]postgres.UserMod, error)

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

func (*UserModLoader) LoadAll

func (l *UserModLoader) LoadAll(keys []string) ([][]postgres.UserMod, []error)

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

func (*UserModLoader) LoadAllThunk

func (l *UserModLoader) LoadAllThunk(keys []string) func() ([][]postgres.UserMod, []error)

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

func (l *UserModLoader) LoadThunk(key string) func() ([]postgres.UserMod, error)

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

func (l *UserModLoader) Prime(key string, value []postgres.UserMod) 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 UserModLoaderConfig

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

UserModLoaderConfig captures the config to create a new UserModLoader

type VersionDependencyLoader

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

VersionDependencyLoader batches and caches requests

func NewVersionDependencyLoader

func NewVersionDependencyLoader(config VersionDependencyLoaderConfig) *VersionDependencyLoader

NewVersionDependencyLoader creates a new VersionDependencyLoader given a fetch, wait, and maxBatch

func (*VersionDependencyLoader) Clear

func (l *VersionDependencyLoader) Clear(key string)

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

func (*VersionDependencyLoader) Load

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

func (*VersionDependencyLoader) LoadAll

func (l *VersionDependencyLoader) LoadAll(keys []string) ([][]postgres.VersionDependency, []error)

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

func (*VersionDependencyLoader) LoadAllThunk

func (l *VersionDependencyLoader) LoadAllThunk(keys []string) func() ([][]postgres.VersionDependency, []error)

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

func (l *VersionDependencyLoader) LoadThunk(key string) func() ([]postgres.VersionDependency, error)

LoadThunk returns a function that when called will block waiting for a VersionDependency. 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 (*VersionDependencyLoader) 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 VersionDependencyLoaderConfig

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

VersionDependencyLoaderConfig captures the config to create a new VersionDependencyLoader

type VersionLoader

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

VersionLoader batches and caches requests

func NewVersionLoader

func NewVersionLoader(config VersionLoaderConfig) *VersionLoader

NewVersionLoader creates a new VersionLoader given a fetch, wait, and maxBatch

func (*VersionLoader) Clear

func (l *VersionLoader) Clear(key string)

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

func (*VersionLoader) Load

func (l *VersionLoader) Load(key string) ([]postgres.Version, error)

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

func (*VersionLoader) LoadAll

func (l *VersionLoader) LoadAll(keys []string) ([][]postgres.Version, []error)

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

func (*VersionLoader) LoadAllThunk

func (l *VersionLoader) LoadAllThunk(keys []string) func() ([][]postgres.Version, []error)

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

func (l *VersionLoader) LoadThunk(key string) func() ([]postgres.Version, error)

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

func (l *VersionLoader) Prime(key string, value []postgres.Version) 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 VersionLoaderConfig

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

VersionLoaderConfig captures the config to create a new VersionLoader

type VersionLoaderNoMeta

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

VersionLoaderNoMeta batches and caches requests

func NewVersionLoaderNoMeta

func NewVersionLoaderNoMeta(config VersionLoaderNoMetaConfig) *VersionLoaderNoMeta

NewVersionLoaderNoMeta creates a new VersionLoaderNoMeta given a fetch, wait, and maxBatch

func (*VersionLoaderNoMeta) Clear

func (l *VersionLoaderNoMeta) Clear(key string)

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

func (*VersionLoaderNoMeta) Load

func (l *VersionLoaderNoMeta) Load(key string) ([]postgres.Version, error)

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

func (*VersionLoaderNoMeta) LoadAll

func (l *VersionLoaderNoMeta) LoadAll(keys []string) ([][]postgres.Version, []error)

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

func (*VersionLoaderNoMeta) LoadAllThunk

func (l *VersionLoaderNoMeta) LoadAllThunk(keys []string) func() ([][]postgres.Version, []error)

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

func (l *VersionLoaderNoMeta) LoadThunk(key string) func() ([]postgres.Version, error)

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

func (l *VersionLoaderNoMeta) Prime(key string, value []postgres.Version) 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 VersionLoaderNoMetaConfig

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

VersionLoaderNoMetaConfig captures the config to create a new VersionLoaderNoMeta

Jump to

Keyboard shortcuts

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