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 result-parser)
(engine result-parser get-items-fn)
(engine result-parser get-items-fn 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

get-items-fn is a fn of (params, paging-states) that should return some sort of a response, that will be parsed by result-parser, defaults to get-items multimethod

result-parser is a protocols/ResultParser instance

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

get-items-fn is a fn of (params, paging-states) that should return some sort of a response,
that will be parsed by result-parser, defaults to get-items multimethod

result-parser is a protocols/ResultParser instance

Default buffer size for result channel is 100.
Default concurrency is 1, see with-concurrency docs for meaning of this setting.
raw docstring

get-itemscljmultimethod

Multimethod that should perform a request for a specific :entity-type and return a response.

Multimethod that should perform a request for a specific :entity-type and return a response.
raw docstring

paginate!clj

(paginate! engine params 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 params)

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.

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

paginate-coll!clj

(paginate-coll! engine params 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 params entity-type id)

Starts pagination on a single entity and returns items. It expects that there is only 1 result.

Params is merged into paging states map.

Starts pagination on a single entity and returns items. It expects that there is only 1 result.

Params is merged into paging states map.
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

result-parserclj

(result-parser items-fn cursor-fn new-entities-fn)

Returns a proto/ResultParser, the functions given have the same argument list as the protocol.

Returns a proto/ResultParser, the functions given have the same argument list as
the protocol.
raw docstring

result-parser1clj

(result-parser1 items-fn cursor-fn)
(result-parser1 items-fn cursor-fn new-entities-fn)

Returns a proto/ResultParser that expects that response has 1 item and 1 cursor

  • items-fn takes a batch-result returns a collection of items for the paging-state
  • cursor-fn takes a batch-result returns a cursor
  • new-entities-fn takes a batch-result and returns coll of paging states for new entities, defaults to a function that always returns []
Returns a proto/ResultParser that expects that response has 1 item and 1 cursor

- items-fn takes a batch-result returns a collection of items for the paging-state
- cursor-fn takes a batch-result returns a cursor
- new-entities-fn takes a batch-result and returns coll of paging states for new entities, defaults
to a function that always returns []
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-items-fnclj

(with-items-fn engine get-items-fn)

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