Class: Karst::Access::PrincipalSelection
- Inherits:
-
Object
- Object
- Karst::Access::PrincipalSelection
- Defined in:
- lib/karst/access/principal_selection.rb
Overview
Runs Karst::Access::PrincipalSampler independently per configured
Karst::Access::PrincipalSource -- never materializing multiple sources
together (no Author.all.to_a + Reader.all.to_a) -- and allocates the
combined candidates within one overall limit. The single-source case
(including the implicit legacy :default source Configuration builds
from a bare config.principals) behaves identically to calling
PrincipalSampler directly: this class only changes behavior once more
than one source is actually configured.
Allocation policy (deliberately simple, not a general-purpose scheduler): every non-empty source is guaranteed at least one candidate, then remaining room is filled round-robin across sources, each contributing its own candidates in the order PrincipalSampler already prioritizes them (dimension-covering candidates before plain fill). One source running out never blocks another from filling the rest of the budget.
Constant Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(sources:, limit: Karst.config.access_sweep_limit, pool_size: Karst.config.principal_candidate_pool_size) ⇒ PrincipalSelection
constructor
A new instance of PrincipalSelection.
Constructor Details
#initialize(sources:, limit: Karst.config.access_sweep_limit, pool_size: Karst.config.principal_candidate_pool_size) ⇒ PrincipalSelection
Returns a new instance of PrincipalSelection.
27 28 29 30 31 32 |
# File 'lib/karst/access/principal_selection.rb', line 27 def initialize(sources:, limit: Karst.config.access_sweep_limit, pool_size: Karst.config.principal_candidate_pool_size) @sources = sources || {} @limit = limit @pool_size = pool_size end |
Instance Method Details
#call ⇒ Object
34 35 36 37 38 39 |
# File 'lib/karst/access/principal_selection.rb', line 34 def call return empty_result if @sources.empty? per_source = sample_each_source build_result(per_source, allocate(per_source)) end |