Class: SolidObjects::CallerProcess
- Inherits:
-
Object
- Object
- SolidObjects::CallerProcess
- Defined in:
- lib/solid_objects/caller_process.rb,
sig/generated/lib/solid_objects/caller_process.rbs
Instance Attribute Summary collapse
-
#mutex ⇒ Object
readonly
Returns the value of attribute mutex.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
-
#initialize ⇒ CallerProcess
constructor
A new instance of CallerProcess.
- #process_registry ⇒ ProcessRegistry
- #register ⇒ ProcessRegistry
- #reset_after_fork ⇒ void
- #reusable_registry? ⇒ Boolean
Constructor Details
#initialize ⇒ CallerProcess
Returns a new instance of CallerProcess.
10 11 12 13 14 |
# File 'lib/solid_objects/caller_process.rb', line 10 def initialize @mutex = Thread::Mutex.new @process_id = nil @registry = nil end |
Instance Attribute Details
#mutex ⇒ Object (readonly)
Returns the value of attribute mutex.
28 29 30 |
# File 'lib/solid_objects/caller_process.rb', line 28 def mutex @mutex end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
28 29 30 |
# File 'lib/solid_objects/caller_process.rb', line 28 def registry @registry end |
Instance Method Details
#process_registry ⇒ ProcessRegistry
17 18 19 20 21 22 23 24 |
# File 'lib/solid_objects/caller_process.rb', line 17 def process_registry mutex.synchronize do reset_after_fork register unless reusable_registry? registry.heartbeat registry end end |
#register ⇒ ProcessRegistry
48 49 50 51 52 53 54 55 |
# File 'lib/solid_objects/caller_process.rb', line 48 def register @registry = ProcessRegistry.new registry.register( kind: "caller", metadata: { execution: "synchronous" } ) registry end |
#reset_after_fork ⇒ void
This method returns an undefined value.
31 32 33 34 35 36 |
# File 'lib/solid_objects/caller_process.rb', line 31 def reset_after_fork return if @process_id == ::Process.pid @process_id = ::Process.pid @registry = nil end |
#reusable_registry? ⇒ Boolean
39 40 41 42 43 44 45 |
# File 'lib/solid_objects/caller_process.rb', line 39 def reusable_registry? return false unless registry&.process_record registry.process_record.reload.shutdown_state == "running" rescue ActiveRecord::RecordNotFound false end |