backburner-allq 1.0.8 → 1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -131
- data/HOOKS.md +1 -1
- data/README.md +22 -56
- data/TODO +0 -4
- data/backburner-allq.gemspec +2 -2
- data/deploy.sh +1 -1
- data/lib/backburner/allq_wrapper.rb +16 -22
- data/lib/backburner/connection.rb +10 -2
- data/lib/backburner/version.rb +1 -1
- data/lib/backburner/worker.rb +7 -4
- data/lib/backburner/workers/threading.rb +1 -1
- data/lib/backburner/workers/threads_on_fork.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27888373123e4db33adc4349646b3313ff962e98a18a3ff26918e7efd701fa92
|
4
|
+
data.tar.gz: b71459c2a3d38a986c86b7a51a238ada776f451ceb9a242dc74b58a9ca873149
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 064e65cfb8c739d502b833007fb6b1c9d2c6ffd433c20b8f5501200c44047d596fbbf7eb0a0b55def1503193d0bedb4793c003d814b2986b164562d20f1f7ad0
|
7
|
+
data.tar.gz: a6d06ecca8a34f24e1ab7b667a3334220dbfbb65e7e0da4b4884e8b40e491261316484133ec1ee14b144607c3e8adbc42f2fdbe9e3fc3fba880c63e50ae13cdf
|
data/CHANGELOG.md
CHANGED
@@ -1,133 +1,4 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
-
## Version 1.
|
4
|
-
|
5
|
-
* TBD
|
6
|
-
|
7
|
-
## Version 1.4.1 (June 10 2017)
|
8
|
-
|
9
|
-
* Fix warning for constant ::Fixnum is deprecated (@amatsuda)
|
10
|
-
|
11
|
-
## Version 1.4.0 (May 13 2017)
|
12
|
-
|
13
|
-
* Fix unit tests to be more consistent (@eltone)
|
14
|
-
* Ensure job supports body hash with symbol keys (@eltone)
|
15
|
-
* Add support for custom serialization formats (@eltone)
|
16
|
-
* Log the params when a job timeout occurs (@nathantsoi)
|
17
|
-
|
18
|
-
## Version 1.3.1 (April 21 2016)
|
19
|
-
|
20
|
-
* Addition of thread-pool-based concurrency (@contentfree)
|
21
|
-
|
22
|
-
## Version 1.3.0 (February 05 2016)
|
23
|
-
|
24
|
-
* Enqueue command now responds with beanstalk response details
|
25
|
-
|
26
|
-
## Version 1.2.0 (November 01 2015)
|
27
|
-
|
28
|
-
* FIX Made connections to beanstalkd more resilient (@contentfree)
|
29
|
-
|
30
|
-
## Version 1.2.0.pre (October 24 2015)
|
31
|
-
|
32
|
-
* FIX Replace static Beaneater connection with individual connections per worker instance/thread (@contentfree)
|
33
|
-
* FIX Beaneater connections try really hard to repair themselves if disconnected accidentally (@contentfree)
|
34
|
-
* NEW Event hook for workers: on_reconnect (@contentfree)
|
35
|
-
|
36
|
-
## Version 1.1.0 (September 14 2015)
|
37
|
-
|
38
|
-
* NEW Ability to configure namespace separator (@bfolkens)
|
39
|
-
* NEW Avoid timeouts altogether by setting queue_respond_timeout to 0 (@zacviandier)
|
40
|
-
* NEW Event hooks for on_retry and on_bury (@contentfree)
|
41
|
-
* NEW Support lambdas for queue names (@contentfree)
|
42
|
-
* NEW Allow for control of delay calculation (@contentfree)
|
43
|
-
* NEW Ability to specify environment when running the CLI (@contentfree)
|
44
|
-
* NEW Control default async behavior of methods (@contentfree)
|
45
|
-
|
46
|
-
## Version 1.0.0 (April 26 2015)
|
47
|
-
|
48
|
-
* NEW Updating to Beaneater 1.0 (@alup)
|
49
|
-
|
50
|
-
## Version 0.4.6 (October 26 2014)
|
51
|
-
|
52
|
-
* NEW Add job to on_error handler if the handler has a 4th argument (@Nitrodist)
|
53
|
-
* NEW Use a timeout when looking for a job to reserve (@EasyPost)
|
54
|
-
* NEW Support configuring settings on threads on fork class (@silentshade)
|
55
|
-
* FIX queue override by existing queues (@silentshade)
|
56
|
-
* FIX Use thread to log exit message (@silentshade)
|
57
|
-
|
58
|
-
## Version 0.4.5 (December 16 2013)
|
59
|
-
|
60
|
-
* FIX #47 Create a backburner connection per thread (Thanks @thcrock)
|
61
|
-
|
62
|
-
## Version 0.4.4 (October 27 2013)
|
63
|
-
|
64
|
-
* NEW #51 Added ability to set per-queue default ttr's (Thanks @ryanjohns)
|
65
|
-
|
66
|
-
## Version 0.4.3 (July 19 2013)
|
67
|
-
|
68
|
-
* FIX #44 Additional fix to issue introduced in 0.4.2
|
69
|
-
* FIX #45 More graceful shutdown using Kernel.exit and rescuing SystemExit. (Thanks @ryanjohns)
|
70
|
-
|
71
|
-
## Version 0.4.2 (July 3 2013)
|
72
|
-
|
73
|
-
* FIX #44 Properly retry to connect to beanstalkd when connection fails.
|
74
|
-
|
75
|
-
## Version 0.4.1 (June 28 2013)
|
76
|
-
|
77
|
-
* FIX #43 Properly support CLI options and smart load the app environment.
|
78
|
-
|
79
|
-
## Version 0.4.0 (June 28 2013)
|
80
|
-
|
81
|
-
NOTE: This is the start of working with @bradgessler to improve backburner and merge with quebert
|
82
|
-
|
83
|
-
* NEW #26 #27 Remove need for Queue mixin, allow plain ruby objects
|
84
|
-
* NEW Default all jobs to a single general queue rather than separate queues
|
85
|
-
* NEW Add support for named priorities, allowing shorthand names for priority values
|
86
|
-
|
87
|
-
## Version 0.3.4 (April 23 2013)
|
88
|
-
|
89
|
-
* FIX #22 Adds signal handlers for worker to manage proper shutdown (Thanks @tkiley)
|
90
|
-
|
91
|
-
## Version 0.3.3 (April 19 2013)
|
92
|
-
|
93
|
-
* Fix naming conflict rename 'config' to 'queue_config'
|
94
|
-
|
95
|
-
## Version 0.3.2 (Jan 23 2013)
|
96
|
-
|
97
|
-
* Bump version of beaneater to 0.3.0 (better socket handling)
|
98
|
-
|
99
|
-
## Version 0.3.1 (Dec 28 2012)
|
100
|
-
|
101
|
-
* Adds basic forking processing strategy and rake tasks (Thanks @danielfarrell)
|
102
|
-
|
103
|
-
## Version 0.3.0 (Nov 14 2012)
|
104
|
-
|
105
|
-
* Major update with support for a 'threads_on_fork' processing strategy (Thanks @ShadowBelmolve)
|
106
|
-
* Different workers have different rake tasks (Thanks @ShadowBelmolve)
|
107
|
-
* Added processing strategy specific examples i.e stress.rb and adds new unit tests. (Thanks @ShadowBelmolve)
|
108
|
-
|
109
|
-
## Version 0.2.6 (Nov 12 2012)
|
110
|
-
|
111
|
-
* Upgrade to beaneater 0.2.0
|
112
|
-
|
113
|
-
## Version 0.2.5 (Nov 9 2012)
|
114
|
-
|
115
|
-
* Add support for multiple worker processing strategies through subclassing.
|
116
|
-
|
117
|
-
## Version 0.2.0 (Nov 7 2012)
|
118
|
-
|
119
|
-
* Add new plugin hooks feature (see HOOKS.md)
|
120
|
-
|
121
|
-
## Version 0.1.2 (Nov 7 2012)
|
122
|
-
|
123
|
-
* Adds ability to specify a custom logger.
|
124
|
-
* Adds job retry configuration and worker support.
|
125
|
-
|
126
|
-
## Version 0.1.1 (Nov 6 2012)
|
127
|
-
|
128
|
-
* Fix issue with timed out reserves
|
129
|
-
|
130
|
-
## Version 0.1.0 (Nov 4 2012)
|
131
|
-
|
132
|
-
* Switch to beaneater as new ruby beanstalkd client
|
133
|
-
* Add support for array of connections in `beanstalk_url`
|
3
|
+
## Version 1.0.9 (September 9 2020)
|
4
|
+
Branched from backburner to use Allq instead
|
data/HOOKS.md
CHANGED
@@ -6,7 +6,7 @@ In many cases you can use a hook rather than mess around with Backburner's inter
|
|
6
6
|
## Job Hooks
|
7
7
|
|
8
8
|
Hooks are transparently adapted from [Resque](https://github.com/resque/resque/blob/master/docs/HOOKS.md), so
|
9
|
-
if you are familiar with their hook API, now you can use nearly the same ones with
|
9
|
+
if you are familiar with their hook API, now you can use nearly the same ones with allq and backburner!
|
10
10
|
|
11
11
|
There are a variety of hooks available that are triggered during the lifecycle of a job:
|
12
12
|
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# Backburner [![Build Status](https://travis-ci.org/nesquena/backburner.svg?branch=master)](https://travis-ci.org/nesquena/backburner)
|
2
2
|
|
3
|
-
Backburner is a [
|
3
|
+
Backburner-allq is a [allq](http://www.allqueue.com)-powered job queue that can handle a very high volume of jobs.
|
4
4
|
You create background jobs and place them on multiple work queues to be processed later.
|
5
5
|
|
6
|
-
Processing background jobs reliably has never been easier than with
|
6
|
+
Processing background jobs reliably has never been easier than with allq and Backburner. This gem works with any ruby-based
|
7
7
|
web framework, but is especially suited for use with [Sinatra](http://sinatrarb.com), [Padrino](http://padrinorb.com) and Rails.
|
8
8
|
|
9
|
-
If you want to use
|
9
|
+
If you want to use allq for your job processing, consider using Backburner.
|
10
10
|
Backburner is heavily inspired by Resque and DelayedJob. Backburner stores all jobs as simple JSON message payloads.
|
11
|
-
Persistent queues are supported when
|
11
|
+
Persistent queues are supported when allq persistence mode is enabled.
|
12
12
|
|
13
13
|
Backburner supports multiple queues, job priorities, delays, and timeouts. In addition,
|
14
14
|
Backburner has robust support for retrying failed jobs, handling error cases,
|
@@ -26,28 +26,14 @@ libraries under the hood. Every job queue requires a queue store that jobs are p
|
|
26
26
|
In the case of Resque, jobs are processed through **Redis**, a persistent key-value store. In the case of DelayedJob, jobs are processed through
|
27
27
|
**ActiveRecord** and a database such as PostgreSQL.
|
28
28
|
|
29
|
-
The work queue underlying these gems tells you infinitely more about the differences than anything else.
|
30
|
-
Beanstalk is probably the best solution for job queues available today for many reasons.
|
31
|
-
The real question then is... "Why Beanstalk?".
|
32
29
|
|
33
|
-
|
30
|
+
You will quickly see that **allq** is an underrated but incredible project that is extremely well-suited as a job queue.
|
31
|
+
Significantly better suited for this task than Redis or a database.
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
Adam Wiggins posted [an excellent comparison](http://adam.herokuapp.com/past/2010/4/24/beanstalk_a_simple_and_fast_queueing_backend/).
|
33
|
+
A single instance of Allq is perfectly capable of handling thousands of jobs a second (or more, depending on your job size)
|
34
|
+
because it is an in-memory, event-driven system.
|
38
35
|
|
39
|
-
|
40
|
-
Significantly better suited for this task than Redis or a database. Beanstalk is a simple,
|
41
|
-
and a very fast work queue service rolled into a single binary - it is the memcached of work queues.
|
42
|
-
Originally built to power the backend for the 'Causes' Facebook app, it is a mature and production ready open source project.
|
43
|
-
[PostRank](http://www.postrank.com) uses beanstalk to reliably process millions of jobs a day.
|
44
|
-
|
45
|
-
A single instance of Beanstalk is perfectly capable of handling thousands of jobs a second (or more, depending on your job size)
|
46
|
-
because it is an in-memory, event-driven system. Powered by libevent under the hood,
|
47
|
-
it requires zero setup (launch and forget, à la memcached), optional log based persistence, an easily parsed ASCII protocol,
|
48
|
-
and a rich set of tools for job management that go well beyond a simple FIFO work queue.
|
49
|
-
|
50
|
-
Beanstalkd supports the following features out of the box:
|
36
|
+
Allq supports the following features out of the box:
|
51
37
|
|
52
38
|
| Feature | Description |
|
53
39
|
| ------- | ------------------------------- |
|
@@ -59,27 +45,14 @@ Beanstalkd supports the following features out of the box:
|
|
59
45
|
| **Persistence** | Jobs are stored in memory for speed, but logged to disk for safe keeping. |
|
60
46
|
| **Federation** | Horizontal scalability provided through federation by the client. |
|
61
47
|
| **Error Handling** | Bury any job which causes an error for later debugging and inspection.|
|
48
|
+
| **Fair Queueing** | Allows you to shard work across queues for fair client queuing.|
|
49
|
+
| **Workflows** | Allows you tell Job C to wait for Job A and Job B to finish first.|
|
62
50
|
|
63
|
-
Keep in mind that these features are supported out of the box with
|
64
|
-
In the end, **
|
51
|
+
Keep in mind that these features are supported out of the box with allq and require no special code within this gem to support.
|
52
|
+
In the end, **allq is the ideal job queue** while also being ridiculously easy to install and setup.
|
65
53
|
|
66
54
|
## Installation
|
67
55
|
|
68
|
-
First, you probably want to [install beanstalkd](http://kr.github.com/beanstalkd/download.html), which powers the job queues.
|
69
|
-
Depending on your platform, this should be as simple as (for Ubuntu):
|
70
|
-
|
71
|
-
$ sudo apt-get install beanstalkd
|
72
|
-
|
73
|
-
Add this line to your application's Gemfile:
|
74
|
-
|
75
|
-
gem 'backburner'
|
76
|
-
|
77
|
-
And then execute:
|
78
|
-
|
79
|
-
$ bundle
|
80
|
-
|
81
|
-
Or install it yourself as:
|
82
|
-
|
83
56
|
$ gem install backburner
|
84
57
|
|
85
58
|
## Configuration ##
|
@@ -88,7 +61,7 @@ Backburner is extremely simple to setup. Just configure basic settings for backb
|
|
88
61
|
|
89
62
|
```ruby
|
90
63
|
Backburner.configure do |config|
|
91
|
-
config.beanstalk_url = "
|
64
|
+
config.beanstalk_url = "allq://127.0.0.1:8090"
|
92
65
|
config.tube_namespace = "some.app.production"
|
93
66
|
config.namespace_separator = "."
|
94
67
|
config.on_error = lambda { |e| puts e }
|
@@ -112,7 +85,7 @@ The key options available are:
|
|
112
85
|
|
113
86
|
| Option | Description |
|
114
87
|
| ----------------- | ------------------------------- |
|
115
|
-
| `
|
88
|
+
| `allq_url` | Address for allq connection i.e 'allq://127.0.0.1:8090' |
|
116
89
|
| `tube_namespace` | Prefix used for all tubes related to this backburner queue. |
|
117
90
|
| `namespace_separator` | Separator used for namespace and queue name |
|
118
91
|
| `on_error` | Lambda invoked with the error whenever any job in the system fails. |
|
@@ -129,15 +102,10 @@ The key options available are:
|
|
129
102
|
| `job_serializer_proc` | Lambda serializes a job body to a string to write to the task |
|
130
103
|
| `job_parser_proc` | Lambda parses a task body string to a hash |
|
131
104
|
|
132
|
-
## Breaking Changes
|
133
|
-
|
134
|
-
Before **v0.4.0**: Jobs were placed into default queues based on the name of the class creating the queue. i.e NewsletterJob would
|
135
|
-
be put into a 'newsletter-job' queue. As of 0.4.0, all jobs are placed into a primary queue named "my.app.namespace.backburner-jobs"
|
136
|
-
unless otherwise specified.
|
137
105
|
|
138
106
|
## Usage
|
139
107
|
|
140
|
-
Backburner allows you to create jobs and place them onto any number of
|
108
|
+
Backburner allows you to create jobs and place them onto any number of allq tubes, and later pull those jobs off the tubes and
|
141
109
|
process them asynchronously with a worker.
|
142
110
|
|
143
111
|
### Enqueuing Jobs ###
|
@@ -165,7 +133,7 @@ class NewsletterJob
|
|
165
133
|
|
166
134
|
# optional, defaults to respond_timeout in config
|
167
135
|
def self.queue_respond_timeout
|
168
|
-
300 # number of seconds before job times out, 0 to avoid timeout. NB: A timeout of 1 second will likely lead to race conditions between Backburner and
|
136
|
+
300 # number of seconds before job times out, 0 to avoid timeout. NB: A timeout of 1 second will likely lead to race conditions between Backburner and allq and should be avoided
|
169
137
|
end
|
170
138
|
|
171
139
|
# optional, defaults to retry_delay_proc in config
|
@@ -387,15 +355,15 @@ This is why our examples use object IDs instead of passing around objects.
|
|
387
355
|
|
388
356
|
### Named Priorities
|
389
357
|
|
390
|
-
As of v0.4.0, Backburner has support for named priorities.
|
358
|
+
As of v0.4.0, Backburner has support for named priorities. allq priorities are numerical but
|
391
359
|
backburner supports a mapping between a word and a numerical value. The following priorities are
|
392
|
-
available by default: `high` is 0, `medium` is
|
360
|
+
available by default: `high` is 0, `medium` is 4, and `low` is 9.
|
393
361
|
|
394
362
|
Priorities can be customized with:
|
395
363
|
|
396
364
|
```ruby
|
397
365
|
Backburner.configure do |config|
|
398
|
-
config.priority_labels = { :custom =>
|
366
|
+
config.priority_labels = { :custom => 1, :useful => 5 }
|
399
367
|
# or append to default priorities with
|
400
368
|
# config.priority_labels = Backburner::Configuration::PRIORITY_LABELS.merge(:foo => 5)
|
401
369
|
end
|
@@ -557,8 +525,7 @@ Check out [HOOKS.md](https://github.com/nesquena/backburner/blob/master/HOOKS.md
|
|
557
525
|
|
558
526
|
### Workers in Production
|
559
527
|
|
560
|
-
Once you have Backburner setup in your application, starting workers is really easy.
|
561
|
-
is installed, your best bet is to use the built-in rake task that comes with Backburner. Simply add the task to your Rakefile:
|
528
|
+
Once you have Backburner setup in your application, starting workers is really easy. Simply add the task to your Rakefile:
|
562
529
|
|
563
530
|
```ruby
|
564
531
|
# Rakefile
|
@@ -609,8 +576,7 @@ backburner -e $environment
|
|
609
576
|
|
610
577
|
#### Reconnecting
|
611
578
|
|
612
|
-
In Backburner, if the
|
613
|
-
After several retries, if the connection is still not able to be made, a `Beaneater::NotConnected` exception will be raised.
|
579
|
+
In Backburner, if the allq connection is temporarily severed, several retries to establish the connection will be attempted.
|
614
580
|
You can manually catch this exception, and attempt another manual retry using `Backburner::Worker.retry_connection!`.
|
615
581
|
|
616
582
|
### Web Front-end
|
data/TODO
CHANGED
data/backburner-allq.gemspec
CHANGED
@@ -4,9 +4,9 @@ require File.expand_path('../lib/backburner/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.authors = ["Jason Malcolm"]
|
6
6
|
s.email = ["jason@blitline.com"]
|
7
|
-
s.description = %q{
|
7
|
+
s.description = %q{Allq background job processing made easy}
|
8
8
|
s.summary = %q{Reliable allq background job processing made easy for Ruby and Sinatra}
|
9
|
-
s.homepage = "http://github.com/
|
9
|
+
s.homepage = "http://github.com/blitline-dev/backburner-allq"
|
10
10
|
|
11
11
|
s.files = `git ls-files`.split($\)
|
12
12
|
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/deploy.sh
CHANGED
@@ -114,13 +114,19 @@ module Backburner
|
|
114
114
|
@client.release_put(job.id)
|
115
115
|
end
|
116
116
|
|
117
|
-
def bury(job)
|
117
|
+
def bury(job)
|
118
|
+
@client.bury_put(job.id)
|
119
|
+
end
|
118
120
|
|
119
121
|
def tube_names
|
120
122
|
stats_hash = stats
|
121
123
|
stats_hash.keys
|
122
124
|
end
|
123
125
|
|
126
|
+
def tubes
|
127
|
+
tube_names
|
128
|
+
end
|
129
|
+
|
124
130
|
def peek_buried(tube_name = 'default')
|
125
131
|
job = nil
|
126
132
|
job = @client.peek_get(tube_name, buried: true)
|
@@ -161,15 +167,8 @@ module Backburner
|
|
161
167
|
|
162
168
|
default = 5
|
163
169
|
|
164
|
-
return
|
165
|
-
|
166
|
-
return 6 if app_priority >= 33_000
|
167
|
-
|
168
|
-
return 7 if app_priority >= 35_000
|
169
|
-
|
170
|
-
return 8 if app_priority >= 37_000
|
171
|
-
|
172
|
-
default
|
170
|
+
# return app_priority unless larger than 10
|
171
|
+
app_priority > 10 ? 5 : app_priority
|
173
172
|
end
|
174
173
|
|
175
174
|
def log_result(job_result)
|
@@ -191,6 +190,7 @@ module Backburner
|
|
191
190
|
ttl: ttl,
|
192
191
|
delay: delay,
|
193
192
|
priority: adjusted_priority,
|
193
|
+
shard_key: options[:shard_key],
|
194
194
|
parent_id: parent_id)
|
195
195
|
new_job
|
196
196
|
end
|
@@ -212,21 +212,11 @@ module Backburner
|
|
212
212
|
priority: adjusted_priority,
|
213
213
|
timeout: timeout,
|
214
214
|
run_on_timeout: run_on_timeout,
|
215
|
+
shard_key: options[:shard_key],
|
215
216
|
limit: limit)
|
216
217
|
new_parent_job
|
217
218
|
end
|
218
219
|
|
219
|
-
def put2(body, pri = 5, ttl = 600, tube_name = "default", delay = 0)
|
220
|
-
# Old school way
|
221
|
-
options = {
|
222
|
-
pri: pri,
|
223
|
-
ttl: ttl,
|
224
|
-
tube_name: tube_name,
|
225
|
-
delay: delay
|
226
|
-
}
|
227
|
-
put(body, options)
|
228
|
-
end
|
229
|
-
|
230
220
|
def put(body, options)
|
231
221
|
# New school put
|
232
222
|
retry_count = 0
|
@@ -236,7 +226,6 @@ module Backburner
|
|
236
226
|
begin
|
237
227
|
Timeout.timeout(10) do
|
238
228
|
if body && body.to_s.include?('["default"]')
|
239
|
-
puts "PUTTING DEFAULT! #{caller.inspect}"
|
240
229
|
end
|
241
230
|
|
242
231
|
if is_parent
|
@@ -265,6 +254,11 @@ module Backburner
|
|
265
254
|
result
|
266
255
|
end
|
267
256
|
|
257
|
+
def stats(tube)
|
258
|
+
final_stats = stats
|
259
|
+
final_stats[tube]
|
260
|
+
end
|
261
|
+
|
268
262
|
def stats
|
269
263
|
raw_stats = @admin.stats_get
|
270
264
|
final_stats = {}
|
@@ -96,9 +96,17 @@ module Backburner
|
|
96
96
|
|
97
97
|
def put(tube_name, data, opt)
|
98
98
|
pri = (opt[:pri] || 5).to_i
|
99
|
-
delay = opt[:delay].to_i
|
100
99
|
ttr = (opt[:ttr] || 600).to_i
|
101
|
-
|
100
|
+
|
101
|
+
options = {
|
102
|
+
tube_name: tube_name,
|
103
|
+
pri: pri,
|
104
|
+
delay: opt[:delay].to_i,
|
105
|
+
ttr: ttr
|
106
|
+
}
|
107
|
+
|
108
|
+
options.merge!(opt)
|
109
|
+
@allq_wrapper.put(data, options)
|
102
110
|
end
|
103
111
|
|
104
112
|
def get(tube_name)
|
data/lib/backburner/version.rb
CHANGED
data/lib/backburner/worker.rb
CHANGED
@@ -40,8 +40,7 @@ module Backburner
|
|
40
40
|
connection.retryable do
|
41
41
|
tube_name = expand_tube_name(queue || job_class)
|
42
42
|
serialized_data = Backburner.configuration.job_serializer_proc.call(data)
|
43
|
-
|
44
|
-
response = connection.put(tube_name, serialized_data, :pri => pri, :delay => delay, :ttr => ttr)
|
43
|
+
response = connection.put(tube_name, serialized_data, :pri => pri, :delay => delay, :ttr => ttr, :shard_key => opts[:shard_key])
|
45
44
|
end
|
46
45
|
return nil unless Backburner::Hooks.invoke_hook_events(job_class, :after_enqueue, *args)
|
47
46
|
ensure
|
@@ -149,14 +148,18 @@ module Backburner
|
|
149
148
|
return
|
150
149
|
end
|
151
150
|
|
152
|
-
# NB: There's a slight chance here that the connection to
|
151
|
+
# NB: There's a slight chance here that the connection to allq has
|
153
152
|
# gone down between the time we reserved / processed the job and here.
|
154
153
|
num_retries = job.releases
|
155
154
|
max_job_retries = resolve_max_job_retries(job.job_class)
|
156
155
|
retry_status = "failed: attempt #{num_retries+1} of #{max_job_retries+1}"
|
157
156
|
retry_delay = resolve_retry_delay(job.job_class)
|
158
157
|
delay = resolve_retry_delay_proc(job.job_class).call(retry_delay, num_retries) rescue retry_delay
|
159
|
-
|
158
|
+
if num_retries + 1 > max_job_retries
|
159
|
+
job.bury
|
160
|
+
else
|
161
|
+
job.release(delay)
|
162
|
+
end
|
160
163
|
self.log_job_end(job.name, "#{retry_status}, retrying in #{delay}s") if job_started_at
|
161
164
|
|
162
165
|
handle_error(e, job.name, job.args, job)
|
@@ -105,7 +105,7 @@ module Backburner
|
|
105
105
|
# Process the tube settings
|
106
106
|
# This overrides @tubes_data set by process_tube_names method. So a tube has name 'super_job:5'
|
107
107
|
# and the tube class has setting queue_jobs_limit 10, the result limit will be 10
|
108
|
-
# If the tube is known by existing
|
108
|
+
# If the tube is known by existing allq queue, but not by class - skip it
|
109
109
|
#
|
110
110
|
def process_tube_options
|
111
111
|
Backburner::Worker.known_queue_classes.each do |queue|
|
@@ -105,7 +105,7 @@ module Backburner
|
|
105
105
|
# Process the tube settings
|
106
106
|
# This overrides @tubes_data set by process_tube_names method. So a tube has name 'super_job:5:20:10'
|
107
107
|
# and the tube class has setting queue_jobs_limit 10, the result limit will be 10
|
108
|
-
# If the tube is known by existing
|
108
|
+
# If the tube is known by existing allq queue, but not by class - skip it
|
109
109
|
#
|
110
110
|
def process_tube_options
|
111
111
|
Backburner::Worker.known_queue_classes.each do |queue|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backburner-allq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Malcolm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: allq_rest
|
@@ -100,7 +100,7 @@ dependencies:
|
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
|
-
description:
|
103
|
+
description: Allq background job processing made easy
|
104
104
|
email:
|
105
105
|
- jason@blitline.com
|
106
106
|
executables:
|
@@ -169,7 +169,7 @@ files:
|
|
169
169
|
- test/workers/simple_worker_test.rb
|
170
170
|
- test/workers/threading_worker_test.rb
|
171
171
|
- test/workers/threads_on_fork_worker_test.rb
|
172
|
-
homepage: http://github.com/
|
172
|
+
homepage: http://github.com/blitline-dev/backburner-allq
|
173
173
|
licenses:
|
174
174
|
- MIT
|
175
175
|
metadata: {}
|