Paginator enables paginating multiple concurrent items with batching.
Paginator enables paginating multiple concurrent items with batching.
(engine)
(engine async-fn)
Defines a minimal map describing the paging engine. Use with-* to add more options.
async-fn is a fn that takes a no-arg fn and runs it asynchronously, defaults to future-call
Default buffer size for result channel is 100. Default concurrency is 1, see with-concurrency docs for meaning of this setting.
Defines a minimal map describing the paging engine. Use with-* to add more options. async-fn is a fn that takes a no-arg fn and runs it asynchronously, defaults to future-call Default buffer size for result channel is 100. Default concurrency is 1, see with-concurrency docs for meaning of this setting.
(entity-type paging-states)
It returns entity-type of the first paging-state in the collection of paging states
It returns entity-type of the first paging-state in the collection of paging states
(merge-result paging-state result)
Updates paging state with result map. Anything in the result map overwrites current values in paging-state. The exception are keys:
Updates paging state with result map. Anything in the result map overwrites current values in paging-state. The exception are keys: - :page (which increases by 1) - :items values are combined
(merge-results paging-states results)
Updates paging states with the results, see merge-result fn.
Updates paging states with the results, see merge-result fn.
(paginate! engine get-pages-fn entity-ids)
Loads pages with given entity-id pairs. Returns a vector of paging states. Any exceptions are rethrown. entity-ids should be a coll of pairs of entity-type and id.
Loads pages with given entity-id pairs. Returns a vector of paging states. Any exceptions are rethrown. entity-ids should be a coll of pairs of entity-type and id.
(paginate*! engine get-pages-fn)
Returns a channel for inbound paging state maps and a channel where the paging state maps are returns with additional keys of :items or :exception.
They are returned in the map as :in and :out keys respectively.
get-pages-fn takes paging-states coll and returns new updated paging-states coll, use merge-result, merge-results functions to assist in updating paging states correctly with new items.
Returns a channel for inbound paging state maps and a channel where the paging state maps are returns with additional keys of :items or :exception. They are returned in the map as :in and :out keys respectively. get-pages-fn takes paging-states coll and returns new updated paging-states coll, use merge-result, merge-results functions to assist in updating paging states correctly with new items.
(paginate-coll! engine get-pages-fn entity-type ids)
Loads pages with given IDs. Returns a vector of vectors where each subvector represents items for the id at that index in input parameters. Any exceptions are rethrown.
Loads pages with given IDs. Returns a vector of vectors where each subvector represents items for the id at that index in input parameters. Any exceptions are rethrown.
(paginate-one! engine get-page-fn)
Starts pagination on a single entity and returns items. It expects that there is only 1 result.
get-item-fn should take 1 parameter, the sole paging state, with entity-type ::singleton, id nil
Starts pagination on a single entity and returns items. It expects that there is only 1 result. get-item-fn should take 1 parameter, the sole paging state, with entity-type ::singleton, id nil
(paging-state entity-type entity-id)
Returns a base data-structure that describes initial state in paging of results based on some entity.
Initially it doesn't have a :page-cursor key. If the key is present and nil, the entity is considered to be finished caching.
Returns a base data-structure that describes initial state in paging of results based on some entity. Initially it doesn't have a :page-cursor key. If the key is present and nil, the entity is considered to be finished caching.
(throw-states-exceptions states)
Throws any exceptions in the states given.
Throws any exceptions in the states given.
(with-batcher engine sorted?)
(with-batcher engine sorted? max-items)
(with-batcher engine sorted? max-items batch-fn)
Add batching configuration to engine map.
sorted? enables using sorted map instead of normal for keeping batches. This comes into play when you have multiple unfinished batches and one needs to be picked for processing, with sorted map the batches with lowest batch key go first.
max-items is the batch size. If pipeline stalls because no batches are available with max size, smaller batches are issued.
batch-fn is the function to generate batch key from paging state map. Defaults to :entity-type
Add batching configuration to engine map. sorted? enables using sorted map instead of normal for keeping batches. This comes into play when you have multiple unfinished batches and one needs to be picked for processing, with sorted map the batches with lowest batch key go first. max-items is the batch size. If pipeline stalls because no batches are available with max size, smaller batches are issued. batch-fn is the function to generate batch key from paging state map. Defaults to :entity-type
(with-concurrency engine concurrency)
(with-result-buf engine buf-size)
The buffer size for the result channel.
The buffer size for the result channel.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close