Class: Qwirk::Adapter::InMemory::Publisher::MyTaskConsumer

Inherits:
Object
  • Object
show all
Defined in:
lib/qwirk/adapter/in_memory/publisher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(producer_queue, consumer_queue) ⇒ MyTaskConsumer

Returns a new instance of MyTaskConsumer.



72
73
74
75
76
# File 'lib/qwirk/adapter/in_memory/publisher.rb', line 72

def initialize(producer_queue, consumer_queue)
  @producer_queue = producer_queue
  @consumer_queue = consumer_queue
  @stopped = false
end

Instance Attribute Details

#stoppedObject (readonly)

Returns the value of attribute stopped.



70
71
72
# File 'lib/qwirk/adapter/in_memory/publisher.rb', line 70

def stopped
  @stopped
end

Instance Method Details

#acknowledge_messageObject



84
85
# File 'lib/qwirk/adapter/in_memory/publisher.rb', line 84

def acknowledge_message
end

#receiveObject



78
79
80
81
82
# File 'lib/qwirk/adapter/in_memory/publisher.rb', line 78

def receive
  message_id, response, worker_name = @consumer_queue.read(self)
  return nil unless response
  return [message_id, response]
end

#stopObject



87
88
89
90
91
92
93
# File 'lib/qwirk/adapter/in_memory/publisher.rb', line 87

def stop
  # TODO - Need to think about what should actually occur here?
  return if @stopped
  Qwirk.logger.info "Stopping Task worker #{@consumer_queue}"
  @producer_queue.interrupt_read
  @stopped = true
end