faktory_worker_ruby 0.7.1 → 0.8.0
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/.travis.yml +11 -0
- data/Changes.md +6 -3
- data/Gemfile.lock +12 -11
- data/README.md +2 -0
- data/lib/active_job/queue_adapters/faktory_adapter.rb +22 -18
- data/lib/faktory/cli.rb +4 -0
- data/lib/faktory/client.rb +2 -1
- data/lib/faktory/launcher.rb +11 -1
- data/lib/faktory/logging.rb +2 -2
- data/lib/faktory/middleware/i18n.rb +2 -4
- data/lib/faktory/rails.rb +11 -0
- data/lib/faktory/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ffc1c6d5392fd64f4463ae4a47972f7d2c13ebc
|
4
|
+
data.tar.gz: cc1e0294bc5c333f7ce684f112ee1182e20d2095
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f2a3b5f59d0a50c77f0f22ec86f291289762ba5e27dc012fa9cce34807883aee616b7ca9b7a937139b67137725f450c0e7fc504909f0a84136ebd4b6e67586e
|
7
|
+
data.tar.gz: 7ef1fd93ff1d803bb7d895d63749a3deb9cd4fe4000936df5b8e1facfca884e22e439574979b821972936b16b1ea15ef31f97c3db306b90b4d7514ea214d1437
|
data/.travis.yml
ADDED
data/Changes.md
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
-
## 0.
|
3
|
+
## 0.8.0
|
4
|
+
|
5
|
+
- Add `-l LABEL` argument for adding labels to a process [#27, jpwinans]
|
6
|
+
- Support the quiet and shutdown heartbeat signals from the server [#28]
|
4
7
|
|
5
|
-
|
8
|
+
## 0.7.1
|
6
9
|
|
7
|
-
|
10
|
+
- Add an ActiveJob adapter for FWR. [#17, jagthedrummer]
|
8
11
|
|
9
12
|
## 0.7.0
|
10
13
|
|
data/Gemfile.lock
CHANGED
@@ -1,29 +1,30 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
faktory_worker_ruby (0.
|
4
|
+
faktory_worker_ruby (0.8.0)
|
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
|
11
|
-
activesupport (= 5.1
|
10
|
+
activejob (5.2.1)
|
11
|
+
activesupport (= 5.2.1)
|
12
12
|
globalid (>= 0.3.6)
|
13
|
-
activesupport (5.1
|
13
|
+
activesupport (5.2.1)
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
-
i18n (
|
15
|
+
i18n (>= 0.7, < 2)
|
16
16
|
minitest (~> 5.1)
|
17
17
|
tzinfo (~> 1.1)
|
18
18
|
concurrent-ruby (1.0.5)
|
19
|
-
connection_pool (2.2.
|
19
|
+
connection_pool (2.2.2)
|
20
20
|
globalid (0.4.1)
|
21
21
|
activesupport (>= 4.2.0)
|
22
|
-
i18n (
|
22
|
+
i18n (1.1.0)
|
23
23
|
concurrent-ruby (~> 1.0)
|
24
|
-
minitest (5.
|
25
|
-
minitest-hooks (1.
|
26
|
-
|
24
|
+
minitest (5.11.3)
|
25
|
+
minitest-hooks (1.5.0)
|
26
|
+
minitest (> 5.3)
|
27
|
+
rake (12.3.1)
|
27
28
|
thread_safe (0.3.6)
|
28
29
|
tzinfo (1.2.5)
|
29
30
|
thread_safe (~> 0.1)
|
@@ -39,4 +40,4 @@ DEPENDENCIES
|
|
39
40
|
rake (~> 12)
|
40
41
|
|
41
42
|
BUNDLED WITH
|
42
|
-
1.16.
|
43
|
+
1.16.3
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# faktory\_worker\_ruby
|
2
2
|
|
3
|
+

|
4
|
+
|
3
5
|
Faktory\_worker\_ruby is the official Ruby client and worker process for the
|
4
6
|
Faktory background job server. It is similar to [Sidekiq](http://sidekiq.org).
|
5
7
|
|
@@ -11,34 +11,29 @@ module ActiveJob
|
|
11
11
|
# Rails.application.config.active_job.queue_adapter = :faktory
|
12
12
|
class FaktoryAdapter
|
13
13
|
def enqueue(job) #:nodoc:
|
14
|
-
|
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 ]
|
14
|
+
enqueue_at(job, nil)
|
26
15
|
end
|
27
16
|
|
28
17
|
def enqueue_at(job, timestamp) #:nodoc:
|
29
18
|
jid = SecureRandom.hex(12)
|
30
19
|
job.provider_job_id = jid
|
31
|
-
|
32
|
-
Faktory::Client.new.push \
|
20
|
+
hash = {
|
33
21
|
"jid" => jid,
|
34
|
-
"jobtype" => JobWrapper,
|
22
|
+
"jobtype" => JobWrapper.to_s,
|
35
23
|
"custom" => {
|
36
|
-
"wrapped" => job.class.to_s
|
24
|
+
"wrapped" => job.class.to_s,
|
37
25
|
},
|
38
|
-
"priority" => job.priority,
|
39
26
|
"queue" => job.queue_name,
|
40
27
|
"args" => [ job.serialize ],
|
41
|
-
|
28
|
+
}
|
29
|
+
opts = job.faktory_options_hash.dup
|
30
|
+
hash["at"] = Time.at(timestamp).utc.to_datetime.rfc3339(9) if timestamp
|
31
|
+
if opts.size > 0
|
32
|
+
hash["retry"] = opts.delete("retry") if opts.has_key?("retry")
|
33
|
+
hash["custom"] = opts.merge(hash["custom"])
|
34
|
+
end
|
35
|
+
# Faktory::Client does not support symbols as keys
|
36
|
+
Faktory::Client.new.push(hash)
|
42
37
|
end
|
43
38
|
|
44
39
|
class JobWrapper #:nodoc:
|
@@ -50,4 +45,13 @@ module ActiveJob
|
|
50
45
|
end
|
51
46
|
end
|
52
47
|
end
|
48
|
+
|
49
|
+
class Base
|
50
|
+
class_attribute :faktory_options_hash
|
51
|
+
self.faktory_options_hash = {}
|
52
|
+
|
53
|
+
def self.faktory_options(hsh)
|
54
|
+
self.faktory_options_hash = self.faktory_options_hash.stringify_keys.merge(hsh.stringify_keys)
|
55
|
+
end
|
56
|
+
end
|
53
57
|
end
|
data/lib/faktory/cli.rb
CHANGED
@@ -235,6 +235,10 @@ module Faktory
|
|
235
235
|
opts[:tag] = arg
|
236
236
|
end
|
237
237
|
|
238
|
+
o.on '-l', '--label LABEL', "Process label to use in Faktory UI" do |arg|
|
239
|
+
(opts[:labels] ||= []) << arg
|
240
|
+
end
|
241
|
+
|
238
242
|
o.on "-q", "--queue QUEUE[,WEIGHT]", "Queues to process with optional weights" do |arg|
|
239
243
|
queue, weight = arg.split(",")
|
240
244
|
parse_queue opts, queue, weight
|
data/lib/faktory/client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'socket'
|
2
2
|
require 'json'
|
3
3
|
require 'uri'
|
4
|
+
require 'digest'
|
4
5
|
require 'securerandom'
|
5
6
|
|
6
7
|
module Faktory
|
@@ -148,7 +149,7 @@ module Faktory
|
|
148
149
|
"wid": @@random_process_wid,
|
149
150
|
"hostname": Socket.gethostname,
|
150
151
|
"pid": $$,
|
151
|
-
"labels": ["ruby-#{RUBY_VERSION}"],
|
152
|
+
"labels": Faktory.options[:labels] || ["ruby-#{RUBY_VERSION}"],
|
152
153
|
"v": 2,
|
153
154
|
}
|
154
155
|
|
data/lib/faktory/launcher.rb
CHANGED
@@ -55,7 +55,17 @@ module Faktory
|
|
55
55
|
$0 = PROCTITLES.map {|p| p.call }.join(" ")
|
56
56
|
|
57
57
|
begin
|
58
|
-
Faktory.server {|c| c.beat }
|
58
|
+
result = Faktory.server {|c| c.beat }
|
59
|
+
case result
|
60
|
+
when "OK"
|
61
|
+
# all good
|
62
|
+
when "terminate"
|
63
|
+
::Process.kill('TERM', $$)
|
64
|
+
when "quiet"
|
65
|
+
::Process.kill('TSTP', $$)
|
66
|
+
else
|
67
|
+
Faktory.logger.warn "Got unexpected BEAT: #{result}"
|
68
|
+
end
|
59
69
|
rescue => ex
|
60
70
|
# best effort, try again in a few secs
|
61
71
|
end
|
data/lib/faktory/logging.rb
CHANGED
@@ -29,8 +29,8 @@ module Faktory
|
|
29
29
|
def self.job_hash_context(job_hash)
|
30
30
|
# If we're using a wrapper class, like ActiveJob, use the "wrapped"
|
31
31
|
# attribute to expose the underlying thing.
|
32
|
-
klass = job_hash['wrapped'
|
33
|
-
"#{klass} JID-#{job_hash['jid'
|
32
|
+
klass = job_hash['custom']['wrapped'] || job_hash["jobtype"]
|
33
|
+
"#{klass} JID-#{job_hash['jid']}"
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.with_job_hash_context(job_hash, &block)
|
@@ -19,10 +19,8 @@ module Faktory::Middleware::I18n
|
|
19
19
|
# Pull the msg locale out and set the current thread to use it.
|
20
20
|
class Worker
|
21
21
|
def call(jobinst, payload)
|
22
|
-
|
23
|
-
yield
|
24
|
-
ensure
|
25
|
-
I18n.locale = I18n.default_locale
|
22
|
+
locale = payload.dig("custom", "locale") || I18n.default_locale
|
23
|
+
I18n.with_locale(locale) { yield }
|
26
24
|
end
|
27
25
|
end
|
28
26
|
end
|
data/lib/faktory/rails.rb
CHANGED
@@ -20,6 +20,10 @@ module Faktory
|
|
20
20
|
# None of this matters on the client-side, only within the Faktory executor itself.
|
21
21
|
#
|
22
22
|
Faktory.configure_worker do |_|
|
23
|
+
if ::Rails::VERSION::MAJOR < 5
|
24
|
+
raise "Your current version of Rails, #{::Rails::VERSION::STRING}, is not supported"
|
25
|
+
end
|
26
|
+
|
23
27
|
Faktory.options[:reloader] = Faktory::Rails::Reloader.new
|
24
28
|
end
|
25
29
|
end
|
@@ -40,4 +44,11 @@ module Faktory
|
|
40
44
|
end
|
41
45
|
end
|
42
46
|
end if defined?(::Rails)
|
47
|
+
|
48
|
+
if defined?(::Rails) && ::Rails::VERSION::MAJOR < 5
|
49
|
+
$stderr.puts("**************************************************")
|
50
|
+
$stderr.puts("🚫 ERROR: Faktory Worker does not support Rails versions under 5.x - please ensure your workers are updated")
|
51
|
+
$stderr.puts("**************************************************")
|
52
|
+
$stderr.puts("")
|
53
|
+
end
|
43
54
|
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.
|
4
|
+
version: 0.8.0
|
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-
|
11
|
+
date: 2018-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|
@@ -95,6 +95,7 @@ extensions: []
|
|
95
95
|
extra_rdoc_files: []
|
96
96
|
files:
|
97
97
|
- ".gitignore"
|
98
|
+
- ".travis.yml"
|
98
99
|
- Changes.md
|
99
100
|
- Gemfile
|
100
101
|
- Gemfile.lock
|
@@ -143,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
144
|
version: '0'
|
144
145
|
requirements: []
|
145
146
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.
|
147
|
+
rubygems_version: 2.6.13
|
147
148
|
signing_key:
|
148
149
|
specification_version: 4
|
149
150
|
summary: Ruby worker for Faktory
|