sidekiq-amigo 1.6.0 → 1.6.2

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: c51def3cb58812e0889c0768708747aefd3956495692ffcbb6521a1d24c6d0b0
4
- data.tar.gz: 5081debc483ce040e8c6f3a26cfacdd85094c5e70895b390f23f58f795663da3
3
+ metadata.gz: d5224634ebf95a2fcaefc764d07114cc77b2feed22a15e736eec934d8eba84b0
4
+ data.tar.gz: 2e49a507f4e6d47e7ce25b676293738591807bc47dadf47e1fdbcb634d5a9df5
5
5
  SHA512:
6
- metadata.gz: b126004a168ea18f4842bd34268fc3edb263d21de40731d178e9bd4a5db64bf403da0953b6083ea0e5c5e8d32bc9aa4faf0e66e54f0f166a077780d6573565f6
7
- data.tar.gz: 4a710ac1029e607ed60b1f448e4c443d287bcb599252801a70a17a9478e0f5c80b373f610a14034be1d2d3c98541512e64ab2f8b2bc85869b70fbc009308007d
6
+ metadata.gz: fa9617859526003317496d860e07119a11e8d0d58e66382360078a74463760b78da8516d215a0922fd40ee5bcc4d5e35421be2aa393df1f0a0709c941c367560
7
+ data.tar.gz: 99876ed52f35b972bdc1a68a507c29b87f6a0aa5db6c2ae7738e203da8c66cb5dd01a4c2489fd4a923f117e84af308ea121f2be40ea95e5a3426485da114f216
@@ -6,8 +6,12 @@ module Amigo
6
6
  class AuditLogger
7
7
  include Sidekiq::Worker
8
8
 
9
+ def audit_log_level
10
+ return :info
11
+ end
12
+
9
13
  def perform(event_json)
10
- Amigo.log(self, :info, "async_job_audit",
14
+ Amigo.log(self, self.audit_log_level, "async_job_audit",
11
15
  event_id: event_json["id"],
12
16
  event_name: event_json["name"],
13
17
  event_payload: event_json["payload"],)
@@ -22,11 +22,12 @@ module Amigo
22
22
  end
23
23
 
24
24
  def perform(*args)
25
- if args.empty?
25
+ splay = self.class.splay_duration
26
+ if splay.nil? || args == [true]
27
+ self._perform
28
+ elsif args.empty?
26
29
  jitter = rand(0..self.class.splay_duration.to_i)
27
30
  self.class.perform_in(jitter, true)
28
- elsif args == [true]
29
- self._perform
30
31
  else
31
32
  raise "ScheduledJob#perform must be called with no arguments, or [true]"
32
33
  end
@@ -62,6 +63,16 @@ module Amigo
62
63
  self.cron_expr = expr
63
64
  end
64
65
 
66
+ # When the cron job is run, it is re-enqueued
67
+ # again with a random offset. This splay prevents
68
+ # the 'thundering herd' problem, where, say, may jobs
69
+ # are meant to happen at minute 0. Instead, jobs are offset.
70
+ #
71
+ # Use +nil+ to turn off this behavior and get more precise execution.
72
+ # This is mostly useful for jobs that must run very often.
73
+ #
74
+ # +duration+ must respond to +to_i+.
75
+ # @param duration [Integer,#to_i]
65
76
  def splay(duration)
66
77
  self.splay_duration = duration
67
78
  end
data/lib/amigo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Amigo
4
- VERSION = "1.6.0"
4
+ VERSION = "1.6.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-amigo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lithic Technology
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-02 00:00:00.000000000 Z
11
+ date: 2024-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq