beaneater 1.3.1 → 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 +5 -0
- data/README.md +3 -1
- data/lib/beaneater/connection.rb +3 -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 -140
- 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 -597
- 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,10 @@
|
|
|
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
|
+
|
|
3
8
|
## 1.3.1 (November 4 2026)
|
|
4
9
|
|
|
5
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)
|
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:
|
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,140 +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
|
-
page = args[:remote] ? "rake 'release:github[#{args[:remote]}]'" : "rake release:github"
|
|
75
|
-
errors << "tag #{tag} already exists (if only the gem push failed: gem push pkg/beaneater-#{version}.gem, then #{page})"
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
begin
|
|
79
|
-
published = JSON.parse(Net::HTTP.get(URI("https://rubygems.org/api/v1/versions/beaneater.json")))
|
|
80
|
-
errors << "beaneater #{version} is already on rubygems.org" if published.any? { |v| v["number"] == version }
|
|
81
|
-
rescue StandardError => e
|
|
82
|
-
errors << "couldn't check rubygems.org (#{e.message})"
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
abort "Not ready to release #{version}:\n#{errors.map { |e| " - #{e}" }.join("\n")}" unless errors.empty?
|
|
86
|
-
puts "Ready to release beaneater #{version} (#{git.("rev-parse", "--short", "HEAD")} on #{branch}, #{remote})"
|
|
87
|
-
end
|
|
88
|
-
Rake::Task["release"].prerequisites.unshift("release:check")
|
|
89
|
-
%w[release:source_control_push release:rubygem_push].each { |t| Rake::Task[t].enhance(["release:check"]) }
|
|
90
|
-
|
|
91
|
-
# rake release:github (rake release runs it last, once the tag and the gem are pushed):
|
|
92
|
-
# creates the GitHub release page for the tag through the gh CLI, on the github.com
|
|
93
|
-
# repository the remote pushes to, with a link to the CHANGELOG and GitHub's generated
|
|
94
|
-
# notes since the previous version's tag. It is marked Latest only when no higher version
|
|
95
|
-
# is tagged, so a release from an X.Y-stable branch doesn't take that from a newer one.
|
|
96
|
-
# If the page already exists it does nothing, so it can also be run by hand to finish a release.
|
|
97
|
-
desc "Create the GitHub release page for v#{Beaneater::VERSION}"
|
|
98
|
-
task "release:github", [:remote] do |_, args|
|
|
99
|
-
version = Gem::Version.new(Beaneater::VERSION)
|
|
100
|
-
tag = "v#{version}"
|
|
101
|
-
git = ->(*a) { out = IO.popen(["git", *a], err: File::NULL, &:read); out.strip if $?.success? }
|
|
102
|
-
branch = git.("rev-parse", "--abbrev-ref", "HEAD").to_s
|
|
103
|
-
remote = args[:remote] || git.("config", "--get", "branch.#{branch}.remote") || "origin"
|
|
104
|
-
url = git.("remote", "get-url", "--push", remote).to_s.split("\n").first.to_s
|
|
105
|
-
repo = url[%r{(?:\A|[@/.])github\.com[:/]([^/]+/[^/]+?)(?:\.git)?/?\z}i, 1] or abort "#{remote} isn't a GitHub repository"
|
|
106
|
-
# the push URL's tags, not the fetch URL's: the page goes to the repository the tag was pushed to
|
|
107
|
-
tags = git.("ls-remote", "--tags", url, "refs/tags/v*") or abort "Couldn't list the tags on #{remote}"
|
|
108
|
-
tagged = tags.split("\n").filter_map { |l| l[%r{\trefs/tags/v(\d+\.\d+\.\d+)\z}, 1] }.map { |v| Gem::Version.new(v) }
|
|
109
|
-
previous = tagged.select { |v| v < version }.max
|
|
110
|
-
options = ["--latest=#{tagged.none? { |v| v > version }}"]
|
|
111
|
-
options += ["--notes-start-tag", "v#{previous}"] if previous
|
|
112
|
-
# gh adds the generated notes after a single newline; the second one keeps them out of this paragraph
|
|
113
|
-
notes = "See [CHANGELOG.md](https://github.com/#{repo}/blob/#{tag}/CHANGELOG.md) for what changed, and what to do when upgrading.\n"
|
|
114
|
-
gh_repo = "github.com/#{repo}" # so an exported GH_HOST doesn't send it elsewhere
|
|
115
|
-
|
|
116
|
-
if system("gh", "release", "view", tag, "-R", gh_repo, out: File::NULL, err: File::NULL)
|
|
117
|
-
puts "GitHub release #{tag} already exists on #{repo}"
|
|
118
|
-
elsif system("gh", "release", "create", tag, "-R", gh_repo, "--verify-tag", "--title", tag, *options,
|
|
119
|
-
"--generate-notes", "--notes", notes)
|
|
120
|
-
puts "Created GitHub release #{tag} on #{repo}"
|
|
121
|
-
else
|
|
122
|
-
abort "Couldn't create GitHub release #{tag} on #{repo} (is gh installed and signed in?)"
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
# The gem is out by then, so a failure here only warns and says how to finish.
|
|
126
|
-
Rake::Task["release"].enhance do |_, args|
|
|
127
|
-
if %w[n no nil false off 0].include?(ENV["gem_push"].to_s.downcase)
|
|
128
|
-
puts "gem_push is off, so no GitHub release page"
|
|
129
|
-
next
|
|
130
|
-
end
|
|
131
|
-
begin
|
|
132
|
-
Rake::Task["release:github"].invoke(args[:remote])
|
|
133
|
-
rescue SystemExit, StandardError => e
|
|
134
|
-
warn "#{e.class}: #{e.message} (#{e.backtrace&.first})" unless e.is_a?(SystemExit)
|
|
135
|
-
page = args[:remote] ? "rake 'release:github[#{args[:remote]}]'" : "rake release:github"
|
|
136
|
-
warn "The tag and the gem are pushed; only the GitHub release page is missing. Run: #{page}"
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
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
|
data/test/arguments_test.rb
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# test/arguments_test.rb
|
|
4
|
-
|
|
5
|
-
require File.expand_path('../test_helper', __FILE__)
|
|
6
|
-
|
|
7
|
-
describe "Command arguments" do
|
|
8
|
-
before do
|
|
9
|
-
@beanstalk = Beaneater.new('localhost')
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
# The connection's next command still gets its own reply
|
|
13
|
-
def assert_in_step
|
|
14
|
-
assert_equal 'USING', @beanstalk.connection.transmit('list-tube-used')[:status]
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
describe "tube names" do
|
|
18
|
-
it "should raise InvalidTubeName for a name beanstalkd does not accept" do
|
|
19
|
-
calls = {
|
|
20
|
-
'use' => ->(name) { @beanstalk.tubes.use(name) },
|
|
21
|
-
'watch' => ->(name) { @beanstalk.tubes.watch(name) },
|
|
22
|
-
'ignore' => ->(name) { @beanstalk.tubes.ignore(name) },
|
|
23
|
-
'put' => ->(name) { @beanstalk.tubes.find(name).put('x') },
|
|
24
|
-
'peek' => ->(name) { @beanstalk.tubes.find(name).peek(:ready) },
|
|
25
|
-
'stats' => ->(name) { @beanstalk.tubes.find(name).stats },
|
|
26
|
-
'pause' => ->(name) { @beanstalk.tubes.find(name).pause(0) }
|
|
27
|
-
}
|
|
28
|
-
["a\r\nb", "a\nb", "a\rb", "a b", "-a", "a" * 201, "", "tubeé", "a\xffb", "a\xffb".b].each do |name|
|
|
29
|
-
calls.each do |call, block|
|
|
30
|
-
assert_raises(Beaneater::InvalidTubeName, "#{call} #{name.inspect}") { block.call(name) }
|
|
31
|
-
assert_in_step
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
assert_equal ['default'], @beanstalk.tubes.watched.map(&:name)
|
|
35
|
-
assert_equal 'default', @beanstalk.tubes.used.name
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "should raise InvalidTubeName when a reconnect would restore a name beanstalkd does not accept" do
|
|
39
|
-
@beanstalk.connection.tubes_watched = ['default', "a\r\nb"]
|
|
40
|
-
@beanstalk.connection.connection.shutdown(Socket::SHUT_RDWR) # the next command reconnects
|
|
41
|
-
assert_raises(Beaneater::InvalidTubeName) { @beanstalk.tubes.used }
|
|
42
|
-
@beanstalk.connection.tubes_watched = ['default']
|
|
43
|
-
assert_equal 'default', @beanstalk.tubes.used.name
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "should accept every name beanstalkd does" do
|
|
47
|
-
['demo.test.foo', 'jobs(eu).mailers', 'MyApp.mailers', 'a+b/c;d$e_f-g', 'a' * 200, :symbol_tube].each do |name|
|
|
48
|
-
tube = @beanstalk.tubes.find(name)
|
|
49
|
-
tube.put('job')
|
|
50
|
-
assert_equal name.to_s, tube.stats.name
|
|
51
|
-
tube.pause(0)
|
|
52
|
-
@beanstalk.tubes.watch(name)
|
|
53
|
-
assert_includes @beanstalk.connection.tubes_watched, name.to_s
|
|
54
|
-
assert_equal 'job', tube.peek(:ready).body
|
|
55
|
-
@beanstalk.tubes.ignore(name)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end # tube names
|
|
59
|
-
|
|
60
|
-
describe "job ids" do
|
|
61
|
-
before do
|
|
62
|
-
@tube = @beanstalk.tubes.find('arguments')
|
|
63
|
-
@id = @tube.put('job')[:id]
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it "should find a job by an Integer or a String of digits" do
|
|
67
|
-
assert_equal 'job', @beanstalk.jobs.find(@id.to_i).body
|
|
68
|
-
assert_equal 'job', @beanstalk.jobs.find(@id.to_s).body
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "should raise ArgumentError for an id that is not a whole number" do
|
|
72
|
-
["#{@id}\r\nstats", "#{@id}\nstats", "#{@id} 1", "abc", "", nil, 1.5, :"1"].each do |id|
|
|
73
|
-
assert_raises(ArgumentError, id.inspect) { @beanstalk.jobs.find(id) }
|
|
74
|
-
assert_in_step
|
|
75
|
-
job = Beaneater::Job.new(@beanstalk, :id => id, :status => 'RESERVED')
|
|
76
|
-
[:delete, :touch, :kick, :stats, :bury, :release].each do |call|
|
|
77
|
-
assert_raises(ArgumentError, "#{call} #{id.inspect}") { job.send(call) }
|
|
78
|
-
assert_in_step
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
assert_equal 'job', @beanstalk.jobs.find(@id).body
|
|
82
|
-
end
|
|
83
|
-
end # job ids
|
|
84
|
-
|
|
85
|
-
describe "numbers" do
|
|
86
|
-
before do
|
|
87
|
-
@tube = @beanstalk.tubes.find('arguments')
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
it "should raise ArgumentError for a number that is not one" do
|
|
91
|
-
["1\r\nstats", "1\n", "1 2", "x", nil].each do |bad|
|
|
92
|
-
[:pri, :delay, :ttr].each do |key|
|
|
93
|
-
assert_raises(ArgumentError, "put #{key} #{bad.inspect}") { @tube.put('job', key => bad) }
|
|
94
|
-
assert_in_step
|
|
95
|
-
end
|
|
96
|
-
assert_raises(ArgumentError, "pause #{bad.inspect}") { @tube.pause(bad) }
|
|
97
|
-
assert_in_step
|
|
98
|
-
assert_raises(ArgumentError, "kick #{bad.inspect}") { @tube.kick(bad) }
|
|
99
|
-
assert_in_step
|
|
100
|
-
assert_raises(ArgumentError, "reserve #{bad.inspect}") { @beanstalk.tubes.reserve(bad) } if bad
|
|
101
|
-
assert_in_step
|
|
102
|
-
|
|
103
|
-
@tube.put('job')
|
|
104
|
-
job = @tube.reserve(0)
|
|
105
|
-
assert_raises(ArgumentError, "release pri #{bad.inspect}") { job.release(:pri => bad, :delay => 0) }
|
|
106
|
-
assert_in_step
|
|
107
|
-
assert_raises(ArgumentError, "release delay #{bad.inspect}") { job.release(:pri => 1, :delay => bad) }
|
|
108
|
-
assert_in_step
|
|
109
|
-
assert_raises(ArgumentError, "bury pri #{bad.inspect}") { job.bury(:pri => bad) }
|
|
110
|
-
assert_in_step
|
|
111
|
-
job.delete
|
|
112
|
-
end
|
|
113
|
-
assert_nil @tube.peek(:ready)
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
it "should raise ArgumentError for a priority, delay or TTR outside 0 to 4294967295" do
|
|
117
|
-
[-1, "-1", 2**32, "4294967296"].each do |bad|
|
|
118
|
-
[:pri, :delay, :ttr].each do |key|
|
|
119
|
-
assert_raises(ArgumentError, "put #{key} #{bad.inspect}") { @tube.put('stats', key => bad) }
|
|
120
|
-
assert_in_step
|
|
121
|
-
end
|
|
122
|
-
assert_raises(ArgumentError, "pause #{bad.inspect}") { @tube.pause(bad) }
|
|
123
|
-
assert_in_step
|
|
124
|
-
|
|
125
|
-
@tube.put('job')
|
|
126
|
-
job = @tube.reserve(0)
|
|
127
|
-
assert_raises(ArgumentError, "release pri #{bad.inspect}") { job.release(:pri => bad, :delay => 0) }
|
|
128
|
-
assert_in_step
|
|
129
|
-
assert_raises(ArgumentError, "release delay #{bad.inspect}") { job.release(:pri => 1, :delay => bad) }
|
|
130
|
-
assert_in_step
|
|
131
|
-
assert_raises(ArgumentError, "bury pri #{bad.inspect}") { job.bury(:pri => bad) }
|
|
132
|
-
assert_in_step
|
|
133
|
-
job.delete
|
|
134
|
-
end
|
|
135
|
-
assert_nil @tube.peek(:ready)
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
it "should accept the largest priority beanstalkd takes" do
|
|
139
|
-
[4294967295, "4294967295"].each do |pri|
|
|
140
|
-
@tube.put('job', :pri => pri)
|
|
141
|
-
job = @tube.reserve(0)
|
|
142
|
-
assert_equal 4294967295, job.stats.pri
|
|
143
|
-
job.release(:pri => pri, :delay => 0)
|
|
144
|
-
job = @tube.reserve(0)
|
|
145
|
-
job.bury(:pri => pri)
|
|
146
|
-
assert_equal 4294967295, job.stats.pri
|
|
147
|
-
job.delete
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
it "should accept Integers and Strings of digits, and Floats where beanstalkd does" do
|
|
152
|
-
@tube.put('job', :pri => '5', :delay => '0', :ttr => '60')
|
|
153
|
-
job = @tube.reserve(0.5)
|
|
154
|
-
assert_equal 5, job.stats.pri
|
|
155
|
-
job.release(:pri => '6', :delay => '0')
|
|
156
|
-
job = @beanstalk.tubes.reserve('0')
|
|
157
|
-
job.bury(:pri => 7)
|
|
158
|
-
assert_equal 1, @tube.kick(1.5)[:id].to_i
|
|
159
|
-
@tube.pause('0')
|
|
160
|
-
end
|
|
161
|
-
end # numbers
|
|
162
|
-
|
|
163
|
-
describe "peek states" do
|
|
164
|
-
it "should raise ArgumentError for a state other than ready, delayed or buried" do
|
|
165
|
-
tube = @beanstalk.tubes.find('arguments')
|
|
166
|
-
tube.put('job')
|
|
167
|
-
["ready\r\nstats", "ready ", "reserved", ""].each do |state|
|
|
168
|
-
assert_raises(ArgumentError, state.inspect) { tube.peek(state) }
|
|
169
|
-
assert_in_step
|
|
170
|
-
end
|
|
171
|
-
assert_equal 'job', tube.peek('ready').body
|
|
172
|
-
end
|
|
173
|
-
end # peek states
|
|
174
|
-
end
|