class Bus::Evaluation

Defined in:

bus/evaluation.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(message : Bus::Message, receivers, timeout : Float64 = 10.0) #

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.


[View source]

Instance Method Detail

def evaluations : Hash(Pipeline(Message), Confidence | Nil) #

[View source]
def filter_by_strategy(winners) #

[View source]
def finished? #

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.


[View source]
def message : Message #

[View source]
def 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.


[View source]
def start_time : Time::Span #

[View source]
def timed_out? #

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.


[View source]
def timeout : Float64 #

[View source]
def timeout=(timeout : Float64) #

[View source]
def winners #

Determine the winners of the evaluation. The algorithm is as follows:

  1. All receivers with a Confidence force value of false are automatically losers.
  2. All receivers with a Confidence force value of true are automatically winners.
  3. For all others are sorted by relevance and then by `certainty.
  4. Winners are everything with force==true plus everything with the highest relevance and certainty.

[View source]