Class: ActivePublisher::Async::InMemoryAdapter::ConsumerThread

Inherits:
Object
  • Object
show all
Defined in:
lib/active_publisher/async/in_memory_adapter/consumer_thread.rb

Constant Summary collapse

NETWORK_ERRORS =
[::Bunny::Exception, ::Timeout::Error, ::IOError].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(listen_queue) ⇒ ConsumerThread

Returns a new instance of ConsumerThread.



13
14
15
16
17
# File 'lib/active_publisher/async/in_memory_adapter/consumer_thread.rb', line 13

def initialize(listen_queue)
  @queue = listen_queue
  @sampled_queue_size = queue.size
  start_thread
end

Instance Attribute Details

#queueObject (readonly)

Returns the value of attribute queue.



5
6
7
# File 'lib/active_publisher/async/in_memory_adapter/consumer_thread.rb', line 5

def queue
  @queue
end

#sampled_queue_sizeObject (readonly)

Returns the value of attribute sampled_queue_size.



5
6
7
# File 'lib/active_publisher/async/in_memory_adapter/consumer_thread.rb', line 5

def sampled_queue_size
  @sampled_queue_size
end

#threadObject (readonly)

Returns the value of attribute thread.



5
6
7
# File 'lib/active_publisher/async/in_memory_adapter/consumer_thread.rb', line 5

def thread
  @thread
end

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/active_publisher/async/in_memory_adapter/consumer_thread.rb', line 19

def alive?
  @thread && @thread.alive?
end

#killObject



23
24
25
26
# File 'lib/active_publisher/async/in_memory_adapter/consumer_thread.rb', line 23

def kill
  @thread.kill if @thread
  @thread = nil
end