Sha256: eea77129d3f16cdd9a9001152dc9ff1d98f1075171ec4d025c2cdde0862e2520

Contents?: true

Size: 772 Bytes

Versions: 8

Compression:

Stored size: 772 Bytes

Contents

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lambda_punch-1.0.0 lib/lambda_punch/notifier.rb
lambda_punch-0.0.8 lib/lambda_punch/notifier.rb
lambda_punch-0.0.7 lib/lambda_punch/notifier.rb
lambda_punch-0.0.6 lib/lambda_punch/notifier.rb
lambda_punch-0.0.5 lib/lambda_punch/notifier.rb
lambda_punch-0.0.4 lib/lambda_punch/notifier.rb
lambda_punch-0.0.3 lib/lambda_punch/notifier.rb
lambda_punch-0.0.2 lib/lambda_punch/notifier.rb