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 concurrency)
(engine concurrency runner-fn)

Defines a minimal map describing the paging engine. Use with-* to add more options.

runner-fn is a function of 2 args that takes a no-arg function and a result-ch. It should run the function, usually in some async manner and push the result into result-ch. By default it does work in future pool and blockingly pushes the result into result-ch.

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.

runner-fn is a function of 2 args that takes a no-arg function and a result-ch. It should run
the function, usually in some async manner and push the result into result-ch. By default it does
work in future pool and blockingly pushes the result into result-ch.

Default buffer size for result channel is 100.
Default concurrency is 1, see with-concurrency docs for meaning of this setting.
sourceraw 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
sourceraw docstring

merge-expand-resultclj

(merge-expand-result result paging-state 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
sourceraw docstring

merge-expand-resultsclj

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

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

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

merge-resultclj

(merge-result result paging-state)

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
sourceraw docstring

merge-resultsclj

(merge-results results paging-states)

Updates paging states with the results, see merge-result fn.

Updates paging states with the results, see merge-result fn.
sourceraw 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.
sourceraw 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.
sourceraw docstring

paginate-coll!clj

(paginate-coll! engine get-pages-fn entity-type ids)

Loads pages with given IDs. Returns a vector of paging states. Any exceptions are rethrown.

Loads pages with given IDs. Returns a vector of paging states. Any exceptions are rethrown.
sourceraw docstring

paginate-coll-items!clj

(paginate-coll-items! engine get-pages-fn entity-type ids)

Loads pages with given IDs. Returns a vector of vectors of items. Any exceptions are rethrown.

Loads pages with given IDs. Returns a vector of vectors of items. Any exceptions are rethrown.
sourceraw 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
sourceraw 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.
sourceraw docstring

throw-states-exceptionsclj

(throw-states-exceptions states)

Throws any exceptions in the states given.

Throws any exceptions in the states given.
sourceraw 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
sourceraw docstring

with-concurrencyclj

(with-concurrency engine concurrency)
source

with-result-bufclj

(with-result-buf engine buf-size)

The buffer size for the result channel.

The buffer size for the result channel.
sourceraw docstring

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

× close