class Bus::Evaluation
- Bus::Evaluation
- Reference
- Object
Defined in:
bus/evaluation.crConstructors
-
.new(message : Bus::Message, receivers, timeout : Float64 = 10.0)
Build an Evaluation object.
Instance Method Summary
- #evaluations : Hash(Pipeline(Message), Confidence | Nil)
- #filter_by_strategy(winners)
-
#finished?
Returns true if evaluations have been received for all of the receivers which were provided when the object was created.
- #message : Message
-
#set(receiver : String, relevance : String | Int = 0, certainty : String | Int = 0, force : String = "")
Takes the origin string for a receiver, and the relevance, certainty, and force values, and sets them inside of the Evaluation object.
- #start_time : Time::Span
-
#timed_out?
Determine if this evaluation has timed out.
- #timeout : Float64
- #timeout=(timeout : Float64)
-
#winners
Determine the winners of the evaluation.
Constructor Detail
Build an Evaluation object. It takes two arguments. The first is the message that requires a destination. The second is the list of pipelines connecting to the potential receivers for the message.
A lookup table is built that contains the origin string for each pipeline as the key, and the pipeline itself as the value. A second hash is built which pairs the pipelines to the Confidence objects for each receiver.
Instance Method Detail
Returns true if evaluations have been received for all of the receivers which were provided when the object was created. This also evaluates to true if the timeout period has been exceeded.
Takes the origin string for a receiver, and the relevance, certainty, and force values, and sets them inside of the Evaluation object.
Determine if this evaluation has timed out. If, for some reason, one of the handlers is very slow returning their Confidence, or never returns a Confidence, the evaulation should still be evaluated using all of the entries that responded by the time that the timeout is exceeded.
Determine the winners of the evaluation. The algorithm is as follows:
- All receivers with a Confidence
forcevalue of false are automatically losers. - All receivers with a Confidence
forcevalue of true are automatically winners. - For all others are sorted by
relevanceand then by `certainty. - Winners are everything with
force==trueplus everything with the highestrelevanceandcertainty.