Class: QueueManager
- Inherits:
-
Object
- Object
- QueueManager
- Defined in:
- lib/models/queue_manager.rb
Overview
Manage the interface with the queue, simplifying the interface for pushing documents.
Class Method Summary collapse
-
.add_ts(document) ⇒ Object
Add a timestamp to the document.
-
.push(document, name = ENV['RACK_ENV']) ⇒ Object
Push a message onto the queue name.
-
.push_generic_event(message) ⇒ Object
Push the generic event queue.
-
.push_log_event(message) ⇒ Object
push log event queue.
-
.push_session(message) ⇒ Object
Push to the session queue.
-
.push_timed_event(message) ⇒ Object
Push to the timed event queue.
-
.push_worker(message) ⇒ Object
Push to the WebUI Worker.
Class Method Details
.add_ts(document) ⇒ Object
Add a timestamp to the document.
25 26 27 28 29 |
# File 'lib/models/queue_manager.rb', line 25 def add_ts(document) json = document.is_a?(String) ? JSON.parse(document) : document json[:created_at] = Time.now.utc.to_s json.to_json end |
.push(document, name = ENV['RACK_ENV']) ⇒ Object
Push a message onto the queue name.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/models/queue_manager.rb', line 11 def push(document, name = ENV['RACK_ENV']) case SystemConfiguration.queue_impl when 'DelayedJob' document[:metric_name] = name document[:created_at] = Time.now.utc.to_s MetricDataJob.perform_later(document) else raise "Unknown queue implementation: #{SystemConfiguration.queue_impl}" end end |
.push_generic_event(message) ⇒ Object
Push the generic event queue
55 56 57 |
# File 'lib/models/queue_manager.rb', line 55 def push_generic_event() push(, :generic_events) end |
.push_log_event(message) ⇒ Object
push log event queue
62 63 64 65 |
# File 'lib/models/queue_manager.rb', line 62 def push_log_event() # encoded_doc = message.to_s.force_encoding('UTF-8') push(, :log_events) end |
.push_session(message) ⇒ Object
Push to the session queue
41 42 43 |
# File 'lib/models/queue_manager.rb', line 41 def push_session() push(, :session_events) end |
.push_timed_event(message) ⇒ Object
Push to the timed event queue
48 49 50 |
# File 'lib/models/queue_manager.rb', line 48 def push_timed_event() push(, :timedevents_events) end |
.push_worker(message) ⇒ Object
Push to the WebUI Worker
34 35 36 |
# File 'lib/models/queue_manager.rb', line 34 def push_worker() push() end |