Module: ConeyIsland

Defined in:
lib/coney_island.rb,
lib/coney_island/job.rb,
lib/coney_island/worker.rb,
lib/coney_island/version.rb,
lib/coney_island/performer.rb,
lib/coney_island/submitter.rb,
lib/coney_island/jobs_cache.rb,
lib/coney_island/job_argument_error.rb,
lib/coney_island/configuration_error.rb,
lib/coney_island/notifiers/base_notifier.rb,
lib/coney_island/notifiers/null_notifier.rb,
lib/coney_island/notifiers/bugsnag_notifier.rb,
lib/coney_island/notifiers/airbrake_notifier.rb,
lib/coney_island/notifiers/honeybadger_notifier.rb

Defined Under Namespace

Modules: Notifiers, Performer Classes: ConfigurationError, Job, JobArgumentError, JobsCache, Submitter, Worker

Constant Summary collapse

VERSION =
"0.17.3"

Class Method Summary collapse

Class Method Details

.amqp_connectionObject

BEGIN configuration



8
9
10
# File 'lib/coney_island.rb', line 8

def self.amqp_connection
  @connection
end

.amqp_parametersObject



16
17
18
# File 'lib/coney_island.rb', line 16

def self.amqp_parameters
  @amqp_parameters
end

.amqp_parameters=(params) ⇒ Object



12
13
14
# File 'lib/coney_island.rb', line 12

def self.amqp_parameters=(params)
  @amqp_parameters = params
end

.cache_jobsObject



100
101
102
# File 'lib/coney_island.rb', line 100

def self.cache_jobs
  ConeyIsland::Submitter.cache_jobs
end

.cached_jobsObject



104
105
106
# File 'lib/coney_island.rb', line 104

def self.cached_jobs
  ConeyIsland::Submitter.cached_jobs
end

.caching_jobs(&blk) ⇒ Object



112
113
114
# File 'lib/coney_island.rb', line 112

def self.caching_jobs(&blk)
  ConeyIsland::Submitter.caching_jobs(&blk)
end

.configObject



64
65
66
# File 'lib/coney_island.rb', line 64

def self.config
  ConeyIsland::Worker.config
end

.config=(config_hash) ⇒ Object



55
56
57
58
59
60
61
62
# File 'lib/coney_island.rb', line 55

def self.config=(config_hash)
  self.amqp_parameters = config_hash.delete :amqp_connection
  if !self.single_amqp_connection?
    ConeyIsland::Submitter.amqp_parameters = config_hash.delete :amqp_connection_submitter
    ConeyIsland::Worker.amqp_parameters = config_hash.delete :amqp_connection_worker
  end
  ConeyIsland::Worker.config=(config_hash)
end

.default_settingsObject



135
136
137
# File 'lib/coney_island.rb', line 135

def self.default_settings
  { work_queue: 'default', timeout: 30, delay: 0, highlander: false }
end

.delay_seedObject



68
69
70
# File 'lib/coney_island.rb', line 68

def self.delay_seed
  @delay_seed ||= 2
end

.delay_seed=(seed) ⇒ Object



72
73
74
# File 'lib/coney_island.rb', line 72

def self.delay_seed=(seed)
  @delay_seed = seed
end

.flush_jobsObject



116
117
118
# File 'lib/coney_island.rb', line 116

def self.flush_jobs
  ConeyIsland::Submitter.flush_jobs
end

.initialize_backgroundObject



80
81
82
# File 'lib/coney_island.rb', line 80

def self.initialize_background
  ConeyIsland::Worker.initialize_background
end

.notifierObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/coney_island.rb', line 40

def self.notifier
  case self.config[:notifier]
  when :airbrake
    Notifiers::AirbrakeNotifier
  when :bugsnag
    Notifiers::BugsnagNotifier
  when :honeybadger
    Notifiers::HoneybadgerNotifier
  when :none
    Notifiers::NullNotifier
  else
    fail ConfigurationError, "#{self.config[:notifier]} is an invalid notifier. Valid options: :airbrake, :bugsnag, :honeybadger, :none"
  end
end

.poke_the_badger(message, context = {}, attempts = 1) ⇒ Object



124
125
126
127
128
129
130
131
132
133
# File 'lib/coney_island.rb', line 124

def self.poke_the_badger(message, context = {}, attempts = 1)
  Timeout::timeout(3) do
    self.notifier.notify(message, context)
  end
rescue
  if attempts <= 3
    attempts += 1
    retry
  end
end

.run_inlineObject



88
89
90
# File 'lib/coney_island.rb', line 88

def self.run_inline
  ConeyIsland::Submitter.run_inline
end

.running_inline?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/coney_island.rb', line 92

def self.running_inline?
  ConeyIsland::Submitter.running_inline?
end

.single_amqp_connection?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/coney_island.rb', line 76

def self.single_amqp_connection?
  !!self.amqp_parameters
end

.start_workerObject



84
85
86
# File 'lib/coney_island.rb', line 84

def self.start_worker
  ConeyIsland::Worker.start
end

.stop_caching_jobsObject



108
109
110
# File 'lib/coney_island.rb', line 108

def self.stop_caching_jobs
  ConeyIsland::Submitter.stop_caching_jobs
end

.stop_running_inlineObject



96
97
98
# File 'lib/coney_island.rb', line 96

def self.stop_running_inline
  ConeyIsland::Submitter.stop_running_inline
end

.submit(*args) ⇒ Object



120
121
122
# File 'lib/coney_island.rb', line 120

def self.submit(*args)
  ConeyIsland::Submitter.submit(*args)
end

.tcp_connection_retry_interval(retries) ⇒ Object



28
29
30
# File 'lib/coney_island.rb', line 28

def self.tcp_connection_retry_interval(retries)
  self.tcp_connection_retry_seed ** retries
end

.tcp_connection_retry_limitObject



24
25
26
# File 'lib/coney_island.rb', line 24

def self.tcp_connection_retry_limit
  @tcp_connection_retry_limit ||= 6
end

.tcp_connection_retry_limit=(limit) ⇒ Object



20
21
22
# File 'lib/coney_island.rb', line 20

def self.tcp_connection_retry_limit=(limit)
  @tcp_connection_retry_limit = limit
end

.tcp_connection_retry_seedObject



36
37
38
# File 'lib/coney_island.rb', line 36

def self.tcp_connection_retry_seed
  @tcp_connection_retry_seed ||= 2
end

.tcp_connection_retry_seed=(seed) ⇒ Object



32
33
34
# File 'lib/coney_island.rb', line 32

def self.tcp_connection_retry_seed=(seed)
  @tcp_connection_retry_seed = seed
end