class Alephant::Publisher::Queue::RevalidateWriter
Attributes
message[R]
Public Class Methods
new(config, message)
click to toggle source
# File lib/alephant/publisher/queue/revalidate_writer.rb, line 9 def initialize(config, message) @config = config @message = message end
Public Instance Methods
lookup()
click to toggle source
# File lib/alephant/publisher/queue/revalidate_writer.rb, line 29 def lookup @lookup ||= Alephant::Lookup.create(config.fetch(:lookup_table_name), config) end
renderer()
click to toggle source
# File lib/alephant/publisher/queue/revalidate_writer.rb, line 21 def renderer @renderer ||= Alephant::Renderer.create(config, http_data) end
run!()
click to toggle source
# File lib/alephant/publisher/queue/revalidate_writer.rb, line 14 def run! renderer.views.each do |view_id, view| store(view_id, view) write_lookup_record(view_id) end end
storage()
click to toggle source
# File lib/alephant/publisher/queue/revalidate_writer.rb, line 25 def storage @storage ||= Alephant::Storage.new(config.fetch(:s3_bucket_id), config.fetch(:s3_object_path)) end
Private Instance Methods
config()
click to toggle source
# File lib/alephant/publisher/queue/revalidate_writer.rb, line 78 def config # @TODO: This part needs refactoring @config[:renderer_id] = message_content.fetch(:renderer_id) @config end
http_data()
click to toggle source
# File lib/alephant/publisher/queue/revalidate_writer.rb, line 84 def http_data @http_data ||= ::JSON.parse(message_content.fetch(:http_response), symbolize_names: true) end
http_options()
click to toggle source
# File lib/alephant/publisher/queue/revalidate_writer.rb, line 88 def http_options @http_options ||= message_content.fetch(:http_options) end
message_content()
click to toggle source
# File lib/alephant/publisher/queue/revalidate_writer.rb, line 92 def message_content @message_content ||= ::JSON.parse(message.body, symbolize_names: true) end
seq_id()
click to toggle source
NOTE: we really don't care about sequence here - we just have to pass something through
# File lib/alephant/publisher/queue/revalidate_writer.rb, line 62 def seq_id 1 end
storage_location(view_id)
click to toggle source
# File lib/alephant/publisher/queue/revalidate_writer.rb, line 66 def storage_location(view_id) [ config.fetch(:renderer_id), view_id, Crimp.signature(http_options) ].join('/') end
storage_opts()
click to toggle source
# File lib/alephant/publisher/queue/revalidate_writer.rb, line 74 def storage_opts { ttl: message_content[:ttl] } # @TODO: What happens if this is nil? end
store(view_id, view)
click to toggle source
# File lib/alephant/publisher/queue/revalidate_writer.rb, line 47 def store(view_id, view) storage.put(storage_location(view_id), view.render, view.content_type, storage_opts) logger.info(event: 'MessageStored', location: storage_location(view_id), view_id: view_id, view: view, content: view.render, content_type: view.content_type, storage_opts: storage_opts, renderer_id: config.fetch(:renderer_id), method: "#{self.class}#store") end
write_lookup_record(view_id)
click to toggle source
# File lib/alephant/publisher/queue/revalidate_writer.rb, line 35 def write_lookup_record(view_id) lookup.write(view_id, http_options.fetch(:options), seq_id, storage_location(view_id)) logger.info(event: 'LookupLocationUpdated', view_id: view_id, options: http_options.fetch(:options), seq_id: seq_id, location: storage_location(view_id), renderer_id: config.fetch(:renderer_id), method: "#{self.class}#write_lookup_record") end