Liking cljdoc? Tell your friends :D

org.clojars.roklenarcic.paginator

Paginator enables paginating multiple concurrent items with batching.

Paginator enables paginating multiple concurrent items with batching.
raw docstring

engineclj

(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.
raw docstring

entity-typeclj

(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
raw docstring

merge-expand-resultclj

(merge-expand-result paging-state result xf)

Updates paging state with result map. Returns a collection with updated paging state + expansion.

Anything in the result map overwrites current values in paging-state. The exception are keys:

  • :page (which increases by 1)
  • :items are not added, but instead they are processed through transducer xf and added to the returned collection
Updates paging state with result map. Returns a collection with
updated paging state + expansion.

 Anything in the result map overwrites current values in paging-state.
 The exception are keys:
 - :page (which increases by 1)
 - :items are not added, but instead they are processed through
  transducer xf and added to the returned collection
raw docstring

merge-expand-resultsclj

(merge-expand-results paging-states results xf)

Updates paging states with the results + expansions, see merge-expand-result.

Updates paging states with the results + expansions, see merge-expand-result.
raw docstring

merge-resultclj

(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:

  • :page (which increases by 1)
  • :items values are combined
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
raw docstring

merge-resultsclj

(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.
raw docstring

paginate!clj

(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.
raw docstring

paginate*!clj

(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.
raw docstring

paginate-coll!clj

(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.
raw docstring

paginate-one!clj

(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
raw docstring

paging-stateclj

(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.
raw docstring

throw-states-exceptionsclj

(throw-states-exceptions states)

Throws any exceptions in the states given.

Throws any exceptions in the states given.
raw docstring

with-batcherclj

(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
raw docstring

with-concurrencyclj

(with-concurrency engine concurrency)

with-result-bufclj

(with-result-buf engine buf-size)

The buffer size for the result channel.

The buffer size for the result channel.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close