Class: DaemonicThreads::Queues
- Inherits:
-
Object
- Object
- DaemonicThreads::Queues
- Defined in:
- lib/ruby-daemonic-threads/queues.rb
Overview
NOTE:
This is not a quarantied delivery queues.
They rely on normal process startup/shutdown sequence.
So, if you got segfault all data will be lost.
On the other hand, queues tends to be quite quickly
Constant Summary collapse
- DEFAULT_STORAGE_DIR =
Rails.root + 'tmp' + 'queues'
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize(process) ⇒ Queues
constructor
A new instance of Queues.
- #store_and_close ⇒ Object
Constructor Details
#initialize(process) ⇒ Queues
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ruby-daemonic-threads/queues.rb', line 26 def initialize(process) @queues = {} @config = process.config.queues @storage_dir = DEFAULT_STORAGE_DIR @storage_dir.mkpath @config.each do |name, config| queue = @queues[name.to_sym] = config["class-constantized"].new if queue.respond_to?(:restore) queue.storage = @storage_dir + name queue.restore end if queue.respond_to?(:config=) queue.config = config end end end |
Instance Method Details
#[](name) ⇒ Object
56 57 58 |
# File 'lib/ruby-daemonic-threads/queues.rb', line 56 def [] name @queues[name] end |
#store_and_close ⇒ Object
50 51 52 53 54 |
# File 'lib/ruby-daemonic-threads/queues.rb', line 50 def store_and_close @queues.each do |name, queue| queue.store_and_close if queue.respond_to?(:store_and_close) end end |