Class: Entrance::Agent::Haproxy

Inherits:
Object
  • Object
show all
Extended by:
Globalizer
Defined in:
lib/entrance/agent/haproxy.rb

Instance Attribute Summary collapse

Attributes included from Globalizer

#current

Instance Method Summary collapse

Constructor Details

#initializeHaproxy

Returns a new instance of Haproxy.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/entrance/agent/haproxy.rb', line 16

def initialize
  Haproxy.current ||= self
  @haproxy   = Synapse::Config::Haproxy.new Entrance.current
  @backends  = Synapse::Config::Services.new
  @services  = {}
  @synapse_config = {
    haproxy:  haproxy,
    services: backends 
  }.with_indifferent_access
  @synapse = Synapse::Synapse.new @synapse_config
  @synapse.services = backends
  Config.current.https_params.default_certificate = Entrance.current.certificate
  @http    = Synapse::Easy::Section::Http.new Config.current.http_params
  @https   = Synapse::Easy::Section::Http.new Config.current.https_params
  haproxy.extra_sections[http.label]  = http
  haproxy.extra_sections[https.label] = https
  link_notifiers
end

Instance Attribute Details

#backendsObject

Returns the value of attribute backends.



13
14
15
# File 'lib/entrance/agent/haproxy.rb', line 13

def backends
  @backends
end

#haproxyObject

Returns the value of attribute haproxy.



13
14
15
# File 'lib/entrance/agent/haproxy.rb', line 13

def haproxy
  @haproxy
end

#httpObject

Returns the value of attribute http.



13
14
15
# File 'lib/entrance/agent/haproxy.rb', line 13

def http
  @http
end

#httpsObject

Returns the value of attribute https.



13
14
15
# File 'lib/entrance/agent/haproxy.rb', line 13

def https
  @https
end

#servicesObject

Returns the value of attribute services.



13
14
15
# File 'lib/entrance/agent/haproxy.rb', line 13

def services
  @services
end

#synapseObject

Returns the value of attribute synapse.



13
14
15
# File 'lib/entrance/agent/haproxy.rb', line 13

def synapse
  @synapse
end

#threadObject

Returns the value of attribute thread.



13
14
15
# File 'lib/entrance/agent/haproxy.rb', line 13

def thread
  @thread
end

Instance Method Details

#startObject



40
41
42
43
44
45
46
# File 'lib/entrance/agent/haproxy.rb', line 40

def start
  return if backends.empty?
  self.thread  = Thread.new do
    synapse.run
  end
  @started = true
end

#updateObject



34
35
36
37
38
39
# File 'lib/entrance/agent/haproxy.rb', line 34

def update
  Entrance.current.update
  update_frontends
  update_haproxy
  link_notifiers
end