Class: HerdstWorker::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/herdst_worker/application/facade.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#autoloadObject

Returns the value of attribute autoload.



14
15
16
# File 'lib/herdst_worker/application/facade.rb', line 14

def autoload
  @autoload
end

#configObject

Returns the value of attribute config.



14
15
16
# File 'lib/herdst_worker/application/facade.rb', line 14

def config
  @config
end

#familyObject

Returns the value of attribute family.



13
14
15
# File 'lib/herdst_worker/application/facade.rb', line 13

def family
  @family
end

#loggerObject

Returns the value of attribute logger.



14
15
16
# File 'lib/herdst_worker/application/facade.rb', line 14

def logger
  @logger
end

#nameObject

Returns the value of attribute name.



13
14
15
# File 'lib/herdst_worker/application/facade.rb', line 13

def name
  @name
end

#poller_enabledObject

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_urlObject

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

#queueObject

Returns the value of attribute queue.



15
16
17
# File 'lib/herdst_worker/application/facade.rb', line 15

def queue
  @queue
end

#queuesObject

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

Yields:

  • (_self)

Yield Parameters:



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

#runObject



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