Module: Creeper::Util

Includes:
ExceptionHandler
Included in:
CLI, Fetcher, Manager, Middleware::Server::RetryJobs, Processor
Defined in:
lib/creeper/util.rb

Overview

This module is part of Creeper core and not intended for extensions.

Constant Summary collapse

EXPIRY =
60 * 60

Instance Method Summary collapse

Methods included from ExceptionHandler

#handle_exception

Instance Method Details

#beanstalk(&block) ⇒ Object



33
34
35
# File 'lib/creeper/util.rb', line 33

def beanstalk(&block)
  Creeper.beanstalk(&block)
end

#constantize(camel_cased_word) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/creeper/util.rb', line 12

def constantize(camel_cased_word)
  names = camel_cased_word.split('::')
  names.shift if names.empty? || names.first.empty?

  constant = Object
  names.each do |name|
    constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
  end
  constant
end

#loggerObject



29
30
31
# File 'lib/creeper/util.rb', line 29

def logger
  Creeper.logger
end

#process_idObject



41
42
43
# File 'lib/creeper/util.rb', line 41

def process_id
  Process.pid
end

#redis(&block) ⇒ Object



37
38
39
# File 'lib/creeper/util.rb', line 37

def redis(&block)
  Creeper.redis(&block)
end

#watchdog(last_words) ⇒ Object



23
24
25
26
27
# File 'lib/creeper/util.rb', line 23

def watchdog(last_words)
  yield
rescue => ex
  handle_exception(ex, { :context => last_words })
end