StrategySelector<Input, Output> class
Selects a FetchStrategy for a given Input at runtime.
Evaluates a list of candidates in priority order, returning the first
strategy for which FetchStrategy.canHandle returns true.
This is the only place where "which pipeline?" logic lives. Every other component receives a pre-selected strategy and just runs it.
Example
final selector = StrategySelector<UrlSpark, Listing>([
ScraperFetchStrategy(channelConfigRepo), // preferred — fast
AiFetchStrategy(scrapeService), // fallback — universal
]);
// In the use case:
final strategy = await selector.select(spark);
final listing = await strategy.fetchOne(spark);
Constructors
-
StrategySelector(List<
FetchStrategy< _candidates)Input, Output> >
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
select(
Input input) → Future< FetchStrategy< Input, Output> > -
Returns the first strategy that can handle
input. -
selectAll(
Input input) → Future< List< FetchStrategy< >Input, Output> > -
Returns ALL strategies that can handle
input, in priority order. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited