Class: Hoss::Transport::Base Private
- Inherits:
-
Object
- Object
- Hoss::Transport::Base
- Includes:
- Logging
- Defined in:
- lib/hoss/transport/base.rb
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 collapse
- WATCHER_EXECUTION_INTERVAL =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
5
- WATCHER_TIMEOUT_INTERVAL =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
4
- WORKER_JOIN_TIMEOUT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
5
Constants included from Logging
Logging::LEVELS, Logging::PREFIX
Instance Attribute Summary collapse
- #config ⇒ Object readonly private
- #filters ⇒ Object readonly private
- #queue ⇒ Object readonly private
- #stopped ⇒ Object readonly private
- #watcher ⇒ Object readonly private
- #workers ⇒ Object readonly private
Instance Method Summary collapse
- #add_filter(key, callback) ⇒ Object private
- #handle_forking! ⇒ Object private
-
#initialize(config) ⇒ Base
constructor
private
A new instance of Base.
- #start ⇒ Object private
- #stop ⇒ Object private
- #submit(resource) ⇒ Object private
Methods included from Logging
#debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(config) ⇒ Base
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.
Returns a new instance of Base.
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/hoss/transport/base.rb', line 41 def initialize(config) @config = config @queue = SizedQueue.new(config.max_queue_size) @serializers = Serializers.new(config) @filters = Filters.new(config) @stopped = Concurrent::AtomicBoolean.new @workers = Array.new(config.pool_size) @worker_mutex = Mutex.new end |
Instance Attribute Details
#config ⇒ Object (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.
54 55 56 |
# File 'lib/hoss/transport/base.rb', line 54 def config @config end |
#filters ⇒ Object (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.
54 55 56 |
# File 'lib/hoss/transport/base.rb', line 54 def filters @filters end |
#queue ⇒ Object (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.
54 55 56 |
# File 'lib/hoss/transport/base.rb', line 54 def queue @queue end |
#stopped ⇒ Object (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.
54 55 56 |
# File 'lib/hoss/transport/base.rb', line 54 def stopped @stopped end |
#watcher ⇒ Object (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.
54 55 56 |
# File 'lib/hoss/transport/base.rb', line 54 def watcher @watcher end |
#workers ⇒ Object (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.
54 55 56 |
# File 'lib/hoss/transport/base.rb', line 54 def workers @workers end |
Instance Method Details
#add_filter(key, callback) ⇒ Object
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.
94 95 96 |
# File 'lib/hoss/transport/base.rb', line 94 def add_filter(key, callback) @filters.add(key, callback) end |
#handle_forking! ⇒ Object
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.
98 99 100 101 102 103 104 105 |
# File 'lib/hoss/transport/base.rb', line 98 def handle_forking! # We can't just stop and start again because the StopMessage # will then be the first message processed when the transport is # restarted. stop_watcher ensure_worker_count create_watcher end |
#start ⇒ Object
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.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/hoss/transport/base.rb', line 56 def start debug '%s: Starting Transport', pid_str # Set @stopped to false first, in case transport is restarted; # ensure_worker_count requires @stopped to be false # ~estolfo @stopped.make_false unless @stopped.false? ensure_worker_count create_watcher end |
#stop ⇒ Object
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.
67 68 69 70 71 72 73 74 |
# File 'lib/hoss/transport/base.rb', line 67 def stop debug '%s: Stopping Transport', pid_str @stopped.make_true stop_watcher stop_workers end |
#submit(resource) ⇒ Object
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.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/hoss/transport/base.rb', line 76 def submit(resource) if @stopped.true? warn '%s: Transport stopping, no new events accepted', pid_str debug 'Dropping: %s', resource.inspect return false end queue.push(resource, true) true rescue ThreadError throttled_queue_full_warning nil rescue Exception => e error '%s: Failed adding to the transport queue: %p', pid_str, e.inspect nil end |