Class: HerdstWorker::Application
- Inherits:
-
Object
- Object
- HerdstWorker::Application
- Defined in:
- lib/herdst_worker/application/facade.rb
Instance Attribute Summary collapse
-
#autoload ⇒ Object
Returns the value of attribute autoload.
-
#config ⇒ Object
Returns the value of attribute config.
-
#family ⇒ Object
Returns the value of attribute family.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#name ⇒ Object
Returns the value of attribute name.
-
#poller_enabled ⇒ Object
Returns the value of attribute poller_enabled.
-
#poller_url ⇒ Object
Returns the value of attribute poller_url.
-
#queue ⇒ Object
Returns the value of attribute queue.
-
#queues ⇒ Object
Returns the value of attribute queues.
Instance Method Summary collapse
- #add_queue(name, url, poller = false) ⇒ Object
- #config_for(name) ⇒ Object
- #configure {|_self| ... } ⇒ Object
- #get_queue(name) ⇒ Object
-
#initialize(env, name, family, poller_enabled) ⇒ Application
constructor
A new instance of Application.
- #run ⇒ Object
Constructor Details
#initialize(env, name, family, poller_enabled) ⇒ Application
Returns a new instance of Application.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/herdst_worker/application/facade.rb', line 18 def initialize(env, name, family, poller_enabled) self.name = name self.family = family self.poller_enabled = poller_enabled self.queues = ActiveSupport::HashWithIndifferentAccess.new HerdstWorker.set_application(self) self.logger = HerdstWorker::Log::Facade.new(get_logger_level(env)) self.config = HerdstWorker::Configuration::Facade.new(env, name) self.autoload = HerdstWorker::Autoload::Facade.new(self) self.set_inflections HerdstWorker::Adapters::Facade.bootstrap(self) end |
Instance Attribute Details
#autoload ⇒ Object
Returns the value of attribute autoload.
14 15 16 |
# File 'lib/herdst_worker/application/facade.rb', line 14 def autoload @autoload end |
#config ⇒ Object
Returns the value of attribute config.
14 15 16 |
# File 'lib/herdst_worker/application/facade.rb', line 14 def config @config end |
#family ⇒ Object
Returns the value of attribute family.
13 14 15 |
# File 'lib/herdst_worker/application/facade.rb', line 13 def family @family end |
#logger ⇒ Object
Returns the value of attribute logger.
14 15 16 |
# File 'lib/herdst_worker/application/facade.rb', line 14 def logger @logger end |
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'lib/herdst_worker/application/facade.rb', line 13 def name @name end |
#poller_enabled ⇒ Object
Returns the value of attribute poller_enabled.
15 16 17 |
# File 'lib/herdst_worker/application/facade.rb', line 15 def poller_enabled @poller_enabled end |
#poller_url ⇒ Object
Returns the value of attribute poller_url.
15 16 17 |
# File 'lib/herdst_worker/application/facade.rb', line 15 def poller_url @poller_url end |
#queue ⇒ Object
Returns the value of attribute queue.
15 16 17 |
# File 'lib/herdst_worker/application/facade.rb', line 15 def queue @queue end |
#queues ⇒ Object
Returns the value of attribute queues.
15 16 17 |
# File 'lib/herdst_worker/application/facade.rb', line 15 def queues @queues end |
Instance Method Details
#add_queue(name, url, poller = false) ⇒ Object
51 52 53 54 |
# File 'lib/herdst_worker/application/facade.rb', line 51 def add_queue(name, url, poller = false) self.queues[name] = url self.poller_url = url if poller end |
#config_for(name) ⇒ Object
69 70 71 |
# File 'lib/herdst_worker/application/facade.rb', line 69 def config_for(name) self.config.config_for(name) end |
#configure {|_self| ... } ⇒ Object
35 36 37 38 39 |
# File 'lib/herdst_worker/application/facade.rb', line 35 def configure(&block) yield self self.autoload.reload end |
#get_queue(name) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/herdst_worker/application/facade.rb', line 42 def get_queue(name) if self.queues[name] HerdstWorker::Queue::Facade.new(self, false, self.queues[name], 20) else nil end end |
#run ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/herdst_worker/application/facade.rb', line 57 def run if self.queue == nil self.logger.info "Starting Application (#{$$})" HerdstWorker::Signals::Facade.listen(self.config.paths.temp) self.queue = HerdstWorker::Queue::Facade.new(self, self.poller_enabled, self.poller_url, 20) self.queue.start end end |