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 +4 -4
- data/Changes.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/faktory_worker_ruby.gemspec +1 -2
- data/lib/faktory/cli.rb +3 -1
- data/lib/faktory/client.rb +29 -7
- data/lib/faktory/rails.rb +1 -1
- data/lib/faktory/version.rb +1 -1
- data/lib/faktory_worker_ruby.rb +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 746a9be3c60d6dda246d9bfadc0cbb5364635928
|
4
|
+
data.tar.gz: 8b7647102cf7e973c3927b95c1a2e6f8d000aeb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76013e6dc045ceb3cdb178815869271e9b6c89250dac467058c087834abb6c666a28f15989023c054e6b692d90dd0f1ce07a0b856da9e992145e9fab9f0830dd
|
7
|
+
data.tar.gz: a478076c6058f919b18828ee08c6855ad89e3ca80dcd3d91fd5fe75259c411a5494dcd48d6857aaf52171ccc023f607348320f27a0b91ed50e6554c78cb626e5
|
data/Changes.md
ADDED
data/Gemfile.lock
CHANGED
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`
|
data/faktory_worker_ruby.gemspec
CHANGED
@@ -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://
|
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
|
|
data/lib/faktory/cli.rb
CHANGED
@@ -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 { "
|
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
|
|
data/lib/faktory/client.rb
CHANGED
@@ -8,7 +8,13 @@ module Faktory
|
|
8
8
|
class ParseError < StandardError;end
|
9
9
|
|
10
10
|
class Client
|
11
|
-
@@random_process_wid =
|
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["
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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]
|
data/lib/faktory/rails.rb
CHANGED
data/lib/faktory/version.rb
CHANGED
@@ -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.
|
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-
|
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
|
-
|
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: {}
|