Class: Bricolage::StreamingLoad::S3ObjectEvent

Inherits:
Event show all
Defined in:
lib/bricolage/streamingload/event.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 Event

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.



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

def bucket
  @bucket
end

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

#regionObject (readonly)

Returns the value of attribute region.



133
134
135
# File 'lib/bricolage/streamingload/event.rb', line 133

def region
  @region
end

#sizeObject (readonly)

Returns the value of attribute size.



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

def size
  @size
end

Class Method Details

.parse_sqs_record(msg, rec) ⇒ Object



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

def S3ObjectEvent.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

#created?Boolean

Returns:

  • (Boolean)


147
148
149
# File 'lib/bricolage/streamingload/event.rb', line 147

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

#data?Boolean

override

Returns:

  • (Boolean)


143
144
145
# File 'lib/bricolage/streamingload/event.rb', line 143

def data?
  true
end

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



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

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

#loadable_object(url_patterns) ⇒ Object



151
152
153
# File 'lib/bricolage/streamingload/event.rb', line 151

def loadable_object(url_patterns)
  LoadableObject.new(self, url_patterns.match(url))
end

#message_typeObject



122
123
124
# File 'lib/bricolage/streamingload/event.rb', line 122

def message_type
  'data'
end

#urlObject



138
139
140
# File 'lib/bricolage/streamingload/event.rb', line 138

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