Class: Sideq::Retries
- Inherits:
-
Object
- Object
- Sideq::Retries
- Defined in:
- lib/sideq/retries.rb
Instance Attribute Summary collapse
-
#retry_set ⇒ Object
readonly
Returns the value of attribute retry_set.
Instance Method Summary collapse
- #clear ⇒ Object
- #delete_entries(job_ids) ⇒ Object
- #details(job_ids) ⇒ Object
-
#initialize ⇒ Retries
constructor
A new instance of Retries.
- #kill_entries(job_ids) ⇒ Object
- #retry_entries(job_ids) ⇒ Object
- #to_csv ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Retries
Returns a new instance of Retries.
5 6 7 |
# File 'lib/sideq/retries.rb', line 5 def initialize @retry_set = Sidekiq::RetrySet.new end |
Instance Attribute Details
#retry_set ⇒ Object (readonly)
Returns the value of attribute retry_set.
3 4 5 |
# File 'lib/sideq/retries.rb', line 3 def retry_set @retry_set end |
Instance Method Details
#clear ⇒ Object
81 82 83 84 85 |
# File 'lib/sideq/retries.rb', line 81 def clear size = retry_set.size retry_set.clear puts "Retry Set: Deleted #{size} entries" end |
#delete_entries(job_ids) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/sideq/retries.rb', line 51 def delete_entries( job_ids ) deleted = 0 each_job( job_ids ) do |job| job.delete puts "#{job.jid}: deleted" deleted += 1 end puts "Retry Set: Deleted #{deleted} entries" end |
#details(job_ids) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/sideq/retries.rb', line 44 def details( job_ids ) retry_set.each_with_object( [] ) do |job, memo| next unless job_ids.include?( job.jid ) memo << job_details( job ) end.join( "\n\n" ) end |
#kill_entries(job_ids) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/sideq/retries.rb', line 61 def kill_entries( job_ids ) killed = 0 each_job( job_ids ) do |job| job.kill puts "#{job.jid}: moved to dead set" killed += 1 end puts "Retry Set: Moved #{killed} entries to Dead Set" end |
#retry_entries(job_ids) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/sideq/retries.rb', line 71 def retry_entries( job_ids ) retried = 0 each_job( job_ids ) do |job| job.retry puts "#{job.jid}: retrying" retried += 1 end puts "Retry Set: Retried #{retried} entries" end |
#to_csv ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sideq/retries.rb', line 25 def to_csv require "csv" CSV.generate do |csv| csv << [ "JobID", "Created at", "Class", "Error Class", "Enqueued at", "Failed at", "Retry count", "Retried at", "Continue retries", "Error" ] retry_set.each do |job| csv << [ job.jid, job.created_at.strftime( "%F %T" ), job.display_class, job["error_class"], job.enqueued_at.strftime( "%F %T" ), Time.at( job["failed_at"] ).strftime( "%F %T" ), job["retry_count"], job["retried_at"] ? Time.at( job["retried_at"] ).strftime( "%F %T" ) : "never", job["retry"], "#{job["error_class"]}: #{job["error_message"][0,77-job["error_class"].size]}" ] end end end |
#to_s ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sideq/retries.rb', line 9 def to_s retry_set.each_with_object( [ "Retry entries: #{retry_set.size}" ] ) do |job, memo| memo << sprintf( "%24s - %19s\n %-22s - %-37s\n e: %19s - f: %19s\n retry (%2d) at %-19s Continue retries?: %s\n %s\n", job.jid, job.created_at.strftime( "%F %T" ), job.display_class, job["error_class"], job.enqueued_at.strftime( "%F %T" ), Time.at( job["failed_at"] ).strftime( "%F %T" ), job["retry_count"], job["retried_at"] ? Time.at( job["retried_at"] ).strftime( "%F %T" ) : "never", job["retry"], "#{job["error_class"]}: #{job["error_message"][0,77-job["error_class"].size]}" ) end.join( "\n" ) end |