Crate ultra_batch
source ·Expand description
Batch and cache database queries, mutations, or other potentially expensive operations. The main motivation for this library is to solve the “N + 1” query problem seen in GraphQL and elsewhere. This library takes heavy influence from the GraphQL Foundation’s DataLoader.
For batched data queries, see the BatchFetcher
type (used to queue and
load data in batches) and the Fetcher
trait (used by BatchFetcher
s
to actually retrieve the data). For other operations including mutations
or more advanced query operations, see the BatchExecutor
type and
the Executor
trait.
Structs§
- Used to configure a new
BatchExecutor
. ABatchExecutorBuilder
is returned fromBatchExecutor::build
.
Enums§
- Error indicating that execution of one or more values from a
BatchExecutor
failed. - Error indicating that loading one or more values from a
BatchFetcher
failed.
Traits§
- A trait for using a batch of values to execute some operation, such as a bulk insertion in a datastore. An
Executor
will be given an array of values and should handle each value, then return a result for each. ImplementingExecutor
will allow operations to be batched by using aBatchExecutor
. See theBatchExecutor
docs for details about batching and error semantics. - A trait for fetching values from some datastore in bulk. A
Fetcher
will be given an array of keys and should insert fetched values into a given cache. ImplementingFetcher
will allow queries to be batched using aBatchFetcher
. See theBatchFetcher
docs for details about batching, caching, and error semantics.