Class: Push::Daemon::Feedback::FeedbackFeeder

Inherits:
Object
  • Object
show all
Includes:
DatabaseReconnectable, InterruptibleSleep
Defined in:
lib/push/daemon/feedback/feedback_feeder.rb

Instance Method Summary collapse

Methods included from InterruptibleSleep

#interrupt_sleep, #interruptible_sleep

Methods included from DatabaseReconnectable

#adaptor_errors, #check_database_is_connected, #database_connection_lost, #reconnect_database, #sleep_to_avoid_thrashing, #with_database_reconnect_and_retry

Constructor Details

#initialize(poll) ⇒ FeedbackFeeder

Returns a new instance of FeedbackFeeder.



8
9
10
# File 'lib/push/daemon/feedback/feedback_feeder.rb', line 8

def initialize(poll)
  @poll = poll
end

Instance Method Details

#nameObject



12
13
14
# File 'lib/push/daemon/feedback/feedback_feeder.rb', line 12

def name
  "FeedbackFeeder"
end

#startObject



16
17
18
19
20
21
22
23
24
# File 'lib/push/daemon/feedback/feedback_feeder.rb', line 16

def start
  Thread.new do
    loop do
      interruptible_sleep @poll
      break if @stop
      enqueue_feedback
    end
  end
end

#stopObject



26
27
28
29
# File 'lib/push/daemon/feedback/feedback_feeder.rb', line 26

def stop
  @stop = true
  interrupt_sleep
end