Class: Flightdeck::ProcessRegistry::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#childrenObject

Returns the value of attribute children

Returns:

  • (Object)

    the current value of children



14
15
16
# File 'app/models/flightdeck/process_registry.rb', line 14

def children
  @children
end

#claimed_countObject

Returns the value of attribute claimed_count

Returns:

  • (Object)

    the current value of claimed_count



14
15
16
# File 'app/models/flightdeck/process_registry.rb', line 14

def claimed_count
  @claimed_count
end

#processObject

Returns the value of attribute process

Returns:

  • (Object)

    the current value of process



14
15
16
# File 'app/models/flightdeck/process_registry.rb', line 14

def process
  @process
end

Instance Method Details

#claims_executions?Boolean

Returns:

  • (Boolean)


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

def claims_executions? = kind == "Worker"

#config_summaryObject

Human summary of what this process was configured to do. Keys differ per process kind, so known ones are formatted and anything else is shown verbatim rather than dropped.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/flightdeck/process_registry.rb', line 48

def config_summary
  parts = []
  data = .symbolize_keys

  parts << "queues: #{data[:queues]}" if data[:queues].present?
  parts << "#{data[:thread_pool_size]} threads" if data[:thread_pool_size].present?
  parts << "batch #{data[:batch_size]}" if data[:batch_size].present?
  parts << "every #{data[:polling_interval]}s" if data[:polling_interval].present?
  parts << "#{Array(data[:recurring_schedule]).size} recurring tasks" if data[:recurring_schedule].present?

  known = %i[queues thread_pool_size batch_size polling_interval recurring_schedule
             concurrency_maintenance_interval]
  data.except(*known).each { |key, value| parts << "#{key}: #{value}" }

  parts.join(" ยท ")
end

#dead?Boolean

Returns:

  • (Boolean)


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

def dead? = freshness == :dead

#freshnessObject



28
29
30
31
32
33
34
35
36
# File 'app/models/flightdeck/process_registry.rb', line 28

def freshness
  threshold = SolidQueue.process_alive_threshold
  age = heartbeat_age

  if age >= threshold then :dead
  elsif age >= threshold * FRESH_FRACTION then :stale
  else :fresh
  end
end

#heartbeat_ageObject



24
25
26
# File 'app/models/flightdeck/process_registry.rb', line 24

def heartbeat_age
  Time.current - last_heartbeat_at
end

#hostnameObject



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

def hostname = process.hostname

#idObject



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

def id = process.id

#kindObject



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

def kind = process.kind

#last_heartbeat_atObject



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

def last_heartbeat_at = process.last_heartbeat_at

#metadataObject



41
42
43
# File 'app/models/flightdeck/process_registry.rb', line 41

def 
  process..presence || {}
end

#nameObject



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

def name = process.name

#pidObject



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

def pid = process.pid

#prunable?Boolean

Returns:

  • (Boolean)


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

def prunable? = dead?

#supervisor?Boolean

Returns:

  • (Boolean)


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

def supervisor? = kind == "Supervisor"