Class: RedisQueuedLocks::Swarm::Supervisor Private
- Inherits:
-
Object
- Object
- RedisQueuedLocks::Swarm::Supervisor
- Includes:
- Utilities
- Defined in:
- lib/redis_queued_locks/swarm/supervisor.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary
Constants included from Utilities
Utilities::RACTOR_LIVENESS_PATTERN, Utilities::RACTOR_STATUS_PATTERN, Utilities::RUBY_OVER_4
Instance Attribute Summary collapse
- #observable ⇒ Proc, NilClass readonly private
- #rql_client ⇒ RedisQueuedLocks::Client readonly private
- #visor ⇒ Thread, NilClass readonly private
Instance Method Summary collapse
- #initialize(rql_client) ⇒ void constructor private
- #observe!(&observable) ⇒ void private
- #running? ⇒ Boolean private
- #status ⇒ Hash<Symbol|Hash<Symbol,String|Boolean>> private
- #stop! ⇒ void private
Methods included from Utilities
clock_gettime, ractor_alive?, ractor_status, ruby_over_4?, run_non_critical, thread_state
Constructor Details
#initialize(rql_client) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 34 35 |
# File 'lib/redis_queued_locks/swarm/supervisor.rb', line 31 def initialize(rql_client) @rql_client = rql_client @visor = nil @observable = nil end |
Instance Attribute Details
#observable ⇒ Proc, NilClass (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 |
# File 'lib/redis_queued_locks/swarm/supervisor.rb', line 25 def observable @observable end |
#rql_client ⇒ RedisQueuedLocks::Client (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/redis_queued_locks/swarm/supervisor.rb', line 13 def rql_client @rql_client end |
#visor ⇒ Thread, NilClass (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/redis_queued_locks/swarm/supervisor.rb', line 19 def visor @visor end |
Instance Method Details
#observe!(&observable) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/redis_queued_locks/swarm/supervisor.rb', line 42 def observe!(&observable) @observable = observable @visor = Thread.new do loop do yield rescue nil # TODO: (CHECK): may be we need to process exceptions here sleep(rql_client.config['swarm.supervisor.liveness_probing_period']) end end # NOTE: need to give a timespot to initialize a visor thread; sleep(0.1) end |
#running? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 61 62 63 64 |
# File 'lib/redis_queued_locks/swarm/supervisor.rb', line 58 def running? # NOTE: # steep can not understand that visor.alive? is invoked on # `::Thread` here (not on `::Thread | nil` after the `nil`-check); # so we need to ignore this check temporary and wait the best future :) visor != nil && visor.alive? # steep:ignore end |
#status ⇒ Hash<Symbol|Hash<Symbol,String|Boolean>>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/redis_queued_locks/swarm/supervisor.rb', line 84 def status # NOTE: # steep can not understand that thread_state(visor) is invoked on # `::Thread` here (not on `::Thread | nil` after the `nil`-check); # so we need to ignore this check temporary and wait the best future :) { running: running?, state: (visor == nil) ? 'non_initialized' : thread_state(visor), # steep:ignore observable: (observable == nil) ? 'non_initialized' : 'initialized' } end |
#stop! ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
70 71 72 73 74 75 76 77 78 |
# File 'lib/redis_queued_locks/swarm/supervisor.rb', line 70 def stop! # NOTE: # steep can not understand that visor.kill is invoked on # `::Thread` here (not on `::Thread | nil` after the `nil`-check); # so we need to ignore this check temporary and wait the best future :) visor.kill if running? # steep:ignore @visor = nil @observable = nil end |