Class: PartitionGardener::RunMetrics
- Inherits:
-
Object
- Object
- PartitionGardener::RunMetrics
- Defined in:
- lib/partition_gardener/run_metrics.rb
Instance Attribute Summary collapse
-
#finished_at ⇒ Object
readonly
Returns the value of attribute finished_at.
-
#plan_signature ⇒ Object
Returns the value of attribute plan_signature.
-
#rows_moved ⇒ Object
readonly
Returns the value of attribute rows_moved.
-
#skip_reason ⇒ Object
readonly
Returns the value of attribute skip_reason.
-
#skipped ⇒ Object
readonly
Returns the value of attribute skipped.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
- #add_rows(count) ⇒ Object
- #duration_ms ⇒ Object
- #finish! ⇒ Object
-
#initialize(table_name) ⇒ RunMetrics
constructor
A new instance of RunMetrics.
- #mark_skipped!(reason) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(table_name) ⇒ RunMetrics
Returns a new instance of RunMetrics.
6 7 8 9 10 11 12 13 14 |
# File 'lib/partition_gardener/run_metrics.rb', line 6 def initialize(table_name) @table_name = table_name @started_at = monotonic_clock @plan_signature = nil @rows_moved = 0 @finished_at = nil @skipped = false @skip_reason = nil end |
Instance Attribute Details
#finished_at ⇒ Object (readonly)
Returns the value of attribute finished_at.
3 4 5 |
# File 'lib/partition_gardener/run_metrics.rb', line 3 def finished_at @finished_at end |
#plan_signature ⇒ Object
Returns the value of attribute plan_signature.
4 5 6 |
# File 'lib/partition_gardener/run_metrics.rb', line 4 def plan_signature @plan_signature end |
#rows_moved ⇒ Object (readonly)
Returns the value of attribute rows_moved.
3 4 5 |
# File 'lib/partition_gardener/run_metrics.rb', line 3 def rows_moved @rows_moved end |
#skip_reason ⇒ Object (readonly)
Returns the value of attribute skip_reason.
3 4 5 |
# File 'lib/partition_gardener/run_metrics.rb', line 3 def skip_reason @skip_reason end |
#skipped ⇒ Object (readonly)
Returns the value of attribute skipped.
3 4 5 |
# File 'lib/partition_gardener/run_metrics.rb', line 3 def skipped @skipped end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
3 4 5 |
# File 'lib/partition_gardener/run_metrics.rb', line 3 def started_at @started_at end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
3 4 5 |
# File 'lib/partition_gardener/run_metrics.rb', line 3 def table_name @table_name end |
Instance Method Details
#add_rows(count) ⇒ Object
16 17 18 |
# File 'lib/partition_gardener/run_metrics.rb', line 16 def add_rows(count) @rows_moved += count.to_i end |
#duration_ms ⇒ Object
30 31 32 33 34 |
# File 'lib/partition_gardener/run_metrics.rb', line 30 def duration_ms return nil unless @finished_at ((@finished_at - @started_at) * 1000).round end |
#finish! ⇒ Object
26 27 28 |
# File 'lib/partition_gardener/run_metrics.rb', line 26 def finish! @finished_at = monotonic_clock end |
#mark_skipped!(reason) ⇒ Object
20 21 22 23 24 |
# File 'lib/partition_gardener/run_metrics.rb', line 20 def mark_skipped!(reason) @skipped = true @skip_reason = reason finish! end |
#to_h ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/partition_gardener/run_metrics.rb', line 36 def to_h { table_name: table_name, duration_ms: duration_ms, plan_signature: plan_signature, rows_moved: rows_moved, skipped: skipped, skip_reason: skip_reason } end |