Class: Sqewer::Connection::MessageBuffer

Inherits:
Struct
  • Object
show all
Defined in:
lib/sqewer/connection.rb

Overview

Stores the messages for the SQS queue (both deletes and sends), and yields them in allowed batch sizes

Direct Known Subclasses

DeleteBuffer, SendBuffer

Constant Summary collapse

MAX_RECORDS =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMessageBuffer

Returns a new instance of MessageBuffer.



102
103
104
# File 'lib/sqewer/connection.rb', line 102

def initialize
  super([])
end

Instance Attribute Details

#messagesObject

Returns the value of attribute messages

Returns:

  • (Object)

    the current value of messages



100
101
102
# File 'lib/sqewer/connection.rb', line 100

def messages
  @messages
end

Instance Method Details

#each_batchObject



105
106
107
# File 'lib/sqewer/connection.rb', line 105

def each_batch
  messages.each_slice(MAX_RECORDS){|batch| yield(batch)}
end