faktory_worker_ruby 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes.md +6 -0
- data/Gemfile.lock +18 -1
- data/faktory_worker_ruby.gemspec +1 -0
- data/lib/active_job/queue_adapters/faktory_adapter.rb +53 -0
- data/lib/faktory/rails.rb +10 -0
- data/lib/faktory/testing.rb +1 -5
- data/lib/faktory/version.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d427c1c0dc267c3debcf7fd725fab9a628f7d0d
|
4
|
+
data.tar.gz: 92c6b2099292bc46e2eaf22ba3be5c9f3dadf6b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e856cbcb98527d2b38c000d87cfbced657f42b7956a7090014946c9131b4771f239683df586c084ad17b4e2f07f2e7f9560c62f7f438db99c523e276136540a6
|
7
|
+
data.tar.gz: 44ce04a5b7346b1e8965b917ac9ecaad179936b62fb7dc4107e1cd9fe2155da0ff549c2ef91551c5f18b75daeec5f87a5aa8b38b4b628c3ab9ef4ba0147eb776
|
data/Changes.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,21 +1,38 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
faktory_worker_ruby (0.7.
|
4
|
+
faktory_worker_ruby (0.7.1)
|
5
5
|
connection_pool (~> 2.2, >= 2.2.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
+
activejob (5.1.5)
|
11
|
+
activesupport (= 5.1.5)
|
12
|
+
globalid (>= 0.3.6)
|
13
|
+
activesupport (5.1.5)
|
14
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
+
i18n (~> 0.7)
|
16
|
+
minitest (~> 5.1)
|
17
|
+
tzinfo (~> 1.1)
|
18
|
+
concurrent-ruby (1.0.5)
|
10
19
|
connection_pool (2.2.1)
|
20
|
+
globalid (0.4.1)
|
21
|
+
activesupport (>= 4.2.0)
|
22
|
+
i18n (0.9.5)
|
23
|
+
concurrent-ruby (~> 1.0)
|
11
24
|
minitest (5.10.3)
|
12
25
|
minitest-hooks (1.4.2)
|
13
26
|
rake (12.1.0)
|
27
|
+
thread_safe (0.3.6)
|
28
|
+
tzinfo (1.2.5)
|
29
|
+
thread_safe (~> 0.1)
|
14
30
|
|
15
31
|
PLATFORMS
|
16
32
|
ruby
|
17
33
|
|
18
34
|
DEPENDENCIES
|
35
|
+
activejob (>= 5.1.5)
|
19
36
|
faktory_worker_ruby!
|
20
37
|
minitest (~> 5)
|
21
38
|
minitest-hooks
|
data/faktory_worker_ruby.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.required_ruby_version = ">= 2.2.2"
|
18
18
|
|
19
19
|
gem.add_dependency 'connection_pool', '~> 2.2', ">= 2.2.1"
|
20
|
+
gem.add_development_dependency 'activejob', '>= 5.1.5'
|
20
21
|
gem.add_development_dependency 'minitest', '~> 5'
|
21
22
|
gem.add_development_dependency 'minitest-hooks'
|
22
23
|
gem.add_development_dependency 'rake', '~> 12'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_job'
|
4
|
+
|
5
|
+
module ActiveJob
|
6
|
+
module QueueAdapters
|
7
|
+
# == Faktory adapter for Active Job
|
8
|
+
#
|
9
|
+
# To use Faktory set the queue_adapter config to +:faktory+.
|
10
|
+
#
|
11
|
+
# Rails.application.config.active_job.queue_adapter = :faktory
|
12
|
+
class FaktoryAdapter
|
13
|
+
def enqueue(job) #:nodoc:
|
14
|
+
jid = SecureRandom.hex(12)
|
15
|
+
job.provider_job_id = jid
|
16
|
+
# Faktory::Client does not support symbols as keys
|
17
|
+
Faktory::Client.new.push \
|
18
|
+
"jid" => jid,
|
19
|
+
"jobtype" => JobWrapper,
|
20
|
+
"custom" => {
|
21
|
+
"wrapped" => job.class.to_s,
|
22
|
+
},
|
23
|
+
"priority" => job.priority,
|
24
|
+
"queue" => job.queue_name,
|
25
|
+
"args" => [ job.serialize ]
|
26
|
+
end
|
27
|
+
|
28
|
+
def enqueue_at(job, timestamp) #:nodoc:
|
29
|
+
jid = SecureRandom.hex(12)
|
30
|
+
job.provider_job_id = jid
|
31
|
+
# Faktory::Client does not support symbols as keys
|
32
|
+
Faktory::Client.new.push \
|
33
|
+
"jid" => jid,
|
34
|
+
"jobtype" => JobWrapper,
|
35
|
+
"custom" => {
|
36
|
+
"wrapped" => job.class.to_s
|
37
|
+
},
|
38
|
+
"priority" => job.priority,
|
39
|
+
"queue" => job.queue_name,
|
40
|
+
"args" => [ job.serialize ],
|
41
|
+
"at" => Time.at(timestamp).utc.to_datetime.rfc3339(9)
|
42
|
+
end
|
43
|
+
|
44
|
+
class JobWrapper #:nodoc:
|
45
|
+
include Faktory::Job
|
46
|
+
|
47
|
+
def perform(job_data)
|
48
|
+
Base.execute job_data
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/faktory/rails.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Faktory
|
3
3
|
class Rails < ::Rails::Engine
|
4
|
+
# This hook happens after `Rails::Application` is inherited within
|
5
|
+
# config/application.rb and before config is touched, usually within the
|
6
|
+
# class block. Definitely before config/environments/*.rb and
|
7
|
+
# config/initializers/*.rb.
|
8
|
+
config.before_configuration do
|
9
|
+
if defined?(::ActiveJob)
|
10
|
+
require 'active_job/queue_adapters/faktory_adapter'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
4
14
|
config.after_initialize do
|
5
15
|
# This hook happens after all initializers are run, just before returning
|
6
16
|
# from config/environment.rb back to faktory/cli.rb.
|
data/lib/faktory/testing.rb
CHANGED
@@ -31,7 +31,7 @@ module Faktory
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.inline!(&block)
|
34
|
-
# Only allow
|
34
|
+
# Only allow inline testing inside of a block
|
35
35
|
# https://github.com/mperham/sidekiq/issues/3495
|
36
36
|
unless block_given?
|
37
37
|
raise 'Must provide a block to Faktory::Testing.inline!'
|
@@ -40,10 +40,6 @@ module Faktory
|
|
40
40
|
__set_test_mode(:inline, &block)
|
41
41
|
end
|
42
42
|
|
43
|
-
def self.blockless_inline_is_a_bad_idea_but_I_wanna_do_it_anyway!
|
44
|
-
__set_test_mode(:inline)
|
45
|
-
end
|
46
|
-
|
47
43
|
def self.enabled?
|
48
44
|
self.__test_mode != :disable
|
49
45
|
end
|
data/lib/faktory/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faktory_worker_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Perham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|
@@ -30,6 +30,20 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.2.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activejob
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 5.1.5
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 5.1.5
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: minitest
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,6 +103,7 @@ files:
|
|
89
103
|
- Rakefile
|
90
104
|
- bin/faktory-worker
|
91
105
|
- faktory_worker_ruby.gemspec
|
106
|
+
- lib/active_job/queue_adapters/faktory_adapter.rb
|
92
107
|
- lib/faktory.rb
|
93
108
|
- lib/faktory/cli.rb
|
94
109
|
- lib/faktory/client.rb
|
@@ -128,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
143
|
version: '0'
|
129
144
|
requirements: []
|
130
145
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
146
|
+
rubygems_version: 2.5.1
|
132
147
|
signing_key:
|
133
148
|
specification_version: 4
|
134
149
|
summary: Ruby worker for Faktory
|