lambda_punch 0.0.3 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6c2ce456599a6962dba0d2e391fe4a50b0a6b970a639ee88eba170868c801ae
4
- data.tar.gz: 94998efdef31f874202dc32ec145448734e0f3e9b1456ac298b5d26fd910d76b
3
+ metadata.gz: cec6cd5684a1a7ff22f75898d909f3189337f981d965c71d06cc53f447f2dda1
4
+ data.tar.gz: 9825e8239cea26f6b2affe8b5387a1e12f377fa0ffb6a3371bbc6a7bcc5f3910
5
5
  SHA512:
6
- metadata.gz: '018bca029eb50f631a122770588e27679c30103acfbecee14675f7d63aa346e742e8a6644b985d362cc5dfc2f04d9f49367de38d3ab04ec8a7e7afe7a4c03a9b'
7
- data.tar.gz: a5c1cf9b73241914ebb4a5761c3a89a7142bbc29db573ebddf3119e90573abe43f4308dec748184c7fce6d045f0ed72f9546ccb16c4a94e54d6bb4924b1434e4
6
+ metadata.gz: ac0557df20c73e7ff75b082a14d63e8f96e57dc1bbd288a4670e11fb1f4d402688fa17a01f9215fee5db5798b371b73d9f6fe9dfe692b5c4e8bb6c59d9577240
7
+ data.tar.gz: cea1aa8e78d416966a7d876e1035f12026e3b442cad4f95dd0935d145b012eef766a7c1a1a11332680fde1bf87af3e89023dae657130f487e00c849e2cf610f6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## [0.0.8] - 2021-06-28
2
+
3
+ - Guard against early notifier.
4
+
5
+ ## [0.0.7] - 2021-06-28
6
+
7
+ - Fix queue logger.
8
+
9
+ ## [0.0.6] - 2021-06-28
10
+
11
+ - Ensure Queue is always callable.
12
+ - Change default log level to `error`.
13
+
14
+ ## [0.0.5] - 2021-06-28
15
+
16
+ - Ensure Queue is always present.
17
+
18
+ ## [0.0.4] - 2021-06-28
19
+
20
+ - Fix install rake bug. Non-Rails rake doc.
21
+
1
22
  ## [0.0.3] - 2021-06-28
2
23
 
3
24
  - Add rake runtime dep.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lambda_punch (0.0.3)
4
+ lambda_punch (0.0.8)
5
5
  concurrent-ruby
6
6
  rake
7
7
  rb-inotify
data/README.md CHANGED
@@ -42,6 +42,13 @@ Within your project or [Rails application's](https://lamby.custominktech.com/doc
42
42
  RUN bundle exec rake lambda_punch:install
43
43
  ```
44
44
 
45
+ If you are using `LambdaPunch` with a non-Rails project, add this to your Rake file
46
+
47
+ ```ruby
48
+ spec = Gem::Specification.find_by_name 'lambda_punch'
49
+ load "#{spec.gem_dir}/lib/lambda_punch/tasks/install.rake"
50
+ ```
51
+
45
52
  ## 🧰 Usage
46
53
 
47
54
  Anywhere in your application's code, use the `LambdaPunch.push` method to add blocks of code to your jobs queue.
@@ -77,7 +84,7 @@ If your application integrates with API Gateway (which has a 30 second timeout)
77
84
 
78
85
  ### Logging
79
86
 
80
- The default log level is `fatal`, so you will not see any LambdaPunch lines in your logs. However, if you want some low level debugging information on how LambdaPunch is working, you can use this environment variable to change the log level.
87
+ The default log level is `error`, so you will not see any LambdaPunch lines in your logs. However, if you want some low level debugging information on how LambdaPunch is working, you can use this environment variable to change the log level.
81
88
 
82
89
  ```yaml
83
90
  Environment:
@@ -16,8 +16,8 @@ module LambdaPunch
16
16
  private
17
17
 
18
18
  def level
19
- l = (@level || ENV['LAMBDA_PUNCH_LOG_LEVEL'] || 'fatal').upcase.to_sym
20
- ::Logger.const_defined?(l) ? ::Logger.const_get(l) : ::Logger::FATAL
19
+ l = (@level || ENV['LAMBDA_PUNCH_LOG_LEVEL'] || 'error').upcase.to_sym
20
+ ::Logger.const_defined?(l) ? ::Logger.const_get(l) : ::Logger::ERROR
21
21
  end
22
22
 
23
23
  end
@@ -5,7 +5,7 @@ namespace :lambda_punch do
5
5
  require 'fileutils'
6
6
  FileUtils.mkdir_p '/opt/extensions'
7
7
  extension = File.expand_path "#{__dir__}/../extensions/lambdapunch"
8
- FileUtils.cp extension '/opt/extensions/'
8
+ FileUtils.cp extension, '/opt/extensions/'
9
9
  end
10
10
 
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module LambdaPunch
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -16,7 +16,7 @@ module LambdaPunch
16
16
  require 'timeout'
17
17
  require 'rb-inotify'
18
18
  DRb.start_service
19
- @queue = DRbObject.new_with_uri(Server.uri)
19
+ new_drb_queue
20
20
  end
21
21
 
22
22
  # Creates a new instance of this object with the event payload from the `LambdaPunch::Api#invoke`
@@ -26,6 +26,18 @@ module LambdaPunch
26
26
  new(event_payload).call
27
27
  end
28
28
 
29
+ # A safe and resilient way to call the remote queue.
30
+ #
31
+ def call_queue
32
+ queue.call
33
+ rescue DRb::DRbConnError
34
+ LambdaPunch.logger.error "Worker#call_queue => DRb::DRbConnError"
35
+ new_drb_queue
36
+ queue.call
37
+ end
38
+
39
+ private
40
+
29
41
  # The `@queue` object is the local process' reference to the application `LambdaPunch::Queue`
30
42
  # instance which does all the work in the applciation's scope.
31
43
  #
@@ -33,6 +45,10 @@ module LambdaPunch
33
45
  @queue
34
46
  end
35
47
 
48
+ def new_drb_queue
49
+ @queue = DRbObject.new_with_uri(Server.uri)
50
+ end
51
+
36
52
  end
37
53
 
38
54
  def initialize(event_payload)
@@ -48,12 +64,12 @@ module LambdaPunch
48
64
  # also ensures any clean up is done. For example, closing file notifications.
49
65
  #
50
66
  def call
51
- Timeout.timeout(timeout) { @notifier.process }
67
+ Timeout.timeout(timeout) { @notifier.process unless invoked? }
52
68
  rescue Timeout::Error
53
- logger.debug "Worker#call => Function timeout reached."
69
+ logger.error "Worker#call => Function timeout reached."
54
70
  ensure
55
71
  @notifier.close
56
- self.class.queue.call
72
+ self.class.call_queue
57
73
  end
58
74
 
59
75
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lambda_punch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Collins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-28 00:00:00.000000000 Z
11
+ date: 2021-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby