beaneater 1.3.0 → 1.3.2
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/CHANGELOG.md +10 -0
- data/README.md +3 -1
- data/lib/beaneater/connection.rb +5 -4
- data/lib/beaneater/job/collection.rb +2 -0
- data/lib/beaneater/stats/stat_struct.rb +11 -2
- data/lib/beaneater/version.rb +1 -1
- metadata +3 -34
- data/.github/workflows/ruby.yml +0 -46
- data/.gitignore +0 -17
- data/Gemfile +0 -16
- data/Rakefile +0 -90
- data/TODO +0 -1
- data/beaneater.gemspec +0 -33
- data/examples/demo.rb +0 -97
- data/test/arguments_test.rb +0 -174
- data/test/beaneater_test.rb +0 -112
- data/test/connection_test.rb +0 -749
- data/test/errors_test.rb +0 -35
- data/test/job_test.rb +0 -286
- data/test/jobs_test.rb +0 -549
- data/test/prompt_regexp_test.rb +0 -59
- data/test/stat_struct_test.rb +0 -83
- data/test/stats_test.rb +0 -61
- data/test/test_helper.rb +0 -93
- data/test/tube_test.rb +0 -323
- data/test/tubes_test.rb +0 -194
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 76d71fc331b80c0f6007044a9af1b33f244ab428616da12a6b6d69c27c66572f
|
|
4
|
+
data.tar.gz: 870253ea09cf6be9ca2b7141ec9562b08a8f8ab886df9a15cf1ae8fe3f7fefa9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4524413bb0c5ef55f87416583655e13c6fb9afd9e2c1f46afe583f2bd4231487c64977f876a195e50d3381a5f5e66ffecf838e8261e587a3e7d69d135b72b5bd
|
|
7
|
+
data.tar.gz: 64f21bee265bd854fab4b3b9fe021bf4de28b69c2a4252fa68c5f8d0a37ec79ba9a586dc5a27c91bf02b4d26b3d19b9938a76d353419b703d964eae6a34cf782
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# CHANGELOG for Beaneater
|
|
2
2
|
|
|
3
|
+
## 1.3.2 (December 2 2026)
|
|
4
|
+
|
|
5
|
+
* A whitespace-only `ENV['BEANSTALKD_URL']` now counts as unset: `Beaneater.new` (and `Beaneater::Connection.new(nil)`) uses `Beaneater.configuration.beanstalkd_url` instead of connecting to `localhost:11300`. With no `beanstalkd_url` configured, it now raises `NotConnected`, as an unset `BEANSTALKD_URL` does; to keep connecting to `localhost:11300`, set `BEANSTALKD_URL` or `beanstalkd_url` to `localhost:11300` (@nesquena)
|
|
6
|
+
* Packaging: the gem now ships only `lib/`, `.yardopts`, `CHANGELOG.md`, `LICENSE.txt` and `README.md` instead of every file in `git ls-files`, so tests, CI workflows, examples and repository metadata are no longer in the gem (@nesquena)
|
|
7
|
+
|
|
8
|
+
## 1.3.1 (November 4 2026)
|
|
9
|
+
|
|
10
|
+
* `jobs.process!` no longer checks with the server on a job it has just deleted, or released for another try, before moving on (the check sent `stats-job` and could never bury the job): a job whose handler finishes now takes 3 commands (`reserve`, `stats-job`, `delete`) instead of 4, and a retried job takes 2 fewer. A job whose handler raised and that isn't released is still buried as before (@nesquena)
|
|
11
|
+
* `client.stats`, `tube.stats` and `job.stats` parse the server's reply with less work, so polling stats takes noticeably less CPU; the results are unchanged (@nesquena)
|
|
12
|
+
|
|
3
13
|
## 1.3.0 (November 1 2026)
|
|
4
14
|
|
|
5
15
|
* Check tube names, job ids and numbers before writing them into a command. A tube name beanstalkd does not accept (up to 200 letters, digits and `-+/;.$_()`, not starting with a hyphen) raises `InvalidTubeName` from every tube command (`use`, `watch`, `ignore`, `put`, `peek`, `kick`, `stats`, `pause`, and restoring the watched tubes on reconnect); names such as `demo.test.foo`, `jobs(eu).mailers` and `MyApp.mailers` stay valid. `watch`'s `InvalidTubeName` message now reads "Tube cannot be named '<name>'", as `use`'s does, and `tubes.watch(:t)` and `tubes.ignore(:t)` return the names as Strings. A job id that is not a whole number (an Integer or a String of digits), a priority, delay, TTR or pause delay that is not a whole number from 0 to 4294967295 (the range beanstalkd reads), a reserve timeout or kick count that is neither a whole number nor a Float, and a peek state other than `ready`, `delayed` or `buried` raise `ArgumentError`. Such values used to be sent as given and fail on the server with `BadFormatError` or `UnknownCommandError`, or be misread. What to do: `tube.stats`, `tube.pause` and `tubes.ignore` with such a tube name now raise `InvalidTubeName` instead of `BadFormatError`, and the values above raise `ArgumentError` (`jobs.find("abc")`, `tube.put(body, :ttr => 1.5)`, `tube.peek(:reserved)`) instead of `BadFormatError` or `UnknownCommandError`, both `Beaneater::UnexpectedResponse`s; code that rescues `Beaneater::UnexpectedResponse` around these calls should also rescue `Beaneater::InvalidTubeName` and `ArgumentError` (@nesquena)
|
data/README.md
CHANGED
|
@@ -132,7 +132,7 @@ Beaneater.configure do |config|
|
|
|
132
132
|
# config.default_put_ttr = 120
|
|
133
133
|
# config.job_parser = lambda { |body| body }
|
|
134
134
|
# config.job_serializer = lambda { |body| body }
|
|
135
|
-
# config.beanstalkd_url =
|
|
135
|
+
# config.beanstalkd_url = nil
|
|
136
136
|
# config.connect_timeout = nil
|
|
137
137
|
# config.resolv_timeout = nil
|
|
138
138
|
# config.read_timeout = nil
|
|
@@ -142,6 +142,8 @@ end
|
|
|
142
142
|
|
|
143
143
|
The above options are all defaults, so only include a configuration block if you need to make changes.
|
|
144
144
|
|
|
145
|
+
`Beaneater.new` connects to the address it is given, else to `ENV['BEANSTALKD_URL']`, else to `beanstalkd_url`. With none of them set (a blank `BEANSTALKD_URL` counts as unset), it raises `Beaneater::NotConnected`.
|
|
146
|
+
|
|
145
147
|
`connect_timeout` and `resolv_timeout` are passed through to `TCPSocket.new` on Ruby 3.0 and newer (ignored on Ruby < 3.0 for compatibility). `read_timeout` bounds how long beaneater waits for beanstalkd's reply to a command; for `reserve(timeout)` it is added to the reserve's own timeout, and a plain `reserve` (no timeout) still waits as long as it takes for a job. `write_timeout` bounds how long sending a command may take. When either runs out, `Beaneater::SocketTimeout` (a `Beaneater::NotConnected`) is raised and the connection is dropped; the next command reconnects. Timeouts are in seconds; `read_timeout` and `write_timeout` may also be numeric strings (from `ENV`, say).
|
|
146
148
|
|
|
147
149
|
A `SocketTimeout` on `put` does not tell you whether beanstalkd stored the job: the command may have reached the server and only the reply been lost. Retrying the `put` can therefore enqueue the job twice, so retry a timed-out `put` only if running the job twice is harmless.
|
data/lib/beaneater/connection.rb
CHANGED
|
@@ -397,13 +397,14 @@ class Beaneater
|
|
|
397
397
|
|
|
398
398
|
# The host provided by BEANSTALKD_URL environment variable, if available.
|
|
399
399
|
#
|
|
400
|
-
# @return [String] A beanstalkd host address
|
|
400
|
+
# @return [String, nil] A beanstalkd host address, or nil when unset or blank
|
|
401
401
|
# @example
|
|
402
402
|
# ENV['BEANSTALKD_URL'] = "localhost:1212"
|
|
403
403
|
# # => 'localhost:1212'
|
|
404
404
|
#
|
|
405
405
|
def _host_from_env
|
|
406
|
-
|
|
406
|
+
url = ENV['BEANSTALKD_URL'].to_s.strip
|
|
407
|
+
url unless url.empty?
|
|
407
408
|
end
|
|
408
409
|
|
|
409
410
|
# Converts one value of a stats or list response to its Ruby type:
|
|
@@ -414,9 +415,9 @@ class Beaneater
|
|
|
414
415
|
value[1..-2]
|
|
415
416
|
elsif text
|
|
416
417
|
value
|
|
417
|
-
elsif value
|
|
418
|
+
elsif value.match?(/\A-?\d+\z/)
|
|
418
419
|
value.to_i
|
|
419
|
-
elsif value
|
|
420
|
+
elsif value.match?(/\A-?\d+\.\d+\z/)
|
|
420
421
|
value.to_f
|
|
421
422
|
elsif value == 'true' || value == 'false'
|
|
422
423
|
value == 'true'
|
|
@@ -131,9 +131,11 @@ class Beaneater
|
|
|
131
131
|
begin
|
|
132
132
|
processor[:block].call(@current_job)
|
|
133
133
|
@current_job.delete
|
|
134
|
+
@current_job = nil # deleted, so there is nothing for the ensure below to bury
|
|
134
135
|
rescue *processor[:retry_on]
|
|
135
136
|
if @current_job.stats.releases < processor[:max_retries]
|
|
136
137
|
@current_job.release(:delay => release_delay)
|
|
138
|
+
@current_job = nil # released for another try, so no longer ours to bury
|
|
137
139
|
end
|
|
138
140
|
end
|
|
139
141
|
rescue AbortProcessingError
|
|
@@ -13,10 +13,19 @@ class Beaneater
|
|
|
13
13
|
#
|
|
14
14
|
def self.from_hash(hash)
|
|
15
15
|
return unless hash.is_a?(Hash)
|
|
16
|
-
underscore_hash = hash.inject({}) { |r, (k, v)| r[k
|
|
16
|
+
underscore_hash = hash.inject({}) { |r, (k, v)| r[underscore(k)] = v; r }
|
|
17
17
|
self.new(underscore_hash)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
# The key as a String with its hyphens turned into underscores, with String#tr for speed. A key
|
|
21
|
+
# in an encoding that isn't ASCII-compatible (UTF-16, say) takes gsub, so that the
|
|
22
|
+
# Encoding::CompatibilityError it raises keeps gsub's message.
|
|
23
|
+
def self.underscore(key)
|
|
24
|
+
key = key.to_s
|
|
25
|
+
key.encoding.ascii_compatible? ? key.tr('-', '_') : key.gsub(/-/, '_')
|
|
26
|
+
end
|
|
27
|
+
private_class_method :underscore
|
|
28
|
+
|
|
20
29
|
# Access value for stat with specified key.
|
|
21
30
|
#
|
|
22
31
|
# Keys are stored underscored (see {.from_hash}), so hyphenated beanstalkd
|
|
@@ -30,7 +39,7 @@ class Beaneater
|
|
|
30
39
|
# @stats['current-jobs-ready'] # => 5
|
|
31
40
|
#
|
|
32
41
|
def [](key)
|
|
33
|
-
name =
|
|
42
|
+
name = self.class.send(:underscore, key)
|
|
34
43
|
@hash.fetch(name) { @hash[name.to_sym] }
|
|
35
44
|
end
|
|
36
45
|
|
data/lib/beaneater/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: beaneater
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nico Taing
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-12-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|
|
@@ -87,17 +87,10 @@ executables: []
|
|
|
87
87
|
extensions: []
|
|
88
88
|
extra_rdoc_files: []
|
|
89
89
|
files:
|
|
90
|
-
- ".github/workflows/ruby.yml"
|
|
91
|
-
- ".gitignore"
|
|
92
90
|
- ".yardopts"
|
|
93
91
|
- CHANGELOG.md
|
|
94
|
-
- Gemfile
|
|
95
92
|
- LICENSE.txt
|
|
96
93
|
- README.md
|
|
97
|
-
- Rakefile
|
|
98
|
-
- TODO
|
|
99
|
-
- beaneater.gemspec
|
|
100
|
-
- examples/demo.rb
|
|
101
94
|
- lib/beaneater.rb
|
|
102
95
|
- lib/beaneater/arguments.rb
|
|
103
96
|
- lib/beaneater/configuration.rb
|
|
@@ -113,18 +106,6 @@ files:
|
|
|
113
106
|
- lib/beaneater/tube/collection.rb
|
|
114
107
|
- lib/beaneater/tube/record.rb
|
|
115
108
|
- lib/beaneater/version.rb
|
|
116
|
-
- test/arguments_test.rb
|
|
117
|
-
- test/beaneater_test.rb
|
|
118
|
-
- test/connection_test.rb
|
|
119
|
-
- test/errors_test.rb
|
|
120
|
-
- test/job_test.rb
|
|
121
|
-
- test/jobs_test.rb
|
|
122
|
-
- test/prompt_regexp_test.rb
|
|
123
|
-
- test/stat_struct_test.rb
|
|
124
|
-
- test/stats_test.rb
|
|
125
|
-
- test/test_helper.rb
|
|
126
|
-
- test/tube_test.rb
|
|
127
|
-
- test/tubes_test.rb
|
|
128
109
|
homepage: https://github.com/beanstalkd/beaneater
|
|
129
110
|
licenses:
|
|
130
111
|
- MIT
|
|
@@ -152,16 +133,4 @@ rubygems_version: 3.5.23
|
|
|
152
133
|
signing_key:
|
|
153
134
|
specification_version: 4
|
|
154
135
|
summary: Simple beanstalkd client for ruby.
|
|
155
|
-
test_files:
|
|
156
|
-
- test/arguments_test.rb
|
|
157
|
-
- test/beaneater_test.rb
|
|
158
|
-
- test/connection_test.rb
|
|
159
|
-
- test/errors_test.rb
|
|
160
|
-
- test/job_test.rb
|
|
161
|
-
- test/jobs_test.rb
|
|
162
|
-
- test/prompt_regexp_test.rb
|
|
163
|
-
- test/stat_struct_test.rb
|
|
164
|
-
- test/stats_test.rb
|
|
165
|
-
- test/test_helper.rb
|
|
166
|
-
- test/tube_test.rb
|
|
167
|
-
- test/tubes_test.rb
|
|
136
|
+
test_files: []
|
data/.github/workflows/ruby.yml
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# This workflow uses actions that are not certified by GitHub.
|
|
2
|
-
# They are provided by a third-party and are governed by
|
|
3
|
-
# separate terms of service, privacy policy, and support
|
|
4
|
-
# documentation.
|
|
5
|
-
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
|
6
|
-
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
|
7
|
-
|
|
8
|
-
name: Build Status
|
|
9
|
-
|
|
10
|
-
on:
|
|
11
|
-
push:
|
|
12
|
-
branches: [ "master" ]
|
|
13
|
-
pull_request:
|
|
14
|
-
branches: [ "master" ]
|
|
15
|
-
|
|
16
|
-
permissions:
|
|
17
|
-
contents: read
|
|
18
|
-
|
|
19
|
-
jobs:
|
|
20
|
-
test:
|
|
21
|
-
|
|
22
|
-
runs-on: ubuntu-latest
|
|
23
|
-
strategy:
|
|
24
|
-
matrix:
|
|
25
|
-
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0']
|
|
26
|
-
|
|
27
|
-
steps:
|
|
28
|
-
- uses: actions/checkout@v4
|
|
29
|
-
- name: Download & Extract beanstalkd
|
|
30
|
-
run: curl -L https://github.com/beanstalkd/beanstalkd/archive/refs/tags/v1.13.tar.gz | tar xz
|
|
31
|
-
- name: Make beanstalkd
|
|
32
|
-
# beanstalkd 1.13 builds with -Werror and predates C23, which newer compilers default to: build it
|
|
33
|
-
# as C17, and keep the const pointer newer C libraries' memchr() returns to prot.c a warning
|
|
34
|
-
run: make CFLAGS='-std=gnu17 -Wno-error=discarded-qualifiers'
|
|
35
|
-
working-directory: beanstalkd-1.13
|
|
36
|
-
- name: Set up Ruby
|
|
37
|
-
uses: ruby/setup-ruby@v1
|
|
38
|
-
with:
|
|
39
|
-
ruby-version: ${{ matrix.ruby-version }}
|
|
40
|
-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
41
|
-
- name: Daemonize beanstalkd
|
|
42
|
-
run: ./beanstalkd-1.13/beanstalkd &
|
|
43
|
-
- name: Run tests
|
|
44
|
-
run: bundle exec rake test:full
|
|
45
|
-
env:
|
|
46
|
-
BEANSTALKD_BIN: ${{ github.workspace }}/beanstalkd-1.13/beanstalkd
|
data/.gitignore
DELETED
data/Gemfile
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
source 'https://rubygems.org'
|
|
4
|
-
|
|
5
|
-
# Specify your gem's dependencies in beaneater.gemspec
|
|
6
|
-
gemspec
|
|
7
|
-
|
|
8
|
-
group :development do
|
|
9
|
-
gem 'redcarpet', '~> 3.6'
|
|
10
|
-
gem 'github-markup'
|
|
11
|
-
gem 'yard'
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
group :development, :test do
|
|
15
|
-
gem 'coveralls', :require => false
|
|
16
|
-
end
|
data/Rakefile
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "bundler/gem_tasks"
|
|
4
|
-
require 'rake/testtask'
|
|
5
|
-
require 'yard'
|
|
6
|
-
require 'redcarpet'
|
|
7
|
-
require 'json'
|
|
8
|
-
require 'net/http'
|
|
9
|
-
require_relative 'lib/beaneater/version'
|
|
10
|
-
|
|
11
|
-
# rake test
|
|
12
|
-
Rake::TestTask.new do |t|
|
|
13
|
-
t.libs.push "lib"
|
|
14
|
-
t.test_files = FileList[File.expand_path('../test/**/*_test.rb', __FILE__)] -
|
|
15
|
-
FileList[File.expand_path('../test/**/beaneater_test.rb', __FILE__)]
|
|
16
|
-
t.verbose = true
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# rake test:integration
|
|
20
|
-
Rake::TestTask.new("test:integration") do |t|
|
|
21
|
-
t.libs.push "lib"
|
|
22
|
-
t.test_files = FileList[File.expand_path('../test/**/beaneater_test.rb', __FILE__)]
|
|
23
|
-
t.verbose = true
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# rake test:full
|
|
27
|
-
Rake::TestTask.new("test:full") do |t|
|
|
28
|
-
t.libs.push "lib"
|
|
29
|
-
t.test_files = FileList[File.expand_path('../test/**/*_test.rb', __FILE__)]
|
|
30
|
-
t.verbose = true
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
YARD::Rake::YardocTask.new do |t|
|
|
34
|
-
t.files = ['lib/beaneater/**/*.rb']
|
|
35
|
-
t.options = []
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# rake release:check (rake release runs it first, before it builds, tags or pushes):
|
|
39
|
-
# HEAD must be on master (or X.Y-stable), committed and at the remote branch it will be
|
|
40
|
-
# pushed to (`origin` unless `rake release[remote]` or the branch's upstream says
|
|
41
|
-
# otherwise), version.rb must match the top CHANGELOG.md heading, stamped with a date,
|
|
42
|
-
# and neither the tag nor the gem version may exist yet.
|
|
43
|
-
desc "Check that HEAD can be released as beaneater #{Beaneater::VERSION}"
|
|
44
|
-
task "release:check", [:remote] do |_, args|
|
|
45
|
-
version = Beaneater::VERSION
|
|
46
|
-
tag = "v#{version}"
|
|
47
|
-
git = ->(*a) { out = IO.popen(["git", *a], err: File::NULL, &:read); out.strip if $?.success? }
|
|
48
|
-
errors = []
|
|
49
|
-
|
|
50
|
-
branch = git.("rev-parse", "--abbrev-ref", "HEAD").to_s
|
|
51
|
-
remote = args[:remote] || git.("config", "--get", "branch.#{branch}.remote") || "origin"
|
|
52
|
-
errors << "git fetch #{remote} failed" unless system("git", "fetch", "--quiet", remote)
|
|
53
|
-
stable = "#{version[/\A\d+\.\d+/]}-stable"
|
|
54
|
-
errors << "on #{branch}, not master or #{stable}" unless ["master", stable].include?(branch)
|
|
55
|
-
errors << "there are uncommitted changes" unless git.("status", "--porcelain") == ""
|
|
56
|
-
head = git.("rev-parse", "HEAD")
|
|
57
|
-
unless head && head == git.("rev-parse", "--verify", "--quiet", "refs/remotes/#{remote}/#{branch}")
|
|
58
|
-
errors << "#{branch} is not at #{remote}/#{branch} (push or pull first; release a merged commit)"
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
heading = File.foreach(File.expand_path('CHANGELOG.md', __dir__), encoding: "bom|utf-8").find { |l| l.start_with?("## ") }.to_s.strip
|
|
62
|
-
top, rest = heading.match(/\A## (\d+\.\d+\.\d+)( .*|)\z/)&.captures
|
|
63
|
-
if top != version
|
|
64
|
-
errors << "CHANGELOG.md starts with '#{heading}', not #{version}"
|
|
65
|
-
elsif rest !~ /\b(19|20)\d\d\b/ || rest =~ /\b(unreleased|tbd|tba)\b/i
|
|
66
|
-
errors << "CHANGELOG.md's '#{heading}' isn't stamped with a date"
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
local_tag = git.("tag", "--list", tag)
|
|
70
|
-
remote_tag = git.("ls-remote", "--tags", remote, "refs/tags/#{tag}")
|
|
71
|
-
if local_tag.nil? || remote_tag.nil?
|
|
72
|
-
errors << "couldn't check for tag #{tag}"
|
|
73
|
-
elsif !(local_tag.empty? && remote_tag.empty?)
|
|
74
|
-
errors << "tag #{tag} already exists (if only the gem push failed: gem push pkg/beaneater-#{version}.gem)"
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
begin
|
|
78
|
-
published = JSON.parse(Net::HTTP.get(URI("https://rubygems.org/api/v1/versions/beaneater.json")))
|
|
79
|
-
errors << "beaneater #{version} is already on rubygems.org" if published.any? { |v| v["number"] == version }
|
|
80
|
-
rescue StandardError => e
|
|
81
|
-
errors << "couldn't check rubygems.org (#{e.message})"
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
abort "Not ready to release #{version}:\n#{errors.map { |e| " - #{e}" }.join("\n")}" unless errors.empty?
|
|
85
|
-
puts "Ready to release beaneater #{version} (#{git.("rev-parse", "--short", "HEAD")} on #{branch}, #{remote})"
|
|
86
|
-
end
|
|
87
|
-
Rake::Task["release"].prerequisites.unshift("release:check")
|
|
88
|
-
%w[release:source_control_push release:rubygem_push].each { |t| Rake::Task[t].enhance(["release:check"]) }
|
|
89
|
-
|
|
90
|
-
task :default => 'test:full'
|
data/TODO
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
- Remove connection from pool if it's not responding and be able to add more connections and reattempt later
|
data/beaneater.gemspec
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# -*- encoding: utf-8 -*-
|
|
3
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
-
require 'beaneater/version'
|
|
6
|
-
|
|
7
|
-
Gem::Specification.new do |gem|
|
|
8
|
-
gem.name = "beaneater"
|
|
9
|
-
gem.version = Beaneater::VERSION
|
|
10
|
-
gem.authors = ["Nico Taing"]
|
|
11
|
-
gem.email = ["nico.taing@gmail.com"]
|
|
12
|
-
gem.description = %q{Simple beanstalkd client for ruby}
|
|
13
|
-
gem.summary = %q{Simple beanstalkd client for ruby.}
|
|
14
|
-
gem.homepage = "https://github.com/beanstalkd/beaneater"
|
|
15
|
-
gem.license = 'MIT'
|
|
16
|
-
gem.metadata = {
|
|
17
|
-
"changelog_uri" => "https://github.com/beanstalkd/beaneater/blob/master/CHANGELOG.md",
|
|
18
|
-
"source_code_uri" => "https://github.com/beanstalkd/beaneater",
|
|
19
|
-
"bug_tracker_uri" => "https://github.com/beanstalkd/beaneater/issues",
|
|
20
|
-
"rubygems_mfa_required" => "true"
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
gem.files = `git ls-files`.split($/)
|
|
24
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
25
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
26
|
-
gem.require_paths = ["lib"]
|
|
27
|
-
gem.required_ruby_version = '>= 2.7'
|
|
28
|
-
gem.add_development_dependency 'minitest', "~> 4.1.0"
|
|
29
|
-
gem.add_development_dependency 'rake'
|
|
30
|
-
gem.add_development_dependency 'mocha'
|
|
31
|
-
gem.add_development_dependency 'term-ansicolor'
|
|
32
|
-
gem.add_development_dependency 'json'
|
|
33
|
-
end
|
data/examples/demo.rb
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'term/ansicolor'
|
|
4
|
-
class String; include Term::ANSIColor; end
|
|
5
|
-
def step(msg); "\n[STEP] #{msg}...".yellow; end
|
|
6
|
-
$:.unshift("../lib")
|
|
7
|
-
require 'beaneater'
|
|
8
|
-
|
|
9
|
-
# Establish a pool of beanstalks
|
|
10
|
-
puts step("Connecting to Beanstalk")
|
|
11
|
-
bc = Beaneater.new('localhost')
|
|
12
|
-
puts bc
|
|
13
|
-
|
|
14
|
-
# Print out key stats
|
|
15
|
-
puts step("Print Stats")
|
|
16
|
-
p bc.stats.keys
|
|
17
|
-
p [bc.stats.total_connections, bc.stats[:total_connections], bc.stats['total_connections']]
|
|
18
|
-
|
|
19
|
-
# find tube
|
|
20
|
-
puts step("Find tube")
|
|
21
|
-
tube = bc.tubes.find('tube2')
|
|
22
|
-
puts tube
|
|
23
|
-
|
|
24
|
-
# Put job onto tube
|
|
25
|
-
puts step("Put job")
|
|
26
|
-
response = tube.put "foo bar", :pri => 1000, :ttr => 10, :delay => 0
|
|
27
|
-
puts response
|
|
28
|
-
|
|
29
|
-
# peek tube
|
|
30
|
-
puts step("Peek tube")
|
|
31
|
-
p tube.peek :ready
|
|
32
|
-
|
|
33
|
-
# watch tube
|
|
34
|
-
bc.tubes.watch!('tube2')
|
|
35
|
-
|
|
36
|
-
# Check tube stats
|
|
37
|
-
puts step("Get tube stats")
|
|
38
|
-
p tube.stats.keys
|
|
39
|
-
p tube.stats.name
|
|
40
|
-
p tube.stats.current_jobs_ready
|
|
41
|
-
|
|
42
|
-
# Reserve job from tube
|
|
43
|
-
puts step("Reserve job")
|
|
44
|
-
p job = bc.tubes.reserve
|
|
45
|
-
jid = job.id
|
|
46
|
-
|
|
47
|
-
# pause tube
|
|
48
|
-
puts step("Pause tube")
|
|
49
|
-
p tube.pause(1)
|
|
50
|
-
|
|
51
|
-
# Register jobs
|
|
52
|
-
puts step("Register jobs for tubes")
|
|
53
|
-
bc.jobs.register('tube_test', :retry_on => [Timeout::Error]) do |job|
|
|
54
|
-
p 'tube_test'
|
|
55
|
-
p job
|
|
56
|
-
raise Beaneater::AbortProcessingError
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
bc.jobs.register('tube_test2', :retry_on => [Timeout::Error]) do |job|
|
|
60
|
-
p 'tube_test2'
|
|
61
|
-
p job
|
|
62
|
-
raise Beaneater::AbortProcessingError
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
p bc.jobs.processors
|
|
66
|
-
|
|
67
|
-
response = bc.tubes.find('tube_test').put "foo register", :pri => 1000, :ttr => 10, :delay => 0
|
|
68
|
-
response = bc.tubes.find('tube_test2').put "foo baz", :pri => 1000, :ttr => 10, :delay => 0
|
|
69
|
-
|
|
70
|
-
# Process jobs
|
|
71
|
-
puts step("Process jobs")
|
|
72
|
-
2.times { bc.jobs.process! }
|
|
73
|
-
|
|
74
|
-
# Get job from id (peek job)
|
|
75
|
-
puts step("Get job from id")
|
|
76
|
-
p bc.jobs.find(jid)
|
|
77
|
-
p bc.jobs.peek(jid)
|
|
78
|
-
|
|
79
|
-
# Check job stats
|
|
80
|
-
puts step("Get job stats")
|
|
81
|
-
p job.stats.keys
|
|
82
|
-
p job.stats.tube
|
|
83
|
-
p job.stats.state
|
|
84
|
-
|
|
85
|
-
# bury job
|
|
86
|
-
puts step("Bury job")
|
|
87
|
-
p job.bury
|
|
88
|
-
|
|
89
|
-
# delete job
|
|
90
|
-
puts step("Delete job")
|
|
91
|
-
p job.delete
|
|
92
|
-
|
|
93
|
-
# list tubes
|
|
94
|
-
puts step("List tubes")
|
|
95
|
-
p bc.tubes.watched
|
|
96
|
-
p bc.tubes.used
|
|
97
|
-
p bc.tubes.all
|