Class: Flightdeck::ProcessRegistry

Inherits:
Object
  • Object
show all
Defined in:
app/models/flightdeck/process_registry.rb

Overview

The Solid Queue fleet: every registered process, grouped supervisor → children, with heartbeat freshness and claimed counts.

Two queries total, regardless of fleet size.

Defined Under Namespace

Classes: Node

Constant Summary collapse

FRESH_FRACTION =

Freshness is measured against Solid Queue's own liveness threshold rather than a number of our own, so what Flightdeck calls dead is exactly what the pruner will collect.

0.2

Instance Method Summary collapse

Instance Method Details

#any_dead?Boolean

Returns:

  • (Boolean)


84
# File 'app/models/flightdeck/process_registry.rb', line 84

def any_dead? = dead.any?

#deadObject



83
# File 'app/models/flightdeck/process_registry.rb', line 83

def dead = nodes.select(&:dead?)

#dead_claimed_countObject



85
# File 'app/models/flightdeck/process_registry.rb', line 85

def dead_claimed_count = dead.sum(&:claimed_count)

#find(id) ⇒ Object



88
89
90
# File 'app/models/flightdeck/process_registry.rb', line 88

def find(id)
  nodes.find { |node| node.id == id.to_i }
end

#nodesObject



66
67
68
# File 'app/models/flightdeck/process_registry.rb', line 66

def nodes
  @nodes ||= build_nodes
end

#totalObject



86
# File 'app/models/flightdeck/process_registry.rb', line 86

def total = nodes.size

#treeObject

Supervisors with their children nested; anything unsupervised (or whose supervisor row has gone) is listed flat so it can never be hidden.



72
73
74
75
76
77
78
79
80
81
# File 'app/models/flightdeck/process_registry.rb', line 72

def tree
  @tree ||= begin
    by_supervisor = nodes.group_by { |node| node.process.supervisor_id }
    known_ids = nodes.map(&:id).to_set

    roots = nodes.select { |node| node.process.supervisor_id.nil? || !known_ids.include?(node.process.supervisor_id) }
    roots.each { |root| root.children = by_supervisor.fetch(root.id, []) }
    roots
  end
end