faktory_worker_ruby 0.5.0 → 0.6.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
  SHA1:
3
- metadata.gz: 601942270c2185c3d6950e04d9cffcfa03256689
4
- data.tar.gz: 51254887f57c7338d086ff07a7e76e9b511fcc53
3
+ metadata.gz: 746a9be3c60d6dda246d9bfadc0cbb5364635928
4
+ data.tar.gz: 8b7647102cf7e973c3927b95c1a2e6f8d000aeb6
5
5
  SHA512:
6
- metadata.gz: 8f22aa99ebfa7d4e79d4b3157561cc14716355716e257c05252539b2ef23ce811f7531d2802722629905427a83e6670c934d8eab977bde9e8bc93737db65ca46
7
- data.tar.gz: b0e723333032496197fd07a5a90441836885d2fb408860e0292a354abbb89d043aca27cfba4ad4d592d1225def1a5e24e7ff747405834cd5448ad417cd04bd1b
6
+ metadata.gz: 76013e6dc045ceb3cdb178815869271e9b6c89250dac467058c087834abb6c666a28f15989023c054e6b692d90dd0f1ce07a0b856da9e992145e9fab9f0830dd
7
+ data.tar.gz: a478076c6058f919b18828ee08c6855ad89e3ca80dcd3d91fd5fe75259c411a5494dcd48d6857aaf52171ccc023f607348320f27a0b91ed50e6554c78cb626e5
@@ -0,0 +1,9 @@
1
+ # Changes
2
+
3
+ ## 0.6.0
4
+
5
+ - Updates for Faktory 0.6.0 and protocol V2.
6
+
7
+ ## 0.5.0
8
+
9
+ - Initial release
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- faktory_worker_ruby (0.5.0)
4
+ faktory_worker_ruby (0.6.0)
5
5
  connection_pool (~> 2.2, >= 2.2.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -38,6 +38,10 @@ Next, install this gem:
38
38
 
39
39
  gem install faktory_worker_ruby
40
40
 
41
+ ## Documentation
42
+
43
+ See the [wiki](//github.com/contribsys/faktory_worker_ruby/wiki) for more details.
44
+
41
45
  ## Your First Job
42
46
 
43
47
  Your Jobs should include the Faktory::Job module and have a `perform`
@@ -7,13 +7,12 @@ Gem::Specification.new do |gem|
7
7
  gem.email = ["mike@contribsys.com"]
8
8
  gem.summary = "Ruby worker for Faktory"
9
9
  gem.description = "Ruby worker for Faktory."
10
- gem.homepage = "http://contribsys.com"
10
+ gem.homepage = "http://github.com/contribsys/faktory_worker_ruby"
11
11
  gem.license = "LGPL-3.0"
12
12
 
13
13
  gem.executables = ['faktory-worker']
14
14
  gem.files = `git ls-files | grep -Ev '^(test|myapp|examples)'`.split("\n")
15
15
  gem.test_files = []
16
- gem.require_paths = ["lib"]
17
16
  gem.version = Faktory::VERSION
18
17
  gem.required_ruby_version = ">= 2.2.2"
19
18
 
@@ -41,6 +41,8 @@ module Faktory
41
41
  # global process state irreversibly. PRs which improve the
42
42
  # test coverage of Faktory::CLI are welcomed.
43
43
  def run
44
+ Faktory::Client.worker!
45
+
44
46
  boot_system
45
47
  print_banner
46
48
 
@@ -71,7 +73,7 @@ module Faktory
71
73
  fire_event(:startup)
72
74
 
73
75
  logger.debug { "Client Middleware: #{Faktory.client_middleware.map(&:klass).join(', ')}" }
74
- logger.debug { "Execute Middleware: #{Faktory.worker_middleware.map(&:klass).join(', ')}" }
76
+ logger.debug { "Worker Middleware: #{Faktory.worker_middleware.map(&:klass).join(', ')}" }
75
77
 
76
78
  logger.info 'Starting processing, hit Ctrl-C to stop' if $stdout.tty?
77
79
 
@@ -8,7 +8,13 @@ module Faktory
8
8
  class ParseError < StandardError;end
9
9
 
10
10
  class Client
11
- @@random_process_wid = SecureRandom.hex(8)
11
+ @@random_process_wid = ""
12
+
13
+ # Called when booting the worker process to signal that this process
14
+ # will consume jobs and send BEAT.
15
+ def self.worker!
16
+ @@random_process_wid = SecureRandom.hex(8)
17
+ end
12
18
 
13
19
  attr_accessor :middleware
14
20
 
@@ -88,7 +94,7 @@ module Faktory
88
94
  str
89
95
  else
90
96
  hash = JSON.parse(str)
91
- hash["signal"]
97
+ hash["state"]
92
98
  end
93
99
  end
94
100
  end
@@ -108,7 +114,8 @@ module Faktory
108
114
  end
109
115
 
110
116
  def tls?
111
- @location.hostname !~ /\Alocalhost\z/ || @location.scheme =~ /tls/
117
+ # Support TLS with this convention: "tcp+tls://:password@myhostname:port/"
118
+ @location.scheme =~ /tls/
112
119
  end
113
120
 
114
121
  def open
@@ -132,20 +139,35 @@ module Faktory
132
139
  "hostname": Socket.gethostname,
133
140
  "pid": $$,
134
141
  "labels": ["ruby-#{RUBY_VERSION}"],
142
+ "v": 2,
135
143
  }
136
144
 
137
145
  hi = result
138
146
 
139
147
  if hi =~ /\AHI (.*)/
140
148
  hash = JSON.parse($1)
141
- # TODO verify version tag
149
+ ver = hash["v"].to_i
150
+ if ver > 2
151
+ puts "Warning: Faktory server protocol #{ver} in use, this worker doesn't speak that version."
152
+ puts "We recommend you upgrade this gem with `bundle up faktory_worker_ruby`."
153
+ end
154
+
142
155
  salt = hash["s"]
143
156
  if salt
144
157
  pwd = @location.password
145
158
  if !pwd
146
159
  raise ArgumentError, "Server requires password, but none has been configured"
147
160
  end
148
- payload["pwdhash"] = Digest::SHA256.hexdigest(pwd + salt)
161
+ iter = hash["i"] || 1
162
+ raise ArgumentError, "Invalid hashing" if iter < 1
163
+
164
+ sha = Digest::SHA256.new
165
+ hashing = pwd + salt
166
+ iter.times do
167
+ sha.update(hashing)
168
+ hashing = sha.digest
169
+ end
170
+ payload["pwdhash"] = sha.hexdigest
149
171
  end
150
172
  end
151
173
 
@@ -185,9 +207,9 @@ module Faktory
185
207
  line[1..-1].strip
186
208
  elsif chr == '$'
187
209
  count = line[1..-1].strip.to_i
188
- data = nil
210
+ return nil if count == -1
189
211
  data = @sock.read(count) if count > 0
190
- line = @sock.gets
212
+ line = @sock.gets # read extra linefeeds
191
213
  data
192
214
  elsif chr == '-'
193
215
  raise CommandError, line[1..-1]
@@ -9,7 +9,7 @@ module Faktory
9
9
  #
10
10
  # None of this matters on the client-side, only within the Faktory executor itself.
11
11
  #
12
- Faktory.configure_exec do |_|
12
+ Faktory.configure_worker do |_|
13
13
  Faktory.options[:reloader] = Faktory::Rails::Reloader.new
14
14
  end
15
15
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Faktory
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0"
4
4
  end
@@ -0,0 +1 @@
1
+ require 'faktory'
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.5.0
4
+ version: 0.6.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: 2017-10-24 00:00:00.000000000 Z
11
+ date: 2017-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -81,6 +81,7 @@ extensions: []
81
81
  extra_rdoc_files: []
82
82
  files:
83
83
  - ".gitignore"
84
+ - Changes.md
84
85
  - Gemfile
85
86
  - Gemfile.lock
86
87
  - LICENSE
@@ -105,7 +106,8 @@ files:
105
106
  - lib/faktory/rails.rb
106
107
  - lib/faktory/util.rb
107
108
  - lib/faktory/version.rb
108
- homepage: http://contribsys.com
109
+ - lib/faktory_worker_ruby.rb
110
+ homepage: http://github.com/contribsys/faktory_worker_ruby
109
111
  licenses:
110
112
  - LGPL-3.0
111
113
  metadata: {}