Class: FFWD::UDP::Bind
- Inherits:
-
Object
- Object
- FFWD::UDP::Bind
- Includes:
- Reporter
- Defined in:
- lib/ffwd/protocol/udp/bind.rb
Constant Summary collapse
- DEFAULT_REBIND_TIMEOUT =
10
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#log ⇒ Object
readonly
Returns the value of attribute log.
-
#reporter_meta ⇒ Object
readonly
Returns the value of attribute reporter_meta.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(core, log, host, port, connection, config) ⇒ Bind
constructor
A new instance of Bind.
Methods included from Reporter
included, #increment, map_meta, #report!, #reporter_data
Constructor Details
#initialize(core, log, host, port, connection, config) ⇒ Bind
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/ffwd/protocol/udp/bind.rb', line 39 def initialize core, log, host, port, connection, config @log = log @peer = "#{host}:#{port}" @reporter_meta = { :type => connection.plugin_type, :listen => @peer, :family => 'udp' } rebind_timeout = config[:rebind_timeout] @socket = nil info = "udp://#{@peer}" r = FFWD.retry :timeout => rebind_timeout do |a| @socket = EM.open_datagram_socket host, port, connection, self, core, config log.info "Bind on #{info} (attempt #{a})" log.info " config: #{config.inspect}" end r.error do |a, t, e| log.warning "Bind on #{info} failed, retry ##{a} in #{t}s: #{e}" end r.depend_on core core.stopping do if @socket @socket.unbind @socket = nil end log.info "Unbound #{info}" end end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
37 38 39 |
# File 'lib/ffwd/protocol/udp/bind.rb', line 37 def config @config end |
#log ⇒ Object (readonly)
Returns the value of attribute log.
37 38 39 |
# File 'lib/ffwd/protocol/udp/bind.rb', line 37 def log @log end |
#reporter_meta ⇒ Object (readonly)
Returns the value of attribute reporter_meta.
37 38 39 |
# File 'lib/ffwd/protocol/udp/bind.rb', line 37 def @reporter_meta end |
Class Method Details
.prepare(opts) ⇒ Object
27 28 29 30 |
# File 'lib/ffwd/protocol/udp/bind.rb', line 27 def self.prepare opts opts[:rebind_timeout] ||= DEFAULT_REBIND_TIMEOUT opts end |