module LambdaPunch class Notifier FILE = "#{Dir.tmpdir}/lambdapunch-handled" File.open(FILE, 'w') { |f| f.write('') } class << self def handled!(context) File.open(FILE, 'w') do |f| f.write context.aws_request_id end end def request_id File.read(FILE) end end def initialize @notifier = INotify::Notifier.new end def watch @notifier.watch(FILE, :modify, :oneshot) { yield(request_id) } end def process @notifier.process end def close logger.debug "Notifier#close" @notifier.close rescue true end def request_id self.class.request_id end private def logger LambdaPunch.logger end end end