Class: Inf::LoadBalancer

Inherits:
Thor
  • Object
show all
Defined in:
lib/load_balancer.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



2
3
4
# File 'lib/load_balancer.rb', line 2

def method_missing(m, *args, &block)
  Inf.send(m, *args, &block)
end

Class Method Details

.method_missing(m, *args, &block) ⇒ Object



6
7
8
# File 'lib/load_balancer.rb', line 6

def self.method_missing(m, *args, &block)
  Inf.send(m, *args, &block)
end

Instance Method Details

#killObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/load_balancer.rb', line 16

def kill
  lb_name  = get_state "apps/#{app_name}/lb-name"
  delete_state "apps/#{app_name}/lb-name"

  if lb_name
    elb.delete_load_balancer(
      load_balancer_name: lb_name
    )

    delete_state "apps/#{app_name}/lb-dns"
    puts "Deleted lb #{lb_name}".blue
  else
    puts "Did not find an lb".yellow
  end
end

#launchObject



11
12
13
# File 'lib/load_balancer.rb', line 11

def launch
  Inf::AWS.launch_load_balancer
end

#statusObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/load_balancer.rb', line 33

def status
  lb_name  = get_state "apps/#{app_name}/lb-name"

  unless lb_name
    puts "Load balancer is not configured".blue
    return
  end

  lb = elb.
    describe_load_balancers(load_balancer_names: [lb_name]).
    load_balancer_descriptions[0]

  unless lb
    puts "Load balancer expected but not found!".red
    return
  end

  puts "Load balancer is at #{lb.dns_name} with ".blue +
    "#{lb.instances.count} instances".blue
end