Class: Puggernaut::Client
- Inherits:
-
Object
- Object
- Puggernaut::Client
- Includes:
- Logger
- Defined in:
- lib/puggernaut/client.rb
Instance Attribute Summary collapse
-
#connections ⇒ Object
Returns the value of attribute connections.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(*servers) ⇒ Client
constructor
A new instance of Client.
- #push(messages) ⇒ Object
Methods included from Logger
Constructor Details
#initialize(*servers) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 |
# File 'lib/puggernaut/client.rb', line 12 def initialize(*servers) @connections = {} @retry = [] @servers = servers.collect { |s| s.split(':') } end |
Instance Attribute Details
#connections ⇒ Object
Returns the value of attribute connections.
10 11 12 |
# File 'lib/puggernaut/client.rb', line 10 def connections @connections end |
Instance Method Details
#close ⇒ Object
18 19 20 21 22 23 |
# File 'lib/puggernaut/client.rb', line 18 def close @connections.each do |host_port, connection| connection.close logger.info "Client#close - #{host_port}" end end |
#push(messages) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/puggernaut/client.rb', line 25 def push() = .collect do |channel, | if .is_a?(::Array) .collect { |m| "#{channel}|#{m}" }.join("\n") else "#{channel}|#{}" end end unless .empty? @servers.each do |(host, port)| send host, port, .join("\n") end end end |