Module: Executor
- Defined in:
- lib/hyperflow-amqp-executor.rb,
lib/hyperflow-amqp-executor/job.rb,
lib/hyperflow-amqp-executor/settings.rb,
lib/hyperflow-amqp-executor/nfs_storage.rb,
lib/hyperflow-amqp-executor/cloud_storage.rb,
lib/hyperflow-amqp-executor/local_storage.rb,
lib/hyperflow-amqp-executor/gridftp_storage.rb,
lib/hyperflow-amqp-executor/plgdata_storage.rb
Defined Under Namespace
Modules: CloudStorage, GridFTPStorage, LocalStorage, NFSStorage, PLGDataStorage Classes: Job, Settings
Class Attribute Summary collapse
-
.events_exchange ⇒ Object
Returns the value of attribute events_exchange.
-
.id ⇒ Object
Returns the value of attribute id.
-
.settings ⇒ Object
Returns the value of attribute settings.
Class Method Summary collapse
Class Attribute Details
.events_exchange ⇒ Object
Returns the value of attribute events_exchange.
19 20 21 |
# File 'lib/hyperflow-amqp-executor.rb', line 19 def events_exchange @events_exchange end |
.id ⇒ Object
Returns the value of attribute id.
19 20 21 |
# File 'lib/hyperflow-amqp-executor.rb', line 19 def id @id end |
.settings ⇒ Object
Returns the value of attribute settings.
19 20 21 |
# File 'lib/hyperflow-amqp-executor.rb', line 19 def settings @settings end |
Class Method Details
.cpu_count ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/hyperflow-amqp-executor.rb', line 25 def cpu_count unless ENV['THREADS'].nil? ENV['THREADS'] else begin `nproc` rescue 1 end end.to_i end |
.logger ⇒ Object
21 22 23 |
# File 'lib/hyperflow-amqp-executor.rb', line 21 def logger @logger ||= Logger.new($stdout) end |
.publish_event(type, routing_key, payload = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/hyperflow-amqp-executor.rb', line 37 def publish_event(type, routing_key, payload = {}) data = payload data['timestamp'] = Time.now.utc.to_f data['type'] = type data['executor'] = @id EM.next_tick do logger.debug "Publishing event #{type}" @events_exchange.publish(JSON.dump(data), content_type: 'application/json', routing_key: routing_key) end data['timestamp'] end |