faktory_worker_ruby 1.0.3 → 1.1.0
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 +1 -1
- data/faktory_worker_ruby.gemspec +8 -0
- data/lib/faktory/batch.rb +1 -1
- data/lib/faktory/cli.rb +1 -1
- data/lib/faktory/client.rb +20 -6
- data/lib/faktory/launcher.rb +22 -1
- data/lib/faktory/version.rb +1 -1
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca8f1a3c8f94200639fe96c6ed6664ab02e3240a4176d73463cfd185bf0dd577
|
4
|
+
data.tar.gz: c0a039afe5d4a3ca54d5c8ef779c282cd2266bce6665998c8da60d1829fa4cb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ccf18cb61e1428fa6443c7f9862861d959bbf40d0914f94c8457642c97e72be367c5e3d019ae3a9cfc30f65dae22ad865b591892f6985a3a460d44dc442c378
|
7
|
+
data.tar.gz: c9822086ef38bf740abd2a6b6afd099305e0d1998e0adcdefb6dbf5ccb84d7b4a6497ef22359320d13fef70899dfb7ebf29c361bd405ea7bb93eb41463719070
|
data/Changes.md
CHANGED
data/Gemfile.lock
CHANGED
data/faktory_worker_ruby.gemspec
CHANGED
@@ -16,6 +16,14 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = Faktory::VERSION
|
17
17
|
gem.required_ruby_version = ">= 2.5.0"
|
18
18
|
|
19
|
+
gem.metadata = {
|
20
|
+
"homepage_uri" => "https://contribsys.com/faktory",
|
21
|
+
"bug_tracker_uri" => "https://github.com/contribsys/faktory_worker_ruby/issues",
|
22
|
+
"documentation_uri" => "https://github.com/contribsys/faktory_worker_ruby/wiki",
|
23
|
+
"changelog_uri" => "https://github.com/contribsys/faktory_worker_ruby/blob/master/Changes.md",
|
24
|
+
"source_code_uri" => "https://github.com/contribsys/faktory_worker_ruby",
|
25
|
+
}
|
26
|
+
|
19
27
|
gem.add_dependency 'connection_pool', '~> 2.2', ">= 2.2.2"
|
20
28
|
gem.add_development_dependency 'activejob', '>= 5.2.0'
|
21
29
|
gem.add_development_dependency 'minitest', '~> 5'
|
data/lib/faktory/batch.rb
CHANGED
data/lib/faktory/cli.rb
CHANGED
@@ -212,7 +212,7 @@ module Faktory
|
|
212
212
|
if !File.exist?(options[:require]) ||
|
213
213
|
(File.directory?(options[:require]) && !File.exist?("#{options[:require]}/config/application.rb"))
|
214
214
|
logger.info "=================================================================="
|
215
|
-
logger.info " Please point Faktory to a Rails
|
215
|
+
logger.info " Please point Faktory to a Rails application or a Ruby file "
|
216
216
|
logger.info " to load your worker classes with -r [DIR|FILE]."
|
217
217
|
logger.info "=================================================================="
|
218
218
|
logger.info @parser
|
data/lib/faktory/client.rb
CHANGED
@@ -141,6 +141,22 @@ module Faktory
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
+
def pause_queues(queues)
|
145
|
+
qs = Array(queues)
|
146
|
+
transaction do
|
147
|
+
command "QUEUE PAUSE", qs.join(" ")
|
148
|
+
ok
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def resume_queues(queues)
|
153
|
+
qs = Array(queues)
|
154
|
+
transaction do
|
155
|
+
command "QUEUE RESUME", qs.join(" ")
|
156
|
+
ok
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
144
160
|
# Push a hash corresponding to a job payload to Faktory.
|
145
161
|
# Hash must contain "jid", "jobtype" and "args" elements at minimum.
|
146
162
|
# Returned value will either be the JID String if successful OR
|
@@ -188,13 +204,11 @@ module Faktory
|
|
188
204
|
# Return a string signal to process, legal values are "quiet" or "terminate".
|
189
205
|
# The quiet signal is informative: the server won't allow this process to FETCH
|
190
206
|
# any more jobs anyways.
|
191
|
-
def beat(current_state = nil)
|
207
|
+
def beat(current_state = nil, hash)
|
192
208
|
transaction do
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
command("BEAT", %Q[{"wid":"#{@@random_process_wid}", "current_state":"#{current_state}"}])
|
197
|
-
end
|
209
|
+
hash["wid"] = @@random_process_wid
|
210
|
+
hash["current_state"] = current_state if current_state
|
211
|
+
command("BEAT", Faktory.dump_json(hash))
|
198
212
|
|
199
213
|
str = result!
|
200
214
|
if str == "OK"
|
data/lib/faktory/launcher.rb
CHANGED
@@ -60,7 +60,7 @@ module Faktory
|
|
60
60
|
$0 = PROCTITLES.map {|p| p.call }.join(" ")
|
61
61
|
|
62
62
|
begin
|
63
|
-
result = Faktory.server {|c| c.beat(@current_state) }
|
63
|
+
result = Faktory.server {|c| c.beat(@current_state, "rss_kb" => memory_usage(::Process.pid)) }
|
64
64
|
case result
|
65
65
|
when "OK"
|
66
66
|
# all good
|
@@ -78,5 +78,26 @@ module Faktory
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
MEMORY_GRABBER = case RUBY_PLATFORM
|
82
|
+
when /linux/
|
83
|
+
->(pid) {
|
84
|
+
IO.readlines("/proc/#{$$}/status").each do |line|
|
85
|
+
next unless line.start_with?("VmRSS:")
|
86
|
+
break line.split[1].to_i
|
87
|
+
end
|
88
|
+
}
|
89
|
+
when /darwin|bsd/
|
90
|
+
->(pid) {
|
91
|
+
`ps -o pid,rss -p #{pid}`.lines.last.split.last.to_i
|
92
|
+
}
|
93
|
+
else
|
94
|
+
->(pid) { 0 }
|
95
|
+
end
|
96
|
+
|
97
|
+
def memory_usage(pid)
|
98
|
+
MEMORY_GRABBER.call(pid)
|
99
|
+
end
|
100
|
+
|
101
|
+
|
81
102
|
end
|
82
103
|
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: 1.0
|
4
|
+
version: 1.1.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: 2021-
|
11
|
+
date: 2021-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|
@@ -132,7 +132,12 @@ files:
|
|
132
132
|
homepage: https://github.com/contribsys/faktory_worker_ruby
|
133
133
|
licenses:
|
134
134
|
- LGPL-3.0
|
135
|
-
metadata:
|
135
|
+
metadata:
|
136
|
+
homepage_uri: https://contribsys.com/faktory
|
137
|
+
bug_tracker_uri: https://github.com/contribsys/faktory_worker_ruby/issues
|
138
|
+
documentation_uri: https://github.com/contribsys/faktory_worker_ruby/wiki
|
139
|
+
changelog_uri: https://github.com/contribsys/faktory_worker_ruby/blob/master/Changes.md
|
140
|
+
source_code_uri: https://github.com/contribsys/faktory_worker_ruby
|
136
141
|
post_install_message:
|
137
142
|
rdoc_options: []
|
138
143
|
require_paths:
|
@@ -148,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
153
|
- !ruby/object:Gem::Version
|
149
154
|
version: '0'
|
150
155
|
requirements: []
|
151
|
-
rubygems_version: 3.
|
156
|
+
rubygems_version: 3.1.4
|
152
157
|
signing_key:
|
153
158
|
specification_version: 4
|
154
159
|
summary: Ruby worker for Faktory
|