module NononoSender

Constants

S
VERSION

Public Instance Methods

alive?() click to toggle source
# File lib/nonono_sender.rb, line 25
def alive?
  defined? @t && @t.alive?
end
exit() click to toggle source
# File lib/nonono_sender.rb, line 19
def exit
  raise Error unless defined? @starter
  @t.kill
  remove_instance_variable(:@starter)
end
init() click to toggle source
# File lib/nonono_sender.rb, line 7
def init; end
retry_count() click to toggle source
# File lib/nonono_sender.rb, line 33
def retry_count
  0
end
retryable?() click to toggle source
# File lib/nonono_sender.rb, line 29
def retryable?
  false
end
run() click to toggle source
# File lib/nonono_sender.rb, line 17
def run; end
send(event) click to toggle source
# File lib/nonono_sender.rb, line 37
def send(event)
  @recv.each do |r|
    max_count = retryable? ? retry_count : 0
    count = 0
    begin
      count += 1
      r.recieve(event)
    rescue StandardError => e
      puts e
      if max_count > count
        sleep 3
        retry
      end
    end
  end
end
start(recv) click to toggle source
# File lib/nonono_sender.rb, line 8
def start(recv)
  raise Error if defined? @t
  @recv = recv
  @t = Thread.new do
    run
  end
  @t.run
end