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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a183f21103562c224add2460da73a145a0c12c32a167525fd18dd02fe334241
4
- data.tar.gz: b7c76d7001ba133f685427ffcc00bcdd75d026747106fac705b741e57f3d7b94
3
+ metadata.gz: ca8f1a3c8f94200639fe96c6ed6664ab02e3240a4176d73463cfd185bf0dd577
4
+ data.tar.gz: c0a039afe5d4a3ca54d5c8ef779c282cd2266bce6665998c8da60d1829fa4cb2
5
5
  SHA512:
6
- metadata.gz: 6bae416fa9d2675c586a8a40ccce0005f665eb2ab2bc19e6a5e12405cafee67aef22984d9e84f6db96012143eee87307d81e089fad5fd81d6dd278489fe62437
7
- data.tar.gz: 42806775422a7542a1a7c7e912bc373dfe8c0d2b1d47d8cccb3ce8d91a0c1a95f8a835cb99cc1b9da2262d17ac3f50e7447ecefcf4eff6ba3ef0d9672e8b1f06
6
+ metadata.gz: 3ccf18cb61e1428fa6443c7f9862861d959bbf40d0914f94c8457642c97e72be367c5e3d019ae3a9cfc30f65dae22ad865b591892f6985a3a460d44dc442c378
7
+ data.tar.gz: c9822086ef38bf740abd2a6b6afd099305e0d1998e0adcdefb6dbf5ccb84d7b4a6497ef22359320d13fef70899dfb7ebf29c361bd405ea7bb93eb41463719070
data/Changes.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changes
2
2
 
3
+ ## 1.1.0
4
+
5
+ - Send process RSS to Faktory for /Busy page
6
+ - Implement QUEUE PAUSE/RESUME client commands
7
+ - Fix broken `complete` callback with batches
8
+
3
9
  ## 1.0.3
4
10
 
5
11
  - Fix corruption in `custom` hash elements [#55]
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- faktory_worker_ruby (1.0.2)
4
+ faktory_worker_ruby (1.1.0)
5
5
  connection_pool (~> 2.2, >= 2.2.2)
6
6
 
7
7
  GEM
@@ -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
@@ -98,7 +98,7 @@ module Faktory
98
98
 
99
99
  def complete=(val)
100
100
  raise "Batch cannot be modified once created" if bid
101
- @success = to_callback(val)
101
+ @complete = to_callback(val)
102
102
  end
103
103
 
104
104
  def jobs(&block)
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 5 application or a Ruby file "
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
@@ -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
- if current_state.nil?
194
- command("BEAT", %Q[{"wid":"#{@@random_process_wid}"}])
195
- else
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"
@@ -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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Faktory
3
- VERSION = "1.0.3"
3
+ VERSION = "1.1.0"
4
4
  end
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.3
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-02-08 00:00:00.000000000 Z
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.2.8
156
+ rubygems_version: 3.1.4
152
157
  signing_key:
153
158
  specification_version: 4
154
159
  summary: Ruby worker for Faktory