Class: Hugo::Balancer

Inherits:
Object
  • Object
show all
Includes:
Mixin::ParamsValidate, Singleton
Defined in:
lib/hugo/balancer.rb

Constant Summary collapse

DEFAULT_ZONE =
'us-east-1c'
DEFAULT_PORT =
'8080'
DEFAULT_WEB =
'80'
DEFAULT_TYPE =
'http'
DEFAULT_SSL_PORT =
'8443'
DEFAULT_SSL_WEB =
'443'

Instance Method Summary collapse

Methods included from Mixin::ParamsValidate

#set_or_return, #validate

Constructor Details

#initializeBalancer

Returns a new instance of Balancer.



14
15
16
17
18
19
20
21
# File 'lib/hugo/balancer.rb', line 14

def initialize
  zone DEFAULT_ZONE
  port DEFAULT_PORT
  web DEFAULT_WEB
  ssl_port DEFAULT_SSL_PORT
  ssl_web DEFAULT_SSL_WEB
  type DEFAULT_TYPE
end

Instance Method Details

#deployObject



23
24
25
26
27
28
29
# File 'lib/hugo/balancer.rb', line 23

def deploy
  Hugo::Aws::Elb.find_or_create(:name => name,
                          :zones => zone,
                          :listeners => [{ :instance_port => port, :protocol =>"HTTP", :load_balancer_port => web}, 
                            { :instance_port => ssl_port, :protocol =>"TCP", :load_balancer_port => ssl_web}]
  )
end

#name(arg = nil) ⇒ Object



31
32
33
# File 'lib/hugo/balancer.rb', line 31

def name(arg=nil)
  set_or_return(:name, arg, :kind_of => [String])     
end

#port(arg = nil) ⇒ Object



39
40
41
# File 'lib/hugo/balancer.rb', line 39

def port(arg=nil)
  set_or_return(:port, arg, :kind_of => [String])     
end

#ssl_port(arg = nil) ⇒ Object



51
52
53
# File 'lib/hugo/balancer.rb', line 51

def ssl_port(arg=nil)
  set_or_return(:ssl_port, arg, :kind_of => [String])     
end

#ssl_web(arg = nil) ⇒ Object



55
56
57
# File 'lib/hugo/balancer.rb', line 55

def ssl_web(arg=nil)
  set_or_return(:ssl_web, arg, :kind_of => [String])     
end

#type(arg = nil) ⇒ Object



47
48
49
# File 'lib/hugo/balancer.rb', line 47

def type(arg=nil)
  set_or_return(:type, arg, :kind_of => [String])     
end

#web(arg = nil) ⇒ Object



43
44
45
# File 'lib/hugo/balancer.rb', line 43

def web(arg=nil)
  set_or_return(:web, arg, :kind_of => [String])     
end

#zone(arg = nil) ⇒ Object



35
36
37
# File 'lib/hugo/balancer.rb', line 35

def zone(arg=nil)
  set_or_return(:zone, arg, :kind_of => [String])     
end