Class: Sidekiq::Routing::QueueComposition::Report

Inherits:
Struct
  • Object
show all
Defined in:
lib/sidekiq/routing/queue_composition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#queueObject

Returns the value of attribute queue

Returns:

  • (Object)

    the current value of queue



10
11
12
# File 'lib/sidekiq/routing/queue_composition.rb', line 10

def queue
  @queue
end

#rowsObject

Returns the value of attribute rows

Returns:

  • (Object)

    the current value of rows



10
11
12
# File 'lib/sidekiq/routing/queue_composition.rb', line 10

def rows
  @rows
end

#scan_limitObject

Returns the value of attribute scan_limit

Returns:

  • (Object)

    the current value of scan_limit



10
11
12
# File 'lib/sidekiq/routing/queue_composition.rb', line 10

def scan_limit
  @scan_limit
end

#scannedObject

Returns the value of attribute scanned

Returns:

  • (Object)

    the current value of scanned



10
11
12
# File 'lib/sidekiq/routing/queue_composition.rb', line 10

def scanned
  @scanned
end

#sizeObject

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



10
11
12
# File 'lib/sidekiq/routing/queue_composition.rb', line 10

def size
  @size
end

Instance Method Details

#offenderObject



11
12
13
# File 'lib/sidekiq/routing/queue_composition.rb', line 11

def offender
  rows.first
end

#to_hObject



15
16
17
18
19
20
21
22
23
# File 'lib/sidekiq/routing/queue_composition.rb', line 15

def to_h
  {
    "queue" => queue,
    "rows" => rows.map(&:dup),
    "scanned" => scanned,
    "size" => size,
    "scan_limit" => scan_limit
  }
end

#to_sObject Also known as: inspect



25
26
27
28
29
30
31
32
# File 'lib/sidekiq/routing/queue_composition.rb', line 25

def to_s
  lines = rows.map do |row|
    age = row["oldest_age_seconds"] ? "#{row["oldest_age_seconds"].round}s ago" : "n/a"
    format("%-55s count=%-9d oldest=%s", row["class"], row["count"], age)
  end
  lines << "scanned #{scanned} of #{size} (cap #{scan_limit})"
  lines.join("\n")
end