Class: Shipitron::Client::FetchClusters

Inherits:
Object
  • Object
show all
Includes:
Metaractor
Defined in:
lib/shipitron/client/fetch_clusters.rb

Instance Method Summary collapse

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/shipitron/client/fetch_clusters.rb', line 12

def call
  resources = dns_resources.sort! do |a,b|
    (a.priority <=> b.priority).yield_self do |prio|
      if prio == 0
        b.weight <=> a.weight
      else
        prio
      end
    end
  end

  context.clusters = resources.map do |r|
    Smash.new(
      name: r.target[0].to_s,
      region: r.target[1].to_s
    )
  end

  Logger.debug "Clusters: #{context.clusters.inspect}"
end