Class: ReverseProxy::Proxy::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/reverse_proxy/proxy/generic.rb

Direct Known Subclasses

Nginx

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Generic

Returns a new instance of Generic.



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/reverse_proxy/proxy/generic.rb', line 26

def initialize params={}
  ReverseProxy.instance = self
  @pid         = Process.pid
  @lock      ||= Mutex.new
  @server      = ReverseProxy::Server.const_get(params[:server]).new self
  @binds     ||= Set.new
  @application = Application.new self
  @config    ||= Config.for self
  prepare
  on_initialize
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



63
64
65
# File 'lib/reverse_proxy/proxy/generic.rb', line 63

def method_missing method, *args, &block
  self.send(:server_event, method) if method.to_s =~ /^(on|before|after)_/
end

Class Attribute Details

.eventsObject (readonly)

Returns the value of attribute events.



8
9
10
# File 'lib/reverse_proxy/proxy/generic.rb', line 8

def events
  @events
end

Instance Attribute Details

#applicationObject

Returns the value of attribute application.



24
25
26
# File 'lib/reverse_proxy/proxy/generic.rb', line 24

def application
  @application
end

#bindsObject

Returns the value of attribute binds.



24
25
26
# File 'lib/reverse_proxy/proxy/generic.rb', line 24

def binds
  @binds
end

#configObject

Returns the value of attribute config.



24
25
26
# File 'lib/reverse_proxy/proxy/generic.rb', line 24

def config
  @config
end

#lockObject (readonly)

Returns the value of attribute lock.



23
24
25
# File 'lib/reverse_proxy/proxy/generic.rb', line 23

def lock
  @lock
end

#pidObject (readonly)

Returns the value of attribute pid.



23
24
25
# File 'lib/reverse_proxy/proxy/generic.rb', line 23

def pid
  @pid
end

#serverObject

Returns the value of attribute server.



24
25
26
# File 'lib/reverse_proxy/proxy/generic.rb', line 24

def server
  @server
end

Instance Method Details

#idObject



40
41
42
# File 'lib/reverse_proxy/proxy/generic.rb', line 40

def id
  ReverseProxy::Proxy.id
end

#log(message) ⇒ Object



37
38
39
# File 'lib/reverse_proxy/proxy/generic.rb', line 37

def log message
  puts "[#{pid}] #{message}"
end

#reloadObject



49
50
51
# File 'lib/reverse_proxy/proxy/generic.rb', line 49

def reload
  @reload.call
end

#startObject



43
44
45
# File 'lib/reverse_proxy/proxy/generic.rb', line 43

def start
  @start.call
end

#stopObject



46
47
48
# File 'lib/reverse_proxy/proxy/generic.rb', line 46

def stop
  @stop.call
end