sidekiq-unique-jobs 6.0.25 → 7.1.29

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq-unique-jobs might be problematic. Click here for more details.

Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1157 -41
  3. data/README.md +825 -291
  4. data/lib/sidekiq_unique_jobs/batch_delete.rb +124 -0
  5. data/lib/sidekiq_unique_jobs/changelog.rb +78 -0
  6. data/lib/sidekiq_unique_jobs/cli.rb +57 -29
  7. data/lib/sidekiq_unique_jobs/config.rb +319 -0
  8. data/lib/sidekiq_unique_jobs/connection.rb +6 -5
  9. data/lib/sidekiq_unique_jobs/constants.rb +46 -25
  10. data/lib/sidekiq_unique_jobs/core_ext.rb +80 -0
  11. data/lib/sidekiq_unique_jobs/deprecation.rb +65 -0
  12. data/lib/sidekiq_unique_jobs/digests.rb +70 -102
  13. data/lib/sidekiq_unique_jobs/exceptions.rb +88 -12
  14. data/lib/sidekiq_unique_jobs/expiring_digests.rb +14 -0
  15. data/lib/sidekiq_unique_jobs/job.rb +41 -12
  16. data/lib/sidekiq_unique_jobs/json.rb +47 -0
  17. data/lib/sidekiq_unique_jobs/key.rb +98 -0
  18. data/lib/sidekiq_unique_jobs/lock/base_lock.rb +111 -82
  19. data/lib/sidekiq_unique_jobs/lock/client_validator.rb +28 -0
  20. data/lib/sidekiq_unique_jobs/lock/server_validator.rb +27 -0
  21. data/lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb +40 -15
  22. data/lib/sidekiq_unique_jobs/lock/until_executed.rb +29 -7
  23. data/lib/sidekiq_unique_jobs/lock/until_executing.rb +26 -2
  24. data/lib/sidekiq_unique_jobs/lock/until_expired.rb +27 -15
  25. data/lib/sidekiq_unique_jobs/lock/validator.rb +96 -0
  26. data/lib/sidekiq_unique_jobs/lock/while_executing.rb +26 -12
  27. data/lib/sidekiq_unique_jobs/lock/while_executing_reject.rb +3 -3
  28. data/lib/sidekiq_unique_jobs/lock.rb +342 -0
  29. data/lib/sidekiq_unique_jobs/lock_args.rb +127 -0
  30. data/lib/sidekiq_unique_jobs/lock_config.rb +126 -0
  31. data/lib/sidekiq_unique_jobs/lock_digest.rb +79 -0
  32. data/lib/sidekiq_unique_jobs/lock_info.rb +68 -0
  33. data/lib/sidekiq_unique_jobs/lock_timeout.rb +62 -0
  34. data/lib/sidekiq_unique_jobs/lock_ttl.rb +77 -0
  35. data/lib/sidekiq_unique_jobs/locksmith.rb +295 -101
  36. data/lib/sidekiq_unique_jobs/logging/middleware_context.rb +44 -0
  37. data/lib/sidekiq_unique_jobs/logging.rb +202 -33
  38. data/lib/sidekiq_unique_jobs/lua/delete.lua +51 -0
  39. data/lib/sidekiq_unique_jobs/lua/delete_by_digest.lua +42 -0
  40. data/lib/sidekiq_unique_jobs/lua/delete_job_by_digest.lua +38 -0
  41. data/lib/sidekiq_unique_jobs/lua/find_digest_in_queues.lua +26 -0
  42. data/lib/sidekiq_unique_jobs/lua/lock.lua +99 -0
  43. data/lib/sidekiq_unique_jobs/lua/lock_until_expired.lua +92 -0
  44. data/lib/sidekiq_unique_jobs/lua/locked.lua +35 -0
  45. data/lib/sidekiq_unique_jobs/lua/queue.lua +87 -0
  46. data/lib/sidekiq_unique_jobs/lua/reap_orphans.lua +122 -0
  47. data/lib/sidekiq_unique_jobs/lua/shared/_common.lua +40 -0
  48. data/lib/sidekiq_unique_jobs/lua/shared/_current_time.lua +8 -0
  49. data/lib/sidekiq_unique_jobs/lua/shared/_delete_from_queue.lua +22 -0
  50. data/lib/sidekiq_unique_jobs/lua/shared/_delete_from_sorted_set.lua +18 -0
  51. data/lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua +53 -0
  52. data/lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_queues.lua +43 -0
  53. data/lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_sorted_set.lua +24 -0
  54. data/lib/sidekiq_unique_jobs/lua/shared/_hgetall.lua +13 -0
  55. data/lib/sidekiq_unique_jobs/lua/shared/_upgrades.lua +3 -0
  56. data/lib/sidekiq_unique_jobs/lua/unlock.lua +107 -0
  57. data/lib/sidekiq_unique_jobs/lua/update_version.lua +40 -0
  58. data/lib/sidekiq_unique_jobs/lua/upgrade.lua +68 -0
  59. data/lib/sidekiq_unique_jobs/middleware/client.rb +42 -0
  60. data/lib/sidekiq_unique_jobs/middleware/server.rb +31 -0
  61. data/lib/sidekiq_unique_jobs/middleware.rb +29 -43
  62. data/lib/sidekiq_unique_jobs/normalizer.rb +4 -4
  63. data/lib/sidekiq_unique_jobs/on_conflict/log.rb +9 -5
  64. data/lib/sidekiq_unique_jobs/on_conflict/null_strategy.rb +1 -1
  65. data/lib/sidekiq_unique_jobs/on_conflict/raise.rb +1 -1
  66. data/lib/sidekiq_unique_jobs/on_conflict/reject.rb +63 -17
  67. data/lib/sidekiq_unique_jobs/on_conflict/replace.rb +54 -14
  68. data/lib/sidekiq_unique_jobs/on_conflict/reschedule.rb +16 -5
  69. data/lib/sidekiq_unique_jobs/on_conflict/strategy.rb +25 -6
  70. data/lib/sidekiq_unique_jobs/on_conflict.rb +23 -10
  71. data/lib/sidekiq_unique_jobs/options_with_fallback.rb +38 -35
  72. data/lib/sidekiq_unique_jobs/orphans/lua_reaper.rb +29 -0
  73. data/lib/sidekiq_unique_jobs/orphans/manager.rb +241 -0
  74. data/lib/sidekiq_unique_jobs/orphans/null_reaper.rb +24 -0
  75. data/lib/sidekiq_unique_jobs/orphans/observer.rb +42 -0
  76. data/lib/sidekiq_unique_jobs/orphans/reaper.rb +114 -0
  77. data/lib/sidekiq_unique_jobs/orphans/reaper_resurrector.rb +170 -0
  78. data/lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb +298 -0
  79. data/lib/sidekiq_unique_jobs/redis/entity.rb +112 -0
  80. data/lib/sidekiq_unique_jobs/redis/hash.rb +56 -0
  81. data/lib/sidekiq_unique_jobs/redis/list.rb +32 -0
  82. data/lib/sidekiq_unique_jobs/redis/set.rb +32 -0
  83. data/lib/sidekiq_unique_jobs/redis/sorted_set.rb +86 -0
  84. data/lib/sidekiq_unique_jobs/redis/string.rb +51 -0
  85. data/lib/sidekiq_unique_jobs/redis.rb +11 -0
  86. data/lib/sidekiq_unique_jobs/reflectable.rb +26 -0
  87. data/lib/sidekiq_unique_jobs/reflections.rb +79 -0
  88. data/lib/sidekiq_unique_jobs/rspec/matchers/have_valid_sidekiq_options.rb +51 -0
  89. data/lib/sidekiq_unique_jobs/rspec/matchers.rb +26 -0
  90. data/lib/sidekiq_unique_jobs/script/caller.rb +127 -0
  91. data/lib/sidekiq_unique_jobs/script.rb +15 -0
  92. data/lib/sidekiq_unique_jobs/server.rb +61 -0
  93. data/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb +114 -65
  94. data/lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb +251 -35
  95. data/lib/sidekiq_unique_jobs/sidekiq_worker_methods.rb +47 -32
  96. data/lib/sidekiq_unique_jobs/testing.rb +102 -29
  97. data/lib/sidekiq_unique_jobs/timer_task.rb +299 -0
  98. data/lib/sidekiq_unique_jobs/timing.rb +58 -0
  99. data/lib/sidekiq_unique_jobs/unlockable.rb +20 -4
  100. data/lib/sidekiq_unique_jobs/update_version.rb +25 -0
  101. data/lib/sidekiq_unique_jobs/upgrade_locks.rb +155 -0
  102. data/lib/sidekiq_unique_jobs/version.rb +3 -1
  103. data/lib/sidekiq_unique_jobs/version_check.rb +23 -4
  104. data/lib/sidekiq_unique_jobs/web/helpers.rb +138 -13
  105. data/lib/sidekiq_unique_jobs/web/views/_paging.erb +4 -4
  106. data/lib/sidekiq_unique_jobs/web/views/changelogs.erb +54 -0
  107. data/lib/sidekiq_unique_jobs/web/views/lock.erb +108 -0
  108. data/lib/sidekiq_unique_jobs/web/views/locks.erb +54 -0
  109. data/lib/sidekiq_unique_jobs/web.rb +76 -27
  110. data/lib/sidekiq_unique_jobs.rb +53 -7
  111. data/lib/tasks/changelog.rake +16 -16
  112. metadata +133 -177
  113. data/lib/sidekiq_unique_jobs/client/middleware.rb +0 -56
  114. data/lib/sidekiq_unique_jobs/scripts.rb +0 -118
  115. data/lib/sidekiq_unique_jobs/server/middleware.rb +0 -46
  116. data/lib/sidekiq_unique_jobs/timeout/calculator.rb +0 -63
  117. data/lib/sidekiq_unique_jobs/timeout.rb +0 -8
  118. data/lib/sidekiq_unique_jobs/unique_args.rb +0 -150
  119. data/lib/sidekiq_unique_jobs/util.rb +0 -103
  120. data/lib/sidekiq_unique_jobs/web/views/unique_digest.erb +0 -28
  121. data/lib/sidekiq_unique_jobs/web/views/unique_digests.erb +0 -46
  122. data/redis/acquire_lock.lua +0 -21
  123. data/redis/convert_legacy_lock.lua +0 -13
  124. data/redis/delete.lua +0 -14
  125. data/redis/delete_by_digest.lua +0 -23
  126. data/redis/delete_job_by_digest.lua +0 -60
  127. data/redis/lock.lua +0 -62
  128. data/redis/release_stale_locks.lua +0 -90
  129. data/redis/unlock.lua +0 -35
@@ -0,0 +1,155 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SidekiqUniqueJobs
4
+ #
5
+ # Upgrades locks between gem version upgrades
6
+ #
7
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
8
+ #
9
+ class UpgradeLocks # rubocop:disable Metrics/ClassLength
10
+ #
11
+ # @return [Integer] the number of keys to batch upgrade
12
+ BATCH_SIZE = 100
13
+ #
14
+ # @return [Array<String>] suffixes for old version
15
+ OLD_SUFFIXES = %w[
16
+ GRABBED
17
+ AVAILABLE
18
+ EXISTS
19
+ VERSION
20
+ ].freeze
21
+
22
+ include SidekiqUniqueJobs::Logging
23
+ include SidekiqUniqueJobs::Connection
24
+
25
+ #
26
+ # Performs upgrade of old locks
27
+ #
28
+ #
29
+ # @return [Integer] the number of upgrades locks
30
+ #
31
+ def self.call
32
+ redis do |conn|
33
+ new(conn).call
34
+ end
35
+ end
36
+
37
+ attr_reader :conn
38
+
39
+ def initialize(conn)
40
+ @count = 0
41
+ @conn = conn
42
+ redis_version # Avoid pipelined calling redis_version and getting a future.
43
+ end
44
+
45
+ #
46
+ # Performs upgrade of old locks
47
+ #
48
+ #
49
+ # @return [Integer] the number of upgrades locks
50
+ #
51
+ def call
52
+ with_logging_context do
53
+ return log_info("Already upgraded to #{version}") if conn.hget(upgraded_key, version)
54
+ # TODO: Needs handling of v7.0.0 => v7.0.1 where we don't want to
55
+ return log_info("Skipping upgrade because #{DEAD_VERSION} has been set") if conn.get(DEAD_VERSION)
56
+
57
+ log_info("Start - Upgrading Locks")
58
+
59
+ upgrade_v6_locks
60
+ delete_unused_v6_keys
61
+ delete_supporting_v6_keys
62
+
63
+ conn.hset(upgraded_key, version, now_f)
64
+ log_info("Done - Upgrading Locks")
65
+ end
66
+
67
+ @count
68
+ end
69
+
70
+ private
71
+
72
+ def upgraded_key
73
+ @upgraded_key ||= "#{LIVE_VERSION}:UPGRADED"
74
+ end
75
+
76
+ def upgrade_v6_locks
77
+ log_info("Start - Converting v6 locks to v7")
78
+ conn.scan_each(match: "*:GRABBED", count: BATCH_SIZE) do |grabbed_key|
79
+ upgrade_v6_lock(grabbed_key)
80
+ @count += 1
81
+ end
82
+ log_info("Done - Converting v6 locks to v7")
83
+ end
84
+
85
+ def upgrade_v6_lock(grabbed_key)
86
+ locked_key = grabbed_key.gsub(":GRABBED", ":LOCKED")
87
+ digest = grabbed_key.gsub(":GRABBED", "")
88
+ locks = conn.hgetall(grabbed_key)
89
+
90
+ conn.pipelined do |pipeline|
91
+ pipeline.hmset(locked_key, *locks.to_a)
92
+ pipeline.zadd(DIGESTS, locks.values.first, digest)
93
+ end
94
+ end
95
+
96
+ def delete_unused_v6_keys
97
+ log_info("Start - Deleting v6 keys")
98
+ OLD_SUFFIXES.each do |suffix|
99
+ delete_suffix(suffix)
100
+ end
101
+ log_info("Done - Deleting v6 keys")
102
+ end
103
+
104
+ def delete_supporting_v6_keys
105
+ batch_delete("unique:keys")
106
+ end
107
+
108
+ def delete_suffix(suffix)
109
+ batch_scan(match: "*:#{suffix}", count: BATCH_SIZE) do |keys|
110
+ batch_delete(*keys)
111
+ end
112
+ end
113
+
114
+ def batch_delete(*keys)
115
+ return if keys.empty?
116
+
117
+ conn.pipelined do |pipeline|
118
+ if VersionCheck.satisfied?(redis_version, ">= 4.0.0")
119
+ pipeline.unlink(*keys)
120
+ else
121
+ pipeline.del(*keys)
122
+ end
123
+ end
124
+ end
125
+
126
+ def batch_scan(match:, count:)
127
+ cursor = "0"
128
+ loop do
129
+ cursor, values = conn.scan(cursor, match: match, count: count)
130
+ yield values
131
+ break if cursor == "0"
132
+ end
133
+ end
134
+
135
+ def version
136
+ SidekiqUniqueJobs.version
137
+ end
138
+
139
+ def now_f
140
+ SidekiqUniqueJobs.now_f
141
+ end
142
+
143
+ def redis_version
144
+ @redis_version ||= SidekiqUniqueJobs.config.redis_version
145
+ end
146
+
147
+ def logging_context
148
+ if logger_context_hash?
149
+ { "uniquejobs" => :upgrade_locks }
150
+ else
151
+ "uniquejobs-upgrade_locks"
152
+ end
153
+ end
154
+ end
155
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SidekiqUniqueJobs
4
- VERSION = "6.0.25"
4
+ #
5
+ # @return [String] the current SidekiqUniqueJobs version
6
+ VERSION = "7.1.29"
5
7
  end
@@ -4,13 +4,13 @@ module SidekiqUniqueJobs
4
4
  #
5
5
  # Handles checking if a version is compliant with given constraint
6
6
  #
7
- # @author Mikael Henriksson <mikael@zoolutions.se>
7
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
8
8
  #
9
9
  class VersionCheck
10
- PATTERN = /(?<operator1>[<>=]+)?\s?(?<version1>(\d+.?)+)(\s+&&\s+)?(?<operator2>[<>=]+)?\s?(?<version2>(\d+.?)+)?/m.freeze # rubocop:disable Layout/LineLength
10
+ PATTERN = /(?<operator1>[<>=]+)?\s?(?<version1>(\d+.?)+)(\s+&&\s+)?(?<operator2>[<>=]+)?\s?(?<version2>(\d+.?)+)?/m.freeze # rubocop:disable Layout/LineLength, Lint/MixedRegexpCaptureTypes
11
11
 
12
12
  #
13
- # Checks if a version is consrtaint is satisfied
13
+ # Checks if a version is constraint is satisfied
14
14
  #
15
15
  # @example A satisfied constraint
16
16
  # VersionCheck.satisfied?("5.0.0", ">= 4.0.0") #=> true
@@ -22,12 +22,31 @@ module SidekiqUniqueJobs
22
22
  # @param [String] version a version string `5.0.0`
23
23
  # @param [String] constraint a version constraint `>= 5.0.0 <= 5.1.1`
24
24
  #
25
- # @return [<type>] <description>
25
+ # @return [true, false] <description>
26
26
  #
27
27
  def self.satisfied?(version, constraint)
28
28
  new(version, constraint).satisfied?
29
29
  end
30
30
 
31
+ #
32
+ # Checks if a version is constraint is unfulfilled
33
+ #
34
+ # @example A satisfied constraint
35
+ # VersionCheck.unfulfilled?("5.0.0", ">= 4.0.0") #=> false
36
+ #
37
+ # @example An unfulfilled constraint
38
+ # VersionCheck.unfulfilled?("5.0.0", "<= 4.0.0") #=> true
39
+ #
40
+ #
41
+ # @param [String] version a version string `5.0.0`
42
+ # @param [String] constraint a version constraint `>= 5.0.0 <= 5.1.1`
43
+ #
44
+ # @return [true, false] <description>
45
+ #
46
+ def self.unfulfilled?(version, constraint)
47
+ !satisfied?(version, constraint)
48
+ end
49
+
31
50
  #
32
51
  # @!attribute [r] version
33
52
  # @return [String] a version string `5.0.0`
@@ -2,28 +2,120 @@
2
2
 
3
3
  module SidekiqUniqueJobs
4
4
  module Web
5
+ #
6
+ # Provides view helpers for the Sidekiq::Web extension
7
+ #
8
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
9
+ #
5
10
  module Helpers
6
- VIEW_PATH = File.expand_path("../web/views", __dir__)
11
+ #
12
+ # @return [String] the path to gem specific views
13
+ VIEW_PATH = File.expand_path("../web/views", __dir__).freeze
14
+ #
15
+ # @return [Array<String>] safe params
16
+ SAFE_CPARAMS = %w[
17
+ filter count cursor prev_cursor poll direction
18
+ ].freeze
7
19
 
20
+ extend self
21
+
22
+ #
23
+ # Opens a template file contained within this gem
24
+ #
25
+ # @param [Symbol] name the name of the template
26
+ #
27
+ # @return [String] the file contents of the template
28
+ #
8
29
  def unique_template(name)
9
- File.open(File.join(VIEW_PATH, "#{name}.erb")).read
30
+ File.read(unique_filename(name))
10
31
  end
11
32
 
12
- SAFE_CPARAMS = %w[cursor prev_cursor].freeze
33
+ #
34
+ # Construct template file name
35
+ #
36
+ # @param [Symbol] name the name of the template
37
+ #
38
+ # @return [String] the full name of the file
39
+ #
40
+ def unique_filename(name)
41
+ File.join(VIEW_PATH, "#{name}.erb")
42
+ end
13
43
 
14
- def cparams(options)
15
- # stringify
16
- options.keys.each do |key|
17
- options[key.to_s] = options.delete(key)
18
- end
44
+ #
45
+ # The collection of digests
46
+ #
47
+ #
48
+ # @return [SidekiqUniqueJobs::Digests] the sorted set with digests
49
+ #
50
+ def digests
51
+ @digests ||= SidekiqUniqueJobs::Digests.new
52
+ end
19
53
 
20
- params.merge(options).map do |key, value|
54
+ #
55
+ # The collection of digests
56
+ #
57
+ #
58
+ # @return [SidekiqUniqueJobs::ExpiringDigests] the sorted set with expiring digests
59
+ #
60
+ def expiring_digests
61
+ @expiring_digests ||= SidekiqUniqueJobs::ExpiringDigests.new
62
+ end
63
+
64
+ #
65
+ # The collection of changelog entries
66
+ #
67
+ #
68
+ # @return [SidekiqUniqueJobs::Digests] the sorted set with digests
69
+ #
70
+ def changelog
71
+ @changelog ||= SidekiqUniqueJobs::Changelog.new
72
+ end
73
+
74
+ #
75
+ # Creates url safe parameters
76
+ #
77
+ # @param [Hash] options the key/value to parameterize
78
+ #
79
+ # @return [String] a url safe parameter string
80
+ #
81
+ def cparams(options)
82
+ stringified_options = options.transform_keys(&:to_s)
83
+ params.merge(stringified_options).map do |key, value|
21
84
  next unless SAFE_CPARAMS.include?(key)
22
85
 
23
86
  "#{key}=#{CGI.escape(value.to_s)}"
24
87
  end.compact.join("&")
25
88
  end
26
89
 
90
+ #
91
+ # Used to avoid incompatibility with older sidekiq versions
92
+ #
93
+ #
94
+ # @param [Array] args the unique arguments to display
95
+ # @param [Integer] truncate_after_chars
96
+ #
97
+ # @return [String] a string containing all non-truncated arguments
98
+ #
99
+ def display_lock_args(args, truncate_after_chars = 2000)
100
+ return "Invalid job payload, args is nil" if args.nil?
101
+ return "Invalid job payload, args must be an Array, not #{args.class.name}" unless args.is_a?(Array)
102
+
103
+ begin
104
+ args.map do |arg|
105
+ h(truncate(to_display(arg), truncate_after_chars))
106
+ end.join(", ")
107
+ rescue StandardError
108
+ "Illegal job arguments: #{h args.inspect}"
109
+ end
110
+ end
111
+
112
+ #
113
+ # Redirect to with falback
114
+ #
115
+ # @param [String] subpath the path to redirect to
116
+ #
117
+ # @return a redirect to the new subpath
118
+ #
27
119
  def redirect_to(subpath)
28
120
  if respond_to?(:to)
29
121
  # Sinatra-based web UI
@@ -34,14 +126,47 @@ module SidekiqUniqueJobs
34
126
  end
35
127
  end
36
128
 
129
+ #
130
+ # Gets a relative time as html
131
+ #
132
+ # @param [Time] time an instance of Time
133
+ #
134
+ # @return [String] a html safe string with relative time information
135
+ #
136
+ def relative_time(time)
137
+ stamp = time.getutc.iso8601
138
+ %(<time class="ltr" dir="ltr" title="#{stamp}" datetime="#{stamp}">#{time}</time>)
139
+ end
140
+
141
+ #
142
+ # Gets a relative time as html without crashing
143
+ #
144
+ # @param [Float, Integer, String, Time] time a representation of a timestamp
145
+ #
146
+ # @return [String] a html safe string with relative time information
147
+ #
37
148
  def safe_relative_time(time)
38
- time = if time.is_a?(Numeric)
149
+ time = parse_time(time)
150
+
151
+ relative_time(time)
152
+ end
153
+
154
+ #
155
+ # Constructs a time from a number of different types
156
+ #
157
+ # @param [Float, Integer, String, Time] time a representation of a timestamp
158
+ #
159
+ # @return [Time]
160
+ #
161
+ def parse_time(time)
162
+ case time
163
+ when Time
164
+ time
165
+ when Integer, Float
39
166
  Time.at(time)
40
167
  else
41
- Time.parse(time)
168
+ Time.parse(time.to_s)
42
169
  end
43
-
44
- relative_time(time)
45
170
  end
46
171
  end
47
172
  end
@@ -1,10 +1,10 @@
1
1
  <ul class="pagination pull-right flip">
2
2
  <% if @prev_cursor %>
3
- <li>
4
- <a href="<%= url %>?<%= cparams(cursor: @prev_cursor, prev_cursor: @next_cursor) %>">Previous <%= @count %></a>
5
- </li>
3
+ <li>
4
+ <a href="<%= url %>?<%= cparams(filter: @filter, cursor: @prev_cursor, prev_cursor: @next_cursor) %>">Previous <%= @count %></a>
5
+ </li>
6
6
  <% end %>
7
7
  <li>
8
- <a href="<%= url %>?<%= cparams(cursor: @next_cursor, prev_cursor: @current_cursor) %>">Next <%= @count %></a>
8
+ <a href="<%= url %>?<%= cparams(filter: @filter, cursor: @next_cursor, prev_cursor: @current_cursor) %>">Next <%= @count %></a>
9
9
  </li>
10
10
  </ul>
@@ -0,0 +1,54 @@
1
+ <header class="row">
2
+ <div class="col-sm-5">
3
+ <h3>
4
+ <%= t('Changelog Entries') %>
5
+ </h3>
6
+ </div>
7
+ <form action="<%= root_path %>changelogs" class="form form-inline" method="get">
8
+ <%= csrf_tag %>
9
+ <input name="filter" class="form-control" type="text" value="<%= @filter %>" />
10
+ <button class="btn btn-default" type="submit">
11
+ <%= t('Filter') %>
12
+ </button>
13
+ </form>
14
+ <% if @changelogs.any? && @total_size > @count.to_i %>
15
+ <div class="col-sm-4">
16
+ <%= erb unique_template(:_paging), locals: { url: "#{root_path}changelogs" } %>
17
+ </div>
18
+ <% end %>
19
+ </header>
20
+ <% if @changelogs.any? %>
21
+ <div class="table_container">
22
+ <form action="<%= root_path %>changelogs/delete_all" method="get">
23
+ <input class="btn btn-danger btn-xs" type="submit" name="delete_all" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSure') %>" />
24
+ </form>
25
+ <br/>
26
+ <table class="table table-striped table-bordered table-hover">
27
+ <thead>
28
+ <tr>
29
+ <th><%= t('Time') %></th>
30
+ <th><%= t('Digest') %></th>
31
+ <th><%= t('Script') %></th>
32
+ <th><%= t('JID') %></th>
33
+ <th><%= t('Prev JID') %></th>
34
+ <th><%= t('Message') %></th>
35
+ </tr>
36
+ </thead>
37
+ <tbody>
38
+ <% @changelogs.each do |changelog| %>
39
+ <tr class="changelog-row">
40
+ <td><%= safe_relative_time(changelog["time"]) %></td>
41
+ <td><%= changelog["digest"] %></td>
42
+ <td><%= changelog["script"] %></td>
43
+ <td><%= changelog["job_id"] %></td>
44
+ <td><%= changelog["prev_jid"] %></td>
45
+ <td><%= changelog["message"] %></th>
46
+ </tr>
47
+ <% end %>
48
+ </tbody>
49
+ </table>
50
+ <form action="<%= root_path %>changelogs/delete_all" method="get">
51
+ <input class="btn btn-danger btn-xs" type="submit" name="delete_all" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSure') %>" />
52
+ </form>
53
+ </div>
54
+ <% end %>
@@ -0,0 +1,108 @@
1
+ <header class="row">
2
+ <div class="col-sm-5">
3
+ <h3>
4
+ <%= t('Lock information') %> <a class="btn btn-default btn-xs" href="<%= root_path %>locks"><%= t('GoBack') %></a>
5
+ </h3>
6
+ </div>
7
+ <div class="col-sm-7 table-responsive">
8
+ <% if @lock.info.none? %>
9
+ <h3>No Lock Information Available</h3>
10
+ <p>To use it turn the following setting on:
11
+ <code>SidekiqUniqueJobs.config.lock_info = true</code>
12
+ </p>
13
+ <% else %>
14
+ <table class="table table-striped table-bordered table-white table-hover">
15
+ <caption>Information about lock</caption>
16
+ <tbody>
17
+ <tr>
18
+ <th scope=row><%= t('Worker') %></td>
19
+ <td><%= @lock.info["worker"] %></td>
20
+ </tr>
21
+ <tr>
22
+ <th scope=row><%= t('Queue') %></td>
23
+ <td><%= @lock.info["queue"] %></td>
24
+ </tr>
25
+ <tr>
26
+ <th scope=row><%= t('Limit') %></td>
27
+ <td><%= @lock.info["limit"] %></td>
28
+ </tr>
29
+ <tr>
30
+ <th scope=row><%= t('TTL') %></td>
31
+ <td><%= @lock.info["ttl"] %></td>
32
+ </tr>
33
+ <tr>
34
+ <th scope=row><%= t('Timeout') %></td>
35
+ <td><%= @lock.info["timeout"] %></td>
36
+ </tr>
37
+ <tr>
38
+ <th scope=row><%= t('Args') %></td>
39
+ <td>
40
+ <code class="code-wrap">
41
+ <!-- We don't want to truncate any job arguments when viewing a single job's status page -->
42
+ <div class="args-extended"><%= display_lock_args(@lock.info["lock_args"], nil) %></div>
43
+ </code>
44
+ </td>
45
+ </tr>
46
+ </tbody>
47
+ </table>
48
+ <% end %>
49
+ </div>
50
+ </header>
51
+ <div class="row">
52
+ <div class="col-sm-6 table-responsive">
53
+ <table class="table table-striped table-bordered table-hover">
54
+ <caption>Digest: <strong class="text-muted"><%= @lock.key %></strong></caption>
55
+ <thead>
56
+ <tr>
57
+ <th scope="col"><%= t('Locked JIDs') %></th>
58
+ <th scope="col"><%= t('Since') %></th>
59
+ <th scope="col"></th>
60
+ </tr>
61
+ </thead>
62
+ <tbody>
63
+ <% @lock.locked_jids(with_values: true).each do |job_id, time| %>
64
+ <tr>
65
+ <td><%= job_id %></td>
66
+ <td><%= safe_relative_time(time.to_f) %></td>
67
+ <td>
68
+ <form action="<%= root_path %>locks/<%= @lock.key %>/jobs/<%= job_id %>/delete" method="get">
69
+ <%= csrf_tag %>
70
+ <input class="btn btn-danger btn-xs flip" type="submit" name="delete" value="<%= t('Unlock') %>" data-confirm="<%= t('AreYouSure') %>" />
71
+ </form>
72
+ </td>
73
+ </tr>
74
+ <% end %>
75
+ </tbody>
76
+ </table>
77
+ </div>
78
+ <div class="col-sm-6 table-responsive">
79
+ <% if @lock.changelog.count.positive? %>
80
+ <table class="table table-striped table-bordered table-hover">
81
+ <caption>Changelogs</caption>
82
+ <thead>
83
+ <tr>
84
+ <th scope="col"><%= t('At') %></th>
85
+ <th scope="col"><%= t('JID') %></th>
86
+ <th scope="col"><%= t('Message') %></th>
87
+ <th scope="col"><%= t('Script') %></th>
88
+ </tr>
89
+ </thead>
90
+ <tbody>
91
+ <% @lock.changelogs.each do |entry| %>
92
+ <tr>
93
+ <td scope="row"><%= safe_relative_time(entry["time"].to_f) %></td>
94
+ <td><%= entry["job_id"] %></td>
95
+ <td><%= entry["message"] %></td>
96
+ <td><%= entry["script"] %></td>
97
+ </tr>
98
+ <% end %>
99
+ </tbody>
100
+ </table>
101
+ <% end %>
102
+ </div>
103
+ </div>
104
+ <form action="<%= root_path %>locks/<%= @lock.key %>/delete" method="get">
105
+ <%= csrf_tag %>
106
+ <a class="btn btn-default btn-xs" href="<%= root_path %>locks"><%= t('GoBack') %></a>
107
+ <input class="btn btn-danger btn-xs flip" type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSure') %>" />
108
+ </form>
@@ -0,0 +1,54 @@
1
+ <header class="row">
2
+ <div class="col-sm-5">
3
+ <h3>
4
+ <%= t('Locks') %>
5
+ </h3>
6
+ </div>
7
+ <form action="<%= root_path %>locks" class="form form-inline" method="get">
8
+ <%= csrf_tag %>
9
+ <input name="filter" class="form-control" type="text" value="<%= @filter %>" />
10
+ <button class="btn btn-default" type="submit">
11
+ <%= t('Filter') %>
12
+ </button>
13
+ </form>
14
+ <% if @locks.any? && @total_size > @count %>
15
+ <div class="col-sm-4">
16
+ <%= erb unique_template(:_paging), locals: { url: "#{root_path}locks" } %>
17
+ </div>
18
+ <% end %>
19
+ </header>
20
+ <% if @locks.any? %>
21
+ <div class="table_container">
22
+ <table class="table table-striped table-bordered table-hover">
23
+ <thead>
24
+ <tr>
25
+ <th><%= t('Delete') %></th>
26
+ <th><%= t('Digest') %></th>
27
+ <th><%= t('Lock') %></th>
28
+ <th><%= t('Locks') %></th>
29
+ <th><%= t('Since') %></th>
30
+ </tr>
31
+ </thead>
32
+ <% @locks.each do |lock| %>
33
+ <tbody>
34
+ <tr class="lock-row">
35
+ <td>
36
+ <form action="<%= root_path %>locks/<%= lock.key %>/delete" method="get">
37
+ <%= csrf_tag %>
38
+ <input name="lock" value="<%= h lock.key %>" type="hidden" />
39
+ <input class="btn btn-danger btn-xs" type="submit" name="delete" value="<%= t('Delete') %>" data-confirm="<%= t('AreYouSure') %>" />
40
+ </form>
41
+ </td>
42
+ <td><a href="<%= root_path %>locks/<%= lock.key %>"><%= lock.key %></a></td>
43
+ <td><%= lock.info["lock"] %></td>
44
+ <td><%= lock.locked.count %></td>
45
+ <td><%= safe_relative_time(lock.created_at) %></td>
46
+ </tr>
47
+ </tbody>
48
+ <% end %>
49
+ </table>
50
+ <form action="<%= root_path %>locks/delete_all" method="get">
51
+ <input class="btn btn-danger btn-xs" type="submit" name="delete_all" value="<%= t('DeleteAll') %>" data-confirm="<%= t('AreYouSure') %>" />
52
+ </form>
53
+ </div>
54
+ <% end %>