postburner 0.7.2 → 0.8.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: 31329ed53b5479ef4b3963ce4f6faa7ae103986cb68af6777db9c5dbb46a5b28
4
- data.tar.gz: 2c115fcdea67de746f3544684377ff66f8f85ec48241b93a6c8f107e9c5bf052
3
+ metadata.gz: b3f5758fde9443c7c094a85825c343aa003fd43a969323d549fe631d3c114fd8
4
+ data.tar.gz: aa30ba2e1ef5669bc9dd86243553dcc3f89c5dfa0a084c154afd313919df82db
5
5
  SHA512:
6
- metadata.gz: 213abba743144280c99e4b65b0ad54fa26189a3c7f60c82ac9258642ca50803769b297abb53619f89bd88152e43ac6720881178b154ed45771c1fb252eeda99e
7
- data.tar.gz: c01eb3f31553159d442cf9c82e984ca084c83b301df918fe2cfedc4d6d2c508d15ae114ff5402361acf9a2bdeefe0db4ed508183e366ed144ae467aad422a0c3
6
+ metadata.gz: 9f87f62fdca9594f365fb1641a3c0d83adc78271a0ac22e4b711e684cf02ba7fa5e9ad51c0ec2eac999ee62ac95d998bd7dccf3ef33e64856b77b40fa39329a5
7
+ data.tar.gz: 9e518552995537a13204210f5fdffb76a7d709a64c0064dec45a0b02150c871774e4ed0f7c82da90ac2fd3d76c313577f70420a95461d426b21fb20abaf428e5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.8.0 - 2022-11-13
4
+
5
+ ### Added
6
+ - add Postburner::Tube for Beaneater job introspection.
7
+ - add note about tube names and hyphens/dashes to README.
8
+
9
+ ### Fixed
10
+ - fix Backburner::Queue methods in subclasses for queue selection, etc.
11
+
3
12
  ## v0.7.1 - 2022-10-30
4
13
 
5
14
  ### Required Changes
data/README.md CHANGED
@@ -203,6 +203,24 @@ to add your own authentication or changes - or just create your own routes, cont
203
203
  [Override the views](https://guides.rubyonrails.org/engines.html#overriding-views) to make them
204
204
  prettier - or follow the suggestion above and use your own.
205
205
 
206
+ ## Known Issues
207
+
208
+ 1. Beaneater and/or Beanstalkd seems to transform a `tube` `name` with hyphens to
209
+ underscores upon instrospection of `stats`. See example. Reccommend using
210
+ names without hyphens / dashes.
211
+
212
+ ```ruby
213
+ (main):001:0> Postburner.connection.tubes["backburner.worker.queue.cat-dog"].put("{}", delay: 1.week.to_i)
214
+ => {:status=>"INSERTED", :id=>"9"}
215
+ irb(main):002:0> Postburner.connection.jobs.find(9)
216
+ => #<Beaneater::Job id=9 body="{}">
217
+ irb(main):003:0> Postburner.connection.jobs.find(9).stats
218
+ => #<Beaneater::StatStruct id=9, tube="backburner.worker.queue.cat_dog", state="delayed", pri=65536, age=23, delay=604800, ttr=120, time_left=604776, file=0, reserves=0, timeouts=0, releases=0, buries=0, kicks=0>
219
+ #
220
+ # NOTE 'cat-dog' on line 1 and 'cat_dog' on line 3.
221
+ #
222
+ ```
223
+
206
224
  ## Installation
207
225
 
208
226
  First [install beanstalkd](https://beanstalkd.github.io/download.html). On Debian-based systems, that goes like this:
@@ -274,7 +274,7 @@ module Postburner
274
274
  _run_insert_callbacks do
275
275
  Job.transaction do
276
276
  response = Backburner::Worker.enqueue(
277
- Postburner::Job,
277
+ self.class,
278
278
  self.id,
279
279
  options
280
280
  )
@@ -0,0 +1,53 @@
1
+ module Postburner
2
+ class Tube
3
+ def initialize(tube)
4
+ @tube = tube
5
+ end
6
+
7
+ # Get all tubes as Postburner::Tube instances.
8
+ #
9
+ def self.all
10
+ Postburner.connection.tubes.all.map { |tube| self.new(tube) }
11
+ end
12
+
13
+ # Get all peeked ids across all known tubes.
14
+ #
15
+ def self.peek_ids
16
+ self.all.map(&:peek_ids).flatten.sort
17
+ end
18
+
19
+ # Get all peeked ids.
20
+ #
21
+ def peek_ids
22
+ [ :buried, :ready, :delayed ].map { |type| @tube.peek(type) }.
23
+ reject(&:nil?).map(&:id).map(&:to_i)
24
+ end
25
+
26
+ # Get paginated array of jobs.
27
+ #
28
+ # Attempts to do this efficiently as possible, by peeking at known
29
+ # ids and exiting when count has been fulfilled.
30
+ #
31
+ # Just pass the last known id to after for the next batch.
32
+ #
33
+ def jobs(count=20, limit: 1000, after: nil)
34
+ stats = @tube.stats
35
+ jobs = Array.new
36
+
37
+ min_known = (
38
+ peek_ids.any? ? self.peek_ids.min : self.class.peek_ids.min
39
+ ).to_i
40
+ min = after ? after + 1 : min_known
41
+ max = min + limit
42
+
43
+ for i in min..max
44
+ job = @tube.client.jobs.find(i)
45
+ jobs << job if job && stats[:name] == job.stats[:tube]
46
+ break if jobs.length >= count
47
+ end
48
+
49
+ return jobs
50
+ end
51
+
52
+ end
53
+ end
@@ -1,3 +1,3 @@
1
1
  module Postburner
2
- VERSION = '0.7.2'
2
+ VERSION = '0.8.0'
3
3
  end
data/lib/postburner.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "postburner/version"
2
2
  require "postburner/engine"
3
+ require "postburner/tube"
3
4
 
4
5
  module Postburner
5
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postburner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-30 00:00:00.000000000 Z
11
+ date: 2022-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -98,6 +98,7 @@ files:
98
98
  - lib/generators/postburner/install/templates/migrations/create_postburner_jobs.rb.erb
99
99
  - lib/postburner.rb
100
100
  - lib/postburner/engine.rb
101
+ - lib/postburner/tube.rb
101
102
  - lib/postburner/version.rb
102
103
  - lib/tasks/postburner_tasks.rake
103
104
  homepage: https://gitlab.nearapogee.com/opensource/postburner