View Source Dataloader.Source protocol (dataloader v2.0.2)

Summary

Types

t()

All the types that implement this protocol.

Functions

Returns whether or not the source should be running synchronously or asynchronously with respect to the process making Dataloader function calls.

Fetch the result found under the given batch and item keys.

Enqueue an item to be loaded under a given batch

Determine if there are any batches that have not yet been run.

Put a value into the results.

Run any batches queued up for this source.

Returns the timeout (in ms) for the source.

Types

batch_key()

@type batch_key() :: term()

item_key()

@type item_key() :: term()

t()

@type t() :: term()

All the types that implement this protocol.

Functions

async?(source)

@spec async?(t()) :: boolean()

Returns whether or not the source should be running synchronously or asynchronously with respect to the process making Dataloader function calls.

fetch(source, batch_key, item_key)

@spec fetch(t(), batch_key(), item_key()) :: {:ok, term()} | {:error, term()}

Fetch the result found under the given batch and item keys.

load(source, batch_key, item_key)

@spec load(t(), batch_key(), item_key()) :: t()

Enqueue an item to be loaded under a given batch

pending_batches?(source)

@spec pending_batches?(t()) :: boolean()

Determine if there are any batches that have not yet been run.

put(source, batch_key, item_key, item)

@spec put(t(), batch_key(), item_key(), term()) :: t()

Put a value into the results.

Useful for warming caches. The source is permitted to reject the value.

run(source)

@spec run(t()) :: t()

Run any batches queued up for this source.

timeout(source)

@spec timeout(t()) :: number()

Returns the timeout (in ms) for the source.

This is important for ensuring the dataloader obeys the timeouts when running multiple sources concurrently