Class: Alephant::Publisher::Publisher

Inherits:
Object
  • Object
show all
Defined in:
lib/alephant/publisher.rb

Constant Summary collapse

VISIBILITY_TIMEOUT =
60
RECEIVE_WAIT_TIME =
15

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts, processor = nil) ⇒ Publisher

Returns a new instance of Publisher.



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/alephant/publisher.rb', line 30

def initialize(opts, processor = nil)
  @opts = opts
  @processor = processor

  @queue = SQSHelper::Queue.new(
    aws_queue,
    archiver,
    opts.queue[:visibility_timeout] || VISIBILITY_TIMEOUT,
    opts.queue[:receive_wait_time]  || RECEIVE_WAIT_TIME,
  )
end

Instance Attribute Details

#executorObject (readonly)

Returns the value of attribute executor.



28
29
30
# File 'lib/alephant/publisher.rb', line 28

def executor
  @executor
end

#optsObject (readonly)

Returns the value of attribute opts.



28
29
30
# File 'lib/alephant/publisher.rb', line 28

def opts
  @opts
end

#processorObject (readonly)

Returns the value of attribute processor.



28
29
30
# File 'lib/alephant/publisher.rb', line 28

def processor
  @processor
end

#queueObject (readonly)

Returns the value of attribute queue.



28
29
30
# File 'lib/alephant/publisher.rb', line 28

def queue
  @queue
end

Instance Method Details

#run!Object



42
43
44
# File 'lib/alephant/publisher.rb', line 42

def run!
  loop { processor.consume(@queue.message) }
end