Class: Salemove::ProcessHandler::PivotProcess
- Inherits:
-
Object
- Object
- Salemove::ProcessHandler::PivotProcess
show all
- Defined in:
- lib/salemove/process_handler/pivot_process.rb
Defined Under Namespace
Classes: ServiceSpawner, TapServiceSpawner
Constant Summary
collapse
- DEFAULT_FULFILLABLE_TIMEOUT =
3
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(freddy, notifier: nil, notifier_factory: NotifierFactory, process_monitor: ProcessMonitor.new, process_name: 'Unknown process', exit_enforcer: nil) ⇒ PivotProcess
Returns a new instance of PivotProcess.
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/salemove/process_handler/pivot_process.rb', line 31
def initialize(freddy,
notifier: nil,
notifier_factory: NotifierFactory,
process_monitor: ProcessMonitor.new,
process_name: 'Unknown process',
exit_enforcer: nil)
@freddy = freddy
@process_monitor = process_monitor
@exception_notifier = notifier_factory.get_notifier(process_name, notifier)
@exit_enforcer = exit_enforcer || Proc.new {}
end
|
Instance Attribute Details
#exception_notifier ⇒ Object
Returns the value of attribute exception_notifier.
13
14
15
|
# File 'lib/salemove/process_handler/pivot_process.rb', line 13
def exception_notifier
@exception_notifier
end
|
#process_monitor ⇒ Object
Returns the value of attribute process_monitor.
13
14
15
|
# File 'lib/salemove/process_handler/pivot_process.rb', line 13
def process_monitor
@process_monitor
end
|
Class Method Details
.logger ⇒ Object
15
16
17
|
# File 'lib/salemove/process_handler/pivot_process.rb', line 15
def self.logger
@logger ||= Logger.new(STDOUT).tap { |l| l.level = Logger::INFO }
end
|
.logger=(logger) ⇒ Object
19
20
21
|
# File 'lib/salemove/process_handler/pivot_process.rb', line 19
def self.logger=(logger)
@logger = logger
end
|
23
24
25
26
27
28
29
|
# File 'lib/salemove/process_handler/pivot_process.rb', line 23
def self.trace_information
if defined?(Freddy) && Freddy.respond_to?(:trace)
{trace: Freddy.trace.to_h}
else
{}
end
end
|
Instance Method Details
#spawn(service, blocking: true) ⇒ Object
44
45
46
47
48
49
|
# File 'lib/salemove/process_handler/pivot_process.rb', line 44
def spawn(service, blocking: true)
@process_monitor.start
@service_threads = spawn_queue_threads(service).concat(spawn_tap_threads(service))
blocking ? wait_for_monitor : Thread.new { wait_for_monitor }
end
|
#spawn_queue_threads(service) ⇒ Object
51
52
53
54
55
56
57
|
# File 'lib/salemove/process_handler/pivot_process.rb', line 51
def spawn_queue_threads(service)
if service.class.const_defined?(:QUEUE)
[ServiceSpawner.spawn(service, @freddy, @exception_notifier)]
else
[]
end
end
|
#spawn_tap_threads(service) ⇒ Object
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/salemove/process_handler/pivot_process.rb', line 59
def spawn_tap_threads(service)
if service.class.const_defined?(:TAPPED_QUEUES)
service.class::TAPPED_QUEUES.map do |queue|
spawner = TapServiceSpawner.new(service, @freddy, @exception_notifier)
spawner.spawn(queue)
end
else
[]
end
end
|