Module: Bluth

Defined in:
lib/bluth.rb,
lib/bluth.rb,
lib/bluth.rb,
lib/bluth.rb,
lib/bluth/cli.rb,
lib/bluth/worker.rb

Defined Under Namespace

Modules: Handler, Queue, VERSION, WorkerBase Classes: Buster, CLI, Gob, Maeby, ScheduleWorker, Shutdown, Worker

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.confObject (readonly)

Returns the value of attribute conf.



45
46
47
# File 'lib/bluth.rb', line 45

def conf
  @conf
end

.dbObject (readonly)

Returns the value of attribute db.



45
46
47
# File 'lib/bluth.rb', line 45

def db
  @db
end

.envObject

Returns the value of attribute env.



46
47
48
# File 'lib/bluth.rb', line 46

def env
  @env
end

.handlersObject (readonly)

Returns the value of attribute handlers.



45
46
47
# File 'lib/bluth.rb', line 45

def handlers
  @handlers
end

.locksObject (readonly)

Returns the value of attribute locks.



45
46
47
# File 'lib/bluth.rb', line 45

def locks
  @locks
end

.poptimeoutObject

Returns the value of attribute poptimeout.



46
47
48
# File 'lib/bluth.rb', line 46

def poptimeout
  @poptimeout
end

.priorityObject

Returns the value of attribute priority.



46
47
48
# File 'lib/bluth.rb', line 46

def priority
  @priority
end

.redisObject

Returns the value of attribute redis.



46
47
48
# File 'lib/bluth.rb', line 46

def redis
  @redis
end

.saltObject (readonly)

Returns the value of attribute salt.



23
24
25
# File 'lib/bluth/worker.rb', line 23

def salt
  @salt
end

.schedulerObject

Returns the value of attribute scheduler.



46
47
48
# File 'lib/bluth.rb', line 46

def scheduler
  @scheduler
end

.uriObject

Returns the value of attribute uri.



46
47
48
# File 'lib/bluth.rb', line 46

def uri
  @uri
end

Class Method Details

.clear_locksObject



53
54
55
56
57
58
# File 'lib/bluth.rb', line 53

def Bluth.clear_locks
  @locks.each { |lock| 
    Familia.info "Removing lock #{lock}"
    Bluth.redis.del lock 
  }
end

.find_locksObject



59
60
61
# File 'lib/bluth.rb', line 59

def Bluth.find_locks
  @locks = Bluth.redis.keys(Familia.rediskey('*', :lock))
end

.popObject



111
112
113
# File 'lib/bluth.rb', line 111

def Bluth.pop
  blocking_queue_handler :brpop
end

.queue(n) ⇒ Object

Raises:

  • (ArgumentError)


66
67
68
69
# File 'lib/bluth.rb', line 66

def Bluth.queue(n)
  raise ArgumentError, "No such queue: #{n}" unless queue?(n)
  Bluth::Queue.send n
end

.queue?(n) ⇒ Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/bluth.rb', line 63

def Bluth.queue?(n)
  Bluth::Queue.queues.collect(&:name).member?(n.to_s.to_sym)
end

.shiftObject

Workers use a blocking pop and will wait for up to Bluth.poptimeout (seconds) before returnning nil. Note that the queues are still processed in order. If all queues are empty, the first one to return a value is use. See:

code.google.com/p/redis/wiki/BlpopCommand



107
108
109
# File 'lib/bluth.rb', line 107

def Bluth.shift
  blocking_queue_handler :blpop
end

.sysinfoObject



47
48
49
50
# File 'lib/bluth.rb', line 47

def sysinfo
  @sysinfo ||= SysInfo.new.freeze
  @sysinfo 
end