Class: RailsPerformance::Models::SidekiqRecord
- Inherits:
-
BaseRecord
- Object
- BaseRecord
- RailsPerformance::Models::SidekiqRecord
- Defined in:
- lib/rails_performance/models/sidekiq_record.rb
Instance Attribute Summary collapse
-
#datetime ⇒ Object
Returns the value of attribute datetime.
-
#datetimei ⇒ Object
Returns the value of attribute datetimei.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#enqueued_ati ⇒ Object
Returns the value of attribute enqueued_ati.
-
#jid ⇒ Object
Returns the value of attribute jid.
-
#message ⇒ Object
Returns the value of attribute message.
-
#queue ⇒ Object
Returns the value of attribute queue.
-
#start_timei ⇒ Object
Returns the value of attribute start_timei.
-
#status ⇒ Object
Returns the value of attribute status.
-
#worker ⇒ Object
Returns the value of attribute worker.
Class Method Summary collapse
-
.from_db(key, value) ⇒ Object
key = job-performance |queue|default |worker|SimpleWorker |jid|7d48fbf20976c224510dbc60 |datetime|20200124T0523 |datetimei|1583146613 |enqueued_ati|1583146613 |start_timei|1583146614 |status|success|END|1.0.0 value = JSON.
Instance Method Summary collapse
-
#initialize(queue:, worker:, jid:, datetime:, datetimei:, enqueued_ati:, start_timei:, status: nil, duration: nil, json: "{}") ⇒ SidekiqRecord
constructor
A new instance of SidekiqRecord.
- #record_hash ⇒ Object
- #save ⇒ Object
Methods inherited from BaseRecord
Constructor Details
#initialize(queue:, worker:, jid:, datetime:, datetimei:, enqueued_ati:, start_timei:, status: nil, duration: nil, json: "{}") ⇒ SidekiqRecord
Returns a new instance of SidekiqRecord.
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rails_performance/models/sidekiq_record.rb', line 32 def initialize(queue:, worker:, jid:, datetime:, datetimei:, enqueued_ati:, start_timei:, status: nil, duration: nil, json: "{}") @queue = queue @worker = worker @jid = jid @datetime = datetime @datetimei = datetimei.to_i @enqueued_ati = enqueued_ati @start_timei = start_timei @status = status @duration = duration @json = json end |
Instance Attribute Details
#datetime ⇒ Object
Returns the value of attribute datetime.
4 5 6 |
# File 'lib/rails_performance/models/sidekiq_record.rb', line 4 def datetime @datetime end |
#datetimei ⇒ Object
Returns the value of attribute datetimei.
4 5 6 |
# File 'lib/rails_performance/models/sidekiq_record.rb', line 4 def datetimei @datetimei end |
#duration ⇒ Object
Returns the value of attribute duration.
4 5 6 |
# File 'lib/rails_performance/models/sidekiq_record.rb', line 4 def duration @duration end |
#enqueued_ati ⇒ Object
Returns the value of attribute enqueued_ati.
4 5 6 |
# File 'lib/rails_performance/models/sidekiq_record.rb', line 4 def enqueued_ati @enqueued_ati end |
#jid ⇒ Object
Returns the value of attribute jid.
4 5 6 |
# File 'lib/rails_performance/models/sidekiq_record.rb', line 4 def jid @jid end |
#message ⇒ Object
Returns the value of attribute message.
4 5 6 |
# File 'lib/rails_performance/models/sidekiq_record.rb', line 4 def @message end |
#queue ⇒ Object
Returns the value of attribute queue.
4 5 6 |
# File 'lib/rails_performance/models/sidekiq_record.rb', line 4 def queue @queue end |
#start_timei ⇒ Object
Returns the value of attribute start_timei.
4 5 6 |
# File 'lib/rails_performance/models/sidekiq_record.rb', line 4 def start_timei @start_timei end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/rails_performance/models/sidekiq_record.rb', line 4 def status @status end |
#worker ⇒ Object
Returns the value of attribute worker.
4 5 6 |
# File 'lib/rails_performance/models/sidekiq_record.rb', line 4 def worker @worker end |
Class Method Details
.from_db(key, value) ⇒ Object
key = job-performance |queue|default |worker|SimpleWorker |jid|7d48fbf20976c224510dbc60 |datetime|20200124T0523 |datetimei|1583146613 |enqueued_ati|1583146613 |start_timei|1583146614 |status|success|END|1.0.0 value = JSON
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rails_performance/models/sidekiq_record.rb', line 16 def SidekiqRecord.from_db(key, value) items = key.split("|") SidekiqRecord.new( queue: items[2], worker: items[4], jid: items[6], datetime: items[8], datetimei: items[10], enqueued_ati: items[12], start_timei: items[14], status: items[16], json: value ) end |
Instance Method Details
#record_hash ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rails_performance/models/sidekiq_record.rb', line 45 def record_hash { worker: self.worker, queue: self.queue, jid: self.jid, status: self.status, datetimei: datetimei, datetime: Time.at(self.start_timei.to_i), duration: self.value['duration'], message: value['message'] } end |
#save ⇒ Object
58 59 60 61 62 |
# File 'lib/rails_performance/models/sidekiq_record.rb', line 58 def save key = "sidekiq|queue|#{queue}|worker|#{worker}|jid|#{jid}|datetime|#{datetime}|datetimei|#{datetimei}|enqueued_ati|#{enqueued_ati}|start_timei|#{start_timei}|status|#{status}|END|#{RailsPerformance::SCHEMA}" value = { message: , duration: duration } Utils.save_to_redis(key, value) end |