Class: Wurk::Preflight::PayloadSample

Inherits:
Object
  • Object
show all
Defined in:
lib/wurk/preflight/payload_sample.rb

Overview

A bounded look at stored payloads: the oldest and newest entries of every queue and sorted set. Reports shapes and jids, never arguments.

Constant Summary collapse

TIME_FIELDS =
%w[created_at enqueued_at failed_at retried_at].freeze
MILLIS_FROM =

Same line Wurk's own readers draw between float seconds and integer ms.

10_000_000_000
MAX_EXAMPLES =
5

Instance Method Summary collapse

Constructor Details

#initialize(reader, per_source:) ⇒ PayloadSample

Returns a new instance of PayloadSample.



16
17
18
19
20
21
22
# File 'lib/wurk/preflight/payload_sample.rb', line 16

def initialize(reader, per_source:)
  @reader = reader
  @half = [per_source / 2, 1].max
  @stats = { 'sampled' => 0, 'unparseable' => 0, 'seconds' => 0, 'millis' => 0, 'retry_for' => 0,
             'sealed' => 0, 'encrypt_without_envelope' => 0 }
  @examples = []
end

Instance Method Details

#report_to(report, foreign:) ⇒ Object



32
33
34
35
36
# File 'lib/wurk/preflight/payload_sample.rb', line 32

def report_to(report, foreign:)
  report_timestamps(report, foreign)
  report_retry_for(report)
  report_encryption(report)
end

#take(queue_names) ⇒ Object



24
25
26
27
28
# File 'lib/wurk/preflight/payload_sample.rb', line 24

def take(queue_names)
  queue_names.each { |name| read_list("#{Keys::QUEUE_PREFIX}#{name}") }
  [Keys::RETRY, Keys::SCHEDULE, Keys::DEAD].each { |set| read_set(set) }
  self
end

#to_h ⇒ Object



30
# File 'lib/wurk/preflight/payload_sample.rb', line 30

def to_h = @stats.merge('encrypt_examples' => @examples)