dataloader

package
v0.0.0-...-67a1156 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(db *proxima.ProximaDatabase) gin.HandlerFunc

Types

type DPoolListLoader

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

DPoolListLoader batches and caches requests

func NewDPoolListLoader

func NewDPoolListLoader(config DPoolListLoaderConfig) *DPoolListLoader

NewDPoolListLoader creates a new DPoolListLoader given a fetch, wait, and maxBatch

func (*DPoolListLoader) Clear

func (l *DPoolListLoader) Clear(key string)

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

func (*DPoolListLoader) Load

func (l *DPoolListLoader) Load(key string) (*models.DPoolList, error)

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

func (*DPoolListLoader) LoadAll

func (l *DPoolListLoader) LoadAll(keys []string) ([]*models.DPoolList, []error)

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

func (*DPoolListLoader) LoadAllThunk

func (l *DPoolListLoader) LoadAllThunk(keys []string) func() ([]*models.DPoolList, []error)

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

func (l *DPoolListLoader) LoadThunk(key string) func() (*models.DPoolList, error)

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

func (l *DPoolListLoader) Prime(key string, value *models.DPoolList) 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 DPoolListLoaderConfig

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

DPoolListLoaderConfig captures the config to create a new DPoolListLoader

type DPoolLoader

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

DPoolLoader batches and caches requests

func NewDPoolLoader

func NewDPoolLoader(config DPoolLoaderConfig) *DPoolLoader

NewDPoolLoader creates a new DPoolLoader given a fetch, wait, and maxBatch

func (*DPoolLoader) Clear

func (l *DPoolLoader) Clear(key string)

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

func (*DPoolLoader) Load

func (l *DPoolLoader) Load(key string) (*models.DPool, error)

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

func (*DPoolLoader) LoadAll

func (l *DPoolLoader) LoadAll(keys []string) ([]*models.DPool, []error)

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

func (*DPoolLoader) LoadAllThunk

func (l *DPoolLoader) LoadAllThunk(keys []string) func() ([]*models.DPool, []error)

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

func (l *DPoolLoader) LoadThunk(key string) func() (*models.DPool, error)

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

func (l *DPoolLoader) Prime(key string, value *models.DPool) 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 DPoolLoaderConfig

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

DPoolLoaderConfig captures the config to create a new DPoolLoader

type DepositLoader

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

DepositLoader batches and caches requests

func NewDepositLoader

func NewDepositLoader(config DepositLoaderConfig) *DepositLoader

NewDepositLoader creates a new DepositLoader given a fetch, wait, and maxBatch

func (*DepositLoader) Clear

func (l *DepositLoader) Clear(key string)

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

func (*DepositLoader) Load

func (l *DepositLoader) Load(key string) (*models.Deposit, error)

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

func (*DepositLoader) LoadAll

func (l *DepositLoader) LoadAll(keys []string) ([]*models.Deposit, []error)

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

func (*DepositLoader) LoadAllThunk

func (l *DepositLoader) LoadAllThunk(keys []string) func() ([]*models.Deposit, []error)

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

func (l *DepositLoader) LoadThunk(key string) func() (*models.Deposit, error)

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

func (l *DepositLoader) Prime(key string, value *models.Deposit) 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 DepositLoaderConfig

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

DepositLoaderConfig captures the config to create a new DepositLoader

type FunderLoader

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

FunderLoader batches and caches requests

func NewFunderLoader

func NewFunderLoader(config FunderLoaderConfig) *FunderLoader

NewFunderLoader creates a new FunderLoader given a fetch, wait, and maxBatch

func (*FunderLoader) Clear

func (l *FunderLoader) Clear(key string)

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

func (*FunderLoader) Load

func (l *FunderLoader) Load(key string) (*models.Funder, error)

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

func (*FunderLoader) LoadAll

func (l *FunderLoader) LoadAll(keys []string) ([]*models.Funder, []error)

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

func (*FunderLoader) LoadAllThunk

func (l *FunderLoader) LoadAllThunk(keys []string) func() ([]*models.Funder, []error)

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

func (l *FunderLoader) LoadThunk(key string) func() (*models.Funder, error)

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

func (l *FunderLoader) Prime(key string, value *models.Funder) 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 FunderLoaderConfig

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

FunderLoaderConfig captures the config to create a new FunderLoader

type FunderTotalInterestLoader

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

FunderTotalInterestLoader batches and caches requests

func NewFunderTotalInterestLoader

func NewFunderTotalInterestLoader(config FunderTotalInterestLoaderConfig) *FunderTotalInterestLoader

NewFunderTotalInterestLoader creates a new FunderTotalInterestLoader given a fetch, wait, and maxBatch

func (*FunderTotalInterestLoader) Clear

func (l *FunderTotalInterestLoader) Clear(key string)

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

func (*FunderTotalInterestLoader) Load

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

func (*FunderTotalInterestLoader) LoadAll

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

func (*FunderTotalInterestLoader) LoadAllThunk

func (l *FunderTotalInterestLoader) LoadAllThunk(keys []string) func() ([]*models.FunderTotalInterest, []error)

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

func (l *FunderTotalInterestLoader) LoadThunk(key string) func() (*models.FunderTotalInterest, error)

LoadThunk returns a function that when called will block waiting for a FunderTotalInterest. 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 (*FunderTotalInterestLoader) 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 FunderTotalInterestLoaderConfig

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

FunderTotalInterestLoaderConfig captures the config to create a new FunderTotalInterestLoader

type FundingLoader

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

FundingLoader batches and caches requests

func NewFundingLoader

func NewFundingLoader(config FundingLoaderConfig) *FundingLoader

NewFundingLoader creates a new FundingLoader given a fetch, wait, and maxBatch

func (*FundingLoader) Clear

func (l *FundingLoader) Clear(key string)

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

func (*FundingLoader) Load

func (l *FundingLoader) Load(key string) (*models.Funding, error)

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

func (*FundingLoader) LoadAll

func (l *FundingLoader) LoadAll(keys []string) ([]*models.Funding, []error)

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

func (*FundingLoader) LoadAllThunk

func (l *FundingLoader) LoadAllThunk(keys []string) func() ([]*models.Funding, []error)

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

func (l *FundingLoader) LoadThunk(key string) func() (*models.Funding, error)

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

func (l *FundingLoader) Prime(key string, value *models.Funding) 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 FundingLoaderConfig

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

FundingLoaderConfig captures the config to create a new FundingLoader

type Loaders

type Loaders struct {
	DPoolListById           DPoolListLoader
	DPoolById               DPoolLoader
	UserById                UserLoader
	UserTotalDepositById    UserTotalDepositLoader
	DepositById             DepositLoader
	FunderById              FunderLoader
	FunderTotalInterestById FunderTotalInterestLoader
	FundingById             FundingLoader
	MPHHolderById           MPHHolderLoader
	MPHById                 MPHLoader
}

func For

func For(ctx context.Context) *Loaders

type MPHHolderLoader

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

MPHHolderLoader batches and caches requests

func NewMPHHolderLoader

func NewMPHHolderLoader(config MPHHolderLoaderConfig) *MPHHolderLoader

NewMPHHolderLoader creates a new MPHHolderLoader given a fetch, wait, and maxBatch

func (*MPHHolderLoader) Clear

func (l *MPHHolderLoader) Clear(key string)

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

func (*MPHHolderLoader) Load

func (l *MPHHolderLoader) Load(key string) (*models.MPHHolder, error)

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

func (*MPHHolderLoader) LoadAll

func (l *MPHHolderLoader) LoadAll(keys []string) ([]*models.MPHHolder, []error)

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

func (*MPHHolderLoader) LoadAllThunk

func (l *MPHHolderLoader) LoadAllThunk(keys []string) func() ([]*models.MPHHolder, []error)

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

func (l *MPHHolderLoader) LoadThunk(key string) func() (*models.MPHHolder, error)

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

func (l *MPHHolderLoader) Prime(key string, value *models.MPHHolder) 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 MPHHolderLoaderConfig

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

MPHHolderLoaderConfig captures the config to create a new MPHHolderLoader

type MPHLoader

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

MPHLoader batches and caches requests

func NewMPHLoader

func NewMPHLoader(config MPHLoaderConfig) *MPHLoader

NewMPHLoader creates a new MPHLoader given a fetch, wait, and maxBatch

func (*MPHLoader) Clear

func (l *MPHLoader) Clear(key string)

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

func (*MPHLoader) Load

func (l *MPHLoader) Load(key string) (*models.Mph, error)

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

func (*MPHLoader) LoadAll

func (l *MPHLoader) LoadAll(keys []string) ([]*models.Mph, []error)

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

func (*MPHLoader) LoadAllThunk

func (l *MPHLoader) LoadAllThunk(keys []string) func() ([]*models.Mph, []error)

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

func (l *MPHLoader) LoadThunk(key string) func() (*models.Mph, error)

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

func (l *MPHLoader) Prime(key string, value *models.Mph) 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 MPHLoaderConfig

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

MPHLoaderConfig captures the config to create a new MPHLoader

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) (*models.User, error)

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

func (*UserLoader) LoadAll

func (l *UserLoader) LoadAll(keys []string) ([]*models.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() ([]*models.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() (*models.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 *models.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) ([]*models.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 UserTotalDepositLoader

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

UserTotalDepositLoader batches and caches requests

func NewUserTotalDepositLoader

func NewUserTotalDepositLoader(config UserTotalDepositLoaderConfig) *UserTotalDepositLoader

NewUserTotalDepositLoader creates a new UserTotalDepositLoader given a fetch, wait, and maxBatch

func (*UserTotalDepositLoader) Clear

func (l *UserTotalDepositLoader) Clear(key string)

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

func (*UserTotalDepositLoader) Load

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

func (*UserTotalDepositLoader) LoadAll

func (l *UserTotalDepositLoader) LoadAll(keys []string) ([]*models.UserTotalDeposit, []error)

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

func (*UserTotalDepositLoader) LoadAllThunk

func (l *UserTotalDepositLoader) LoadAllThunk(keys []string) func() ([]*models.UserTotalDeposit, []error)

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

func (l *UserTotalDepositLoader) LoadThunk(key string) func() (*models.UserTotalDeposit, error)

LoadThunk returns a function that when called will block waiting for a UserTotalDeposit. 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 (*UserTotalDepositLoader) 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 UserTotalDepositLoaderConfig

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

UserTotalDepositLoaderConfig captures the config to create a new UserTotalDepositLoader

Jump to

Keyboard shortcuts

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