Class: LambdaPunch::Notifier
- Inherits:
-
Object
- Object
- LambdaPunch::Notifier
- Defined in:
- lib/lambda_punch/notifier.rb
Constant Summary collapse
- FILE =
"#{Dir.tmpdir}/lambdapunch-handled"
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize ⇒ Notifier
constructor
A new instance of Notifier.
- #process ⇒ Object
- #request_id ⇒ Object
- #watch ⇒ Object
Constructor Details
#initialize ⇒ Notifier
Returns a new instance of Notifier.
24 25 26 27 |
# File 'lib/lambda_punch/notifier.rb', line 24 def initialize @notifier = INotify::Notifier.new File.open(FILE, 'w') { |f| f.write('') } unless File.exist?(FILE) end |
Class Method Details
.handled!(context) ⇒ Object
8 9 10 11 12 |
# File 'lib/lambda_punch/notifier.rb', line 8 def handled!(context) File.open(FILE, 'w') do |f| f.write context.aws_request_id end end |
.request_id ⇒ Object
14 15 16 |
# File 'lib/lambda_punch/notifier.rb', line 14 def request_id File.read(FILE) end |
.tmp_file ⇒ Object
18 19 20 |
# File 'lib/lambda_punch/notifier.rb', line 18 def tmp_file FILE end |
Instance Method Details
#close ⇒ Object
37 38 39 40 |
# File 'lib/lambda_punch/notifier.rb', line 37 def close logger.debug "Notifier#close" @notifier.close rescue true end |
#process ⇒ Object
33 34 35 |
# File 'lib/lambda_punch/notifier.rb', line 33 def process @notifier.process end |
#request_id ⇒ Object
42 43 44 |
# File 'lib/lambda_punch/notifier.rb', line 42 def request_id self.class.request_id end |
#watch ⇒ Object
29 30 31 |
# File 'lib/lambda_punch/notifier.rb', line 29 def watch @notifier.watch(FILE, :modify, :oneshot) { yield(request_id) } end |