Class: Consumer

Inherits:
EventMachine::FileTail
  • Object
show all
Defined in:
lib/logstash_sqs/consumer.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, startpos = -1,, params = {}) ⇒ Consumer

Returns a new instance of Consumer.



3
4
5
6
7
8
# File 'lib/logstash_sqs/consumer.rb', line 3

def initialize(path, startpos=-1, params = {})
  super(path, startpos)
  @buffer = BufferedTokenizer.new
  @aws_sqs_client  = AWSSQS.new(params['buffer_size'])
  @format = params['format'] || 'json'
end

Instance Method Details

#receive_data(data) ⇒ Object



10
11
12
13
14
# File 'lib/logstash_sqs/consumer.rb', line 10

def receive_data(data)
  @buffer.extract(data).each do |message|
    @aws_sqs_client.add_message(marshall(message))
  end
end