coney_island 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/coney_island.rb +13 -2
- data/lib/coney_island/queue_adapter.rb +36 -0
- data/lib/coney_island/version.rb +1 -1
- data/lib/coney_island/worker.rb +0 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6908c473508be8ab7f86e151c62bf2d0db07406
|
4
|
+
data.tar.gz: 7611e7c037d453f77d2c167f793b4a0eea8e1b8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 112c89b1653b3945210a8b00d675735930a2330e21d45b9acd808c193a0ef986750472be8df10501c3fc31fa9f3d2ed5b670ded905e8c61ac25b02412954406d
|
7
|
+
data.tar.gz: aff0f62fe7948afe9028de91d7586a930ab78f231939182ea6258e04f0a479699c01d71766288658b963e82f60718d0590f3caabffbd5c6d56b24893b7228d98
|
data/lib/coney_island.rb
CHANGED
@@ -40,7 +40,16 @@ module ConeyIsland
|
|
40
40
|
@tcp_connection_retry_interval ||= 10
|
41
41
|
end
|
42
42
|
|
43
|
+
def self.notifier
|
44
|
+
@notifier ||= "ConeyIsland::Notifiers::#{self.config[:notifier_service]}Notifier".constantize
|
45
|
+
end
|
46
|
+
|
43
47
|
def self.handle_connection(log)
|
48
|
+
if self.config
|
49
|
+
log.info("ConeyIsland.handle_connection, notifier service is #{self.notifier}")
|
50
|
+
else
|
51
|
+
log.info("NO CONFIG FOUND!!!")
|
52
|
+
end
|
44
53
|
@connection ||= AMQP.connect(self.amqp_parameters)
|
45
54
|
rescue AMQP::TCPConnectionFailed => e
|
46
55
|
self.tcp_connection_retries ||= 0
|
@@ -133,7 +142,7 @@ module ConeyIsland
|
|
133
142
|
|
134
143
|
def self.poke_the_badger(message, context, attempts = 1)
|
135
144
|
Timeout::timeout(3) do
|
136
|
-
|
145
|
+
self.notifier.notify(message, context)
|
137
146
|
end
|
138
147
|
rescue
|
139
148
|
if attempts <= 3
|
@@ -147,4 +156,6 @@ end
|
|
147
156
|
require 'coney_island/notifiers/honeybadger_notifier'
|
148
157
|
require 'coney_island/worker'
|
149
158
|
require 'coney_island/submitter'
|
150
|
-
|
159
|
+
if defined? ActiveJob::QueueAdapters
|
160
|
+
require 'coney_island/queue_adapters'
|
161
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module ActiveJob
|
2
|
+
module QueueAdapters
|
3
|
+
# == ConeyIsland adapter for Active Job
|
4
|
+
#
|
5
|
+
# ConeyIsland is an industrial-strength background worker system for Rails using RabbitMQ. Read more about
|
6
|
+
# {here}[http://edraut.github.io/coney_island/].
|
7
|
+
#
|
8
|
+
# To use ConeyIsland set the queue_adapter config to +:coney_island+.
|
9
|
+
#
|
10
|
+
# Rails.application.config.active_job.queue_adapter = :coney_island
|
11
|
+
class ConeyIslandAdapter
|
12
|
+
class << self
|
13
|
+
def enqueue(job) #:nodoc:
|
14
|
+
ConeyIsland::Worker.submit JobWrapper, :perform, args: [ job.arguments ], work_queue: job.queue_name, timeout: get_timeout_from_args(job)
|
15
|
+
end
|
16
|
+
|
17
|
+
def enqueue_at(job, timestamp) #:nodoc:
|
18
|
+
delay = timestamp - Time.current.to_f
|
19
|
+
ConeyIsland::Worker.submit JobWrapper, :perform, args: [ job.arguments ], work_queue: job.queue_name, delay: delay, timeout: get_timeout_from_args(job)
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_timeout_from_args(job)
|
23
|
+
job.arguments['timeout']
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class JobWrapper #:nodoc:
|
28
|
+
class << self
|
29
|
+
def perform(job_data)
|
30
|
+
Base.execute job_data
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/coney_island/version.rb
CHANGED
data/lib/coney_island/worker.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coney_island
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Draut
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/coney_island.rb
|
111
111
|
- lib/coney_island/notifiers/airbrake_notifier.rb
|
112
112
|
- lib/coney_island/notifiers/honeybadger_notifier.rb
|
113
|
+
- lib/coney_island/queue_adapter.rb
|
113
114
|
- lib/coney_island/submitter.rb
|
114
115
|
- lib/coney_island/version.rb
|
115
116
|
- lib/coney_island/worker.rb
|