Class: Bricolage::StreamingLoad::S3ObjectDispatcherMessage

Inherits:
DispatcherMessage show all
Defined in:
lib/bricolage/streamingload/dispatchermessage.rb

Constant Summary

Constants inherited from Bricolage::SQSMessage

Bricolage::SQSMessage::SQS_EVENT_SOURCE

Instance Attribute Summary collapse

Attributes inherited from Bricolage::SQSMessage

#delay_seconds, #message_id, #name, #receipt_handle, #source, #time

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DispatcherMessage

get_concrete_class

Methods inherited from Bricolage::SQSMessage

#body, create, for_sqs_record, for_sqs_result, get_event_time, #initialize

Constructor Details

This class inherits a constructor from Bricolage::SQSMessage

Instance Attribute Details

#bucketObject (readonly)

Returns the value of attribute bucket.



135
136
137
# File 'lib/bricolage/streamingload/dispatchermessage.rb', line 135

def bucket
  @bucket
end

#keyObject (readonly)

Returns the value of attribute key.



136
137
138
# File 'lib/bricolage/streamingload/dispatchermessage.rb', line 136

def key
  @key
end

#regionObject (readonly)

Returns the value of attribute region.



134
135
136
# File 'lib/bricolage/streamingload/dispatchermessage.rb', line 134

def region
  @region
end

#sizeObject (readonly)

Returns the value of attribute size.



137
138
139
# File 'lib/bricolage/streamingload/dispatchermessage.rb', line 137

def size
  @size
end

Class Method Details

.parse_sqs_record(msg, rec) ⇒ Object



114
115
116
117
118
119
120
121
# File 'lib/bricolage/streamingload/dispatchermessage.rb', line 114

def S3ObjectDispatcherMessage.parse_sqs_record(msg, rec)
  {
    region: rec['awsRegion'],
    bucket: rec['s3']['bucket']['name'],
    key: rec['s3']['object']['key'],
    size: rec['s3']['object']['size']
  }
end

Instance Method Details

#chunkObject



152
153
154
# File 'lib/bricolage/streamingload/dispatchermessage.rb', line 152

def chunk
  Chunk.new(id: nil, url: url, size: size)
end

#created_event?Boolean

Returns:

  • (Boolean)


148
149
150
# File 'lib/bricolage/streamingload/dispatchermessage.rb', line 148

def created_event?
  !!(/\AObjectCreated:(?!Copy)/ =~ @name)
end

#data?Boolean

override

Returns:

  • (Boolean)


144
145
146
# File 'lib/bricolage/streamingload/dispatchermessage.rb', line 144

def data?
  true
end

#init_message(region:, bucket:, key:, size:) ⇒ Object



127
128
129
130
131
132
# File 'lib/bricolage/streamingload/dispatchermessage.rb', line 127

def init_message(region:, bucket:, key:, size:)
  @region = region
  @bucket = bucket
  @key = key
  @size = size
end

#message_typeObject



123
124
125
# File 'lib/bricolage/streamingload/dispatchermessage.rb', line 123

def message_type
  'data'
end

#urlObject



139
140
141
# File 'lib/bricolage/streamingload/dispatchermessage.rb', line 139

def url
  "s3://#{@bucket}/#{@key}"
end