Module: EQ

Extended by:
SingleForwardable
Defined in:
lib/eq.rb,
lib/eq-web.rb,
lib/eq/job.rb,
lib/eq/error.rb,
lib/eq/logging.rb,
lib/eq/version.rb

Defined Under Namespace

Modules: Logging, Queueing, Scheduling, Web, Working Classes: ConfigurationError, Error, Job

Constant Summary collapse

DEFAULT_CONFIG =
{
  queue: 'sequel',
  sequel: 'sqlite:/',
  job_timeout: 5, # in seconds
  worker_pool_size: Celluloid.cores, # in threads
  worker_delay: 0
}.freeze
VERSION =
'0.1.0'

Class Method Summary collapse

Class Method Details

.alive?Boolean

Returns:

  • (Boolean)


52
53
54
55
56
57
# File 'lib/eq.rb', line 52

def alive?
  alive = false
  alive &= queue.alive? if queue
  alive &= worker.alive? if worker
  alive
end

.boot(just = nil) ⇒ Object

this boots queuing and working optional: to use another queuing or working subsystem just do require ‘eq/working’ or require ‘eq/queueing’ instead of require ‘eq/all’



37
# File 'lib/eq.rb', line 37

def boot just=nil; manage :boot, just; end

.config {|@config| ... } ⇒ Object

Yields:



28
29
30
31
32
# File 'lib/eq.rb', line 28

def config
  @config ||= OpenStruct.new DEFAULT_CONFIG
  yield @config if block_given?
  @config
end

.loggerObject



59
# File 'lib/eq.rb', line 59

def logger; Celluloid.logger; end

.manage(action, just = nil) ⇒ Object

Parameters:

  • action (#to_s)

    is the method name to execute on all parts

  • specify (#to_s)

    just to execute the action on one part



67
68
69
70
71
72
# File 'lib/eq.rb', line 67

def manage action, just=nil
  what = just ? just.to_s : "queue work schedul"
  EQ::Queueing.send(action) if what =~ /queue/ && queueing_loaded?
  EQ::Working.send(action) if what =~ /work/ && working_loaded?
  EQ::Scheduling.send(action) if what =~ /schedu/ && working_loaded?
end

.queueObject



40
# File 'lib/eq.rb', line 40

def queue; EQ::Queueing.queue if queueing_loaded?; end

.queueing_loaded?Boolean

Returns:

  • (Boolean)


61
# File 'lib/eq.rb', line 61

def queueing_loaded?; defined? EQ::Queueing; end

.schedulerObject



42
# File 'lib/eq.rb', line 42

def scheduler; EQ::Scheduling.scheduler if scheduling_loaded?; end

.scheduling_loaded?Boolean

Returns:

  • (Boolean)


63
# File 'lib/eq.rb', line 63

def scheduling_loaded?; defined? EQ::Scheduling; end

.shutdown(just = nil) ⇒ Object



38
# File 'lib/eq.rb', line 38

def shutdown just=nil; manage :shutdown, just; end

.workerObject



41
# File 'lib/eq.rb', line 41

def worker; EQ::Working.worker if working_loaded?; end

.working_loaded?Boolean

Returns:

  • (Boolean)


62
# File 'lib/eq.rb', line 62

def working_loaded?; defined? EQ::Working; end