2011/6/22 Robert Klemme <shortcutter / googlemail.com>:
> Hm... Now I am not sure any more whether you need a associative
> container at all. Now we have three steps. From what I understand
> you do:
>
> 1. items are collected
> 2. items are ordered by priority (what you call second container above)
> 3. items are ordered by some randomization algorithm
>
> I'm obviously missing other access operations out here. So far I
> don't see any need for a Hash or similar structure. What else is it
> that you need to do with these items? What properties do they have?
Step 1)
I get data (DNS SRV records), which is an array with entries like this:
#<EventMachine::Udns::RR_SRV:0x00000001ea4970 @domain="domain.org",
@priority=1, @weight=50, @port=5062>
Each entry is a SRV record. It has a priority (lowest value is the
best) and weight (higher value means more probability to choose it).
The client getting such array of SRV records wants to connect to a
server based on SRV priorities/weight, which works as follows:
- SRV records with best priority must be used first.
- If there are various SRV records with same priority, then the
probability of choosing each one depends on its weight value (random
with weight).
- If the chosen SRV record fails to connect (i.e. server down) next
one (based on same priority/weight rules) must be tryed.
--
Iaki Baz Castillo
<ibc / aliax.net>