claro.engine.selector

Selectors let you adjust and optimize the order of resolution on an engine or tree level.

See the Engine documentation.

default-selector

Always selects all available classes.

exact-selector

(exact-selector class-batches & [fallback-selector])

Select the given classes in the order they are given, e.g.:

(exact-selector
  [[Person]
   [FriendsOf FatherOf]
   [Person]])

This can be used on a per-resolution basis, ideally providing the optimal resolution order:

(engine/run!
  {:selector (exact-selector ...)}
  (->Person 1))

parallel-selector

(parallel-selector n)

Select at most n classes to resolve during each iteration.

scoring-selector

(scoring-selector score-fn)

Use (score-fn class resolvables) to generate a score for each class, selecting the one with the highest score.

For example, to always select the class with the most resolvables:

(scoring-selector
  (fn [class resolvables]
    (count resolvables)))

Or, to assign a score based on class, e.g always resolve FriendsOf before Person if applicable:

(scoring-selector
  (fn [class resolvables]
    (get {Person 2, FriendsOf 1} class 0)))

Selector

protocol

members

instantiate

(instantiate selector)

Generate a selector instance, i.e. a function taking a map of classes/resolvables and returning a seq of classes to resolve during the current iteration step.