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 BatchFetchers to actually retrieve the data). For other operations including mutations or more advanced query operations, see the BatchExecutor type and the Executor trait.

Structs§

  • Batches calls to an Executor, such as for bulk inserting, updating, or deleting records in a datastore. BatchExecutors are asynchronous and designed to be passed and shared between threads or tasks. Cloning a BatchExecutor is shallow and will use the same underlying Executor.
  • Used to configure a new BatchExecutor. A BatchExecutorBuilder is returned from BatchExecutor::build.
  • Batches and caches loads from some datastore. A BatchFetcher can be used with any type that implements Fetcher. BatchFetchers are asynchronous and designed to be passed and shared between threads or tasks. Cloning a BatchFetcher is shallow and will use the same Fetcher.
  • Used to configure a new BatchFetcher. A BatchFetcherBuilder is returned from BatchFetcher::build.
  • Holds the results of loading a batch of data from a Fetcher. Implementors of Fetcher should call insert for each value that was loaded in a batch request.

Enums§

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. Implementing Executor will allow operations to be batched by using a BatchExecutor. See the BatchExecutor 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. Implementing Fetcher will allow queries to be batched using a BatchFetcher. See the BatchFetcher docs for details about batching, caching, and error semantics.