class FFWD::TCP::Bind
Constants
- DEFAULT_REBIND_TIMEOUT
Default initial timeout when binding fails.
Attributes
log[R]
reporter_meta[R]
Public Class Methods
new(core, log, host, port, connection, config)
click to toggle source
# File lib/ffwd/protocol/tcp/bind.rb, line 43 def initialize core, log, host, port, connection, config @log = log @peer = "#{host}:#{port}" @reporter_meta = {:component => connection.plugin_type, :listen => @peer} @server = nil info = "tcp://#{@peer}" rebind_timeout = config[:rebind_timeout] r = FFWD.retry :timeout => rebind_timeout do |a| @server = EM.start_server 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 @server EM.stop_server @server @server = nil end log.info "Unbound #{info}" end end
prepare(opts)
click to toggle source
# File lib/ffwd/protocol/tcp/bind.rb, line 28 def self.prepare opts opts[:rebind_timeout] ||= DEFAULT_REBIND_TIMEOUT opts end