Class: NurseAndrea::ContinuousScanner
- Inherits:
-
Object
- Object
- NurseAndrea::ContinuousScanner
- Defined in:
- lib/nurse_andrea/continuous_scanner.rb
Class Attribute Summary collapse
-
.thread ⇒ Object
readonly
Returns the value of attribute thread.
Class Method Summary collapse
-
.rescan_safely ⇒ Object
Public so specs can call it without spinning the loop.
- .running? ⇒ Boolean
- .start! ⇒ Object
- .stop! ⇒ Object
Class Attribute Details
.thread ⇒ Object (readonly)
Returns the value of attribute thread.
36 37 38 |
# File 'lib/nurse_andrea/continuous_scanner.rb', line 36 def thread @thread end |
Class Method Details
.rescan_safely ⇒ Object
Public so specs can call it without spinning the loop.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/nurse_andrea/continuous_scanner.rb', line 63 def rescan_safely return if NurseAndrea::SelfFilter.platform_self? discoveries = NurseAndrea::ManagedServiceScanner.scan return if discoveries.empty? # Only push new items — ManagedServiceScanner already dedups # by (type, tech, provider) within a single call, so we just # need to avoid resubmitting items already queued for the # current flush. existing_keys = NurseAndrea.component_discoveries.map { |d| [ d[:type], d[:tech], d[:provider] ] } discoveries.reject! { |d| existing_keys.include?([ d[:type], d[:tech], d[:provider] ]) } NurseAndrea.component_discoveries.concat(discoveries) if discoveries.any? rescue => e NurseAndrea.debug("[ContinuousScanner] error: #{e.class}: #{e.}") end |
.running? ⇒ Boolean
58 59 60 |
# File 'lib/nurse_andrea/continuous_scanner.rb', line 58 def running? @thread&.alive? == true end |
.start! ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/nurse_andrea/continuous_scanner.rb', line 38 def start! @mutex.synchronize do return if @thread&.alive? return if NurseAndrea.config.disable_continuous_scan @stop = false @thread = Thread.new { run_loop } @thread.name = "nurse_andrea_continuous_scanner" end end |
.stop! ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/nurse_andrea/continuous_scanner.rb', line 49 def stop! @mutex.synchronize do @stop = true end @thread&.wakeup rescue nil @thread&.join(2) @thread = nil end |