Class: WorkerArmy::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/worker_army/base.rb

Direct Known Subclasses

Client, Queue, Worker

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.client_retry_count(conf = nil) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/worker_army/base.rb', line 37

def client_retry_count(conf = nil)
  if ENV['worker_army_client_retry_count']
    return ENV['worker_army_client_retry_count'].to_i
  elsif conf and conf['client_retry_count']
    return conf['client_retry_count'].to_i
  else
    return 10
  end
end

.configObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/worker_army/base.rb', line 4

def config
  return $config if $config
  if ENV['worker_army_redis_host'] and ENV['worker_army_redis_port']
    config = { 'redis_host' => ENV['worker_army_redis_host'], 'redis_port' => ENV['worker_army_redis_port'] }
    if ENV['worker_army_redis_auth']
      config['redis_auth'] = ENV['worker_army_redis_auth']
    end
    if ENV['worker_army_worker_retry_count']
      config['worker_retry_count'] = ENV['worker_army_worker_retry_count'].to_i
    end
    if ENV['worker_army_client_retry_count']
      config['client_retry_count'] = ENV['worker_army_client_retry_count'].to_i
    end
    if ENV['worker_army_callback_retry_count']
      config['callback_retry_count'] = ENV['worker_army_callback_retry_count'].to_i
    end
    if ENV['worker_army_endpoint']
      config['endpoint'] = ENV['worker_army_endpoint']
    end
    if ENV['worker_army_store_job_data']
      config['store_job_data'] = (ENV['worker_army_store_job_data'] == 'true')
    end
  else
    begin
      # puts "Using config in your home directory"
      config = YAML.load(File.read("#{ENV['HOME']}/.worker_army.yml"))
    rescue Errno::ENOENT
      raise "worker-army configuration expected in ~/.worker_army.yml or provide env vars..."
    end
  end
  $config = config
end

Instance Method Details

#callback_retry_count(conf = nil) ⇒ Object



62
63
64
65
66
67
68
69
70
# File 'lib/worker_army/base.rb', line 62

def callback_retry_count(conf = nil)
  if ENV['worker_army_callback_retry_count']
    return ENV['worker_army_callback_retry_count'].to_i
  elsif conf and conf['callback_retry_count']
    return conf['callback_retry_count'].to_i
  else
    return 3
  end
end

#configObject



48
49
50
# File 'lib/worker_army/base.rb', line 48

def config
  WorkerArmy::Base.config
end

#worker_retry_count(conf = nil) ⇒ Object



52
53
54
55
56
57
58
59
60
# File 'lib/worker_army/base.rb', line 52

def worker_retry_count(conf = nil)
  if ENV['worker_army_worker_retry_count']
    return ENV['worker_army_worker_retry_count'].to_i
  elsif conf and conf['worker_retry_count']
    return conf['worker_retry_count'].to_i
  else
    return 10
  end
end