coney_island 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc75eee43a318be728acdf0b941206e100c76aa2
4
- data.tar.gz: b94cbb25dcbfba834707f0a4fa1cc5e9056d435e
3
+ metadata.gz: e6908c473508be8ab7f86e151c62bf2d0db07406
4
+ data.tar.gz: 7611e7c037d453f77d2c167f793b4a0eea8e1b8d
5
5
  SHA512:
6
- metadata.gz: 4eb709dc6cdf88655300a98fffec366b083756db5bb1cc4c60f268f8d1b444a7ba101dab5d0dfb4465cdb792ce65af9d287f4f7d7ef6ada3ae3facb3cea0f28a
7
- data.tar.gz: 2bff91ac4362619b7eeb1e9111ae6c8983a1675199dd8b2c32e2c835fbc21e560233057d3c867dec5cf2a1c6324594a076124c36b314a4940f39bb8c1a913338
6
+ metadata.gz: 112c89b1653b3945210a8b00d675735930a2330e21d45b9acd808c193a0ef986750472be8df10501c3fc31fa9f3d2ed5b670ded905e8c61ac25b02412954406d
7
+ data.tar.gz: aff0f62fe7948afe9028de91d7586a930ab78f231939182ea6258e04f0a479699c01d71766288658b963e82f60718d0590f3caabffbd5c6d56b24893b7228d98
@@ -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
- @notifier.notify(message, context)
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
@@ -1,3 +1,3 @@
1
1
  module ConeyIsland
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -44,8 +44,6 @@ module ConeyIsland
44
44
 
45
45
  self.log.level = self.config[:log_level]
46
46
  self.log.info("config: #{self.config}")
47
-
48
- @notifier = "ConeyIsland::Notifiers::#{self.config[:notifier_service]}Notifier".constantize
49
47
  end
50
48
 
51
49
  def self.exchange
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.3
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-20 00:00:00.000000000 Z
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