funktor 0.7.25 → 0.7.28

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: 4efb77bf5008c8b7045610883ea0f0229a8ebaa89d1b5f3dd4846c3e0bc7ddd4
4
- data.tar.gz: ad9b24108efdc8747d863bc9afbf0b47fe9508c6804f48ca80eba314e681a474
3
+ metadata.gz: 2dec96dc948fcba2229478780e99336bc02441367d4e983c260bc64a91a8994a
4
+ data.tar.gz: 93da2f42dc12e42c2d589675839cc18b3c38fa9eddc479993a2d89a1064aec18
5
5
  SHA512:
6
- metadata.gz: a1d9c1547d1195bab096469043bef6bd63d4183b005a1ee6e08d60ad5f894fe79d0bdeaa33a446966566904a99a088045c66348f0eb9ca5aca1543b75adf9595
7
- data.tar.gz: ead715f1b9673487067fea8206e0bb9a0fb74bcc2a79e43bf3e07703df9a5d3f0fc3361bcde55357ef223078ed7dc1e215d325354614f379138142cc33e07bc3
6
+ metadata.gz: 93f042ad21b600a43112255347afab9ba9349f70da15961121b2281ba4f93ef5d840ea4383d38b9dd0e1f9e36fed373771182770eb6cfd27ffbff7186ea24890
7
+ data.tar.gz: 3595243efb050367bcff3a471901641fde331169ebee669049aa9543d61e1d75a0b3b495c4832ed2dc8a867732e88a378d3bbe8056fe27f8073cd4c9d8a3cf69
data/Gemfile CHANGED
@@ -5,3 +5,5 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
7
  gem "rspec", "~> 3.0"
8
+
9
+ gem 'newrelic_rpm'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- funktor (0.7.25)
4
+ funktor (0.7.28)
5
5
  activesupport
6
6
  aws-sdk-dynamodb (~> 1.62)
7
7
  aws-sdk-sqs (~> 1.37)
@@ -22,7 +22,7 @@ GEM
22
22
  addressable (2.8.0)
23
23
  public_suffix (>= 2.0.2, < 5.0)
24
24
  aws-eventstream (1.2.0)
25
- aws-partitions (1.596.0)
25
+ aws-partitions (1.597.0)
26
26
  aws-sdk-core (3.131.1)
27
27
  aws-eventstream (~> 1, >= 1.0.2)
28
28
  aws-partitions (~> 1, >= 1.525.0)
@@ -53,6 +53,7 @@ GEM
53
53
  minitest (5.14.4)
54
54
  mustermann (1.1.1)
55
55
  ruby2_keywords (~> 0.0.1)
56
+ newrelic_rpm (8.8.0)
56
57
  pry (0.13.1)
57
58
  coderay (~> 1.1)
58
59
  method_source (~> 1.0)
@@ -107,6 +108,7 @@ PLATFORMS
107
108
  DEPENDENCIES
108
109
  activejob (>= 5.1.5)
109
110
  funktor!
111
+ newrelic_rpm
110
112
  pry-byebug
111
113
  rake (~> 12.0)
112
114
  rspec (~> 3.0)
data/lib/funktor/job.rb CHANGED
@@ -114,8 +114,16 @@ module Funktor
114
114
  self.delay = seconds_to_delay(retries)
115
115
  end
116
116
 
117
- # delayed_job and sidekiq use the same basic formula
118
117
  def seconds_to_delay(count)
118
+ if worker_class&.funktor_retry_in_block
119
+ worker_class.funktor_retry_in_block.call(count)
120
+ else
121
+ default_seconds_to_delay(count)
122
+ end
123
+ end
124
+
125
+ # delayed_job and sidekiq use the same basic formula
126
+ def default_seconds_to_delay(count)
119
127
  (count**4) + 15 + (rand(30) * (count + 1))
120
128
  end
121
129
 
@@ -124,7 +132,7 @@ module Funktor
124
132
  end
125
133
 
126
134
  def retry_limit
127
- 25
135
+ worker_class&.custom_retry_limit || 25
128
136
  end
129
137
 
130
138
  def can_retry
@@ -0,0 +1,34 @@
1
+ require 'newrelic_rpm'
2
+ module Funktor
3
+ module Middleware
4
+ class NewRelic
5
+ include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
6
+
7
+ def call(job)
8
+ trace_args = {
9
+ :name => 'perform',
10
+ :class_name => job.worker_class_name_for_metrics,
11
+ :category => 'OtherTransaction/Funktor'
12
+ }
13
+ perform_action_with_newrelic_trace(trace_args) do
14
+ ::NewRelic::Agent::Transaction.merge_untrusted_agent_attributes(job.worker_params,
15
+ :'worker.funktor.params',
16
+ ::NewRelic::Agent::AttributeFilter::DST_NONE)
17
+ yield
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ def self.new_relic!
24
+ Funktor.configure_work_queue_handler do |config|
25
+ config.work_queue_handler_middleware do |chain|
26
+ chain.add Funktor::Middleware::NewRelic
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+
33
+
34
+
@@ -1,3 +1,3 @@
1
1
  module Funktor
2
- VERSION = "0.7.25"
2
+ VERSION = "0.7.28"
3
3
  end
@@ -7,6 +7,7 @@ module Funktor
7
7
  base.extend ClassMethods
8
8
  base.class_eval do
9
9
  class_attribute :funktor_options_hash
10
+ class_attribute :funktor_retry_in_block
10
11
  end
11
12
  end
12
13
  module ClassMethods
@@ -18,6 +19,10 @@ module Funktor
18
19
  self.funktor_options_hash || {}
19
20
  end
20
21
 
22
+ def funktor_retry_in(&block)
23
+ self.funktor_retry_in_block = block
24
+ end
25
+
21
26
  def custom_queue_url
22
27
  get_funktor_options[:queue_url]
23
28
  end
@@ -26,6 +31,16 @@ module Funktor
26
31
  get_funktor_options[:queue]
27
32
  end
28
33
 
34
+ def custom_retry_limit
35
+ retry_limit = get_funktor_options[:retry]
36
+ if retry_limit.nil?
37
+ retry_limit = 25
38
+ elsif !retry_limit # if someone did "retry: false"
39
+ retry_limit = 0
40
+ end
41
+ return retry_limit
42
+ end
43
+
29
44
  def queue_url
30
45
  custom_queue_url
31
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funktor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.25
4
+ version: 0.7.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Green
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-06 00:00:00.000000000 Z
11
+ date: 2022-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-sqs
@@ -261,6 +261,7 @@ files:
261
261
  - lib/funktor/job_pusher.rb
262
262
  - lib/funktor/logger.rb
263
263
  - lib/funktor/middleware/metrics.rb
264
+ - lib/funktor/middleware/new_relic.rb
264
265
  - lib/funktor/middleware_chain.rb
265
266
  - lib/funktor/rails.rb
266
267
  - lib/funktor/shard_utils.rb