Skip to content

Commit 6491156

Browse files
committed
Improve README
- Merge Usage and Installation sections together. - Document `concurrency_maintenance_interval` setting, that I had missed.
1 parent a58d5a7 commit 6491156

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

README.md

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,11 @@
22

33
Solid Queue is a DB-based queuing backend for [Active Job](https://edgeguides.rubyonrails.org/active_job_basics.html), designed with simplicity and performance in mind.
44

5-
Besides regular job enqueuing and processing, Solid Queue supports delayed jobs, concurrency controls, pausing queues, numeric priorities per job, and priorities by queue order. _Proper support for `perform_all_later`, improvements to logging and instrumentation, a better CLI tool, a way to run within an existing process in "async" mode, unique jobs and recurring, cron-like tasks are coming very soon._
5+
Besides regular job enqueuing and processing, Solid Queue supports delayed jobs, concurrency controls, pausing queues, numeric priorities per job, and priorities by queue order. _Improvements to logging and instrumentation, a better CLI tool, a way to run within an existing process in "async" mode, unique jobs and recurring, cron-like tasks are coming very soon._
66

77
Solid Queue can be used with SQL databases such as MySQL, PostgreSQL or SQLite, and it leverages the `FOR UPDATE SKIP LOCKED` clause, if available, to avoid blocking and waiting on locks when polling jobs. It relies on Active Job for retries, discarding, error handling, serialization, or delays, and it's compatible with Ruby on Rails multi-threading.
88

9-
## Usage
10-
To set Solid Queue as your Active Job's queue backend, you should add this to your environment config:
11-
```ruby
12-
# config/environments/production.rb
13-
config.active_job.queue_adapter = :solid_queue
14-
```
15-
16-
Alternatively, you can set only specific jobs to use Solid Queue as their backend if you're migrating from another adapter and want to move jobs progressively:
17-
18-
```ruby
19-
# app/jobs/my_job.rb
20-
21-
class MyJob < ApplicationJob
22-
self.queue_adapter = :solid_queue
23-
# ...
24-
end
25-
```
26-
27-
## Installation
9+
## Installation and usage
2810
Add this line to your application's Gemfile:
2911

3012
```ruby
@@ -41,23 +23,43 @@ Or install it yourself as:
4123
$ gem install solid_queue
4224
```
4325

44-
Install Migrations and Set Up Active Job Adapter
45-
Now, you need to install the necessary migrations and configure the Active Job's adapter. Run the following commands:
26+
Now, you need to install the necessary migrations and configure the Active Job's adapter. You can do both at once using the provided generator:
27+
4628
```bash
4729
$ bin/rails generate solid_queue:install
4830
```
4931

50-
or add the only the migration to your app and run it:
32+
This will set `solid_queue` as the Active Job's adapter in production, and will copy the required migration over to your app.
33+
34+
Alternatively, you can add the only the migration to your app:
5135
```bash
5236
$ bin/rails solid_queue:install:migrations
5337
```
5438

55-
Run the Migrations (required after either of the above steps):
39+
And set Solid Queue as your Active Job's queue backend manually, in your environment config:
40+
```ruby
41+
# config/environments/production.rb
42+
config.active_job.queue_adapter = :solid_queue
43+
```
44+
45+
Alternatively, you can set only specific jobs to use Solid Queue as their backend if you're migrating from another adapter and want to move jobs progressively:
46+
47+
```ruby
48+
# app/jobs/my_job.rb
49+
50+
class MyJob < ApplicationJob
51+
self.queue_adapter = :solid_queue
52+
# ...
53+
end
54+
```
55+
56+
Finally, you need to run the migrations:
57+
5658
```bash
5759
$ bin/rails db:migrate
5860
```
5961

60-
With this, you'll be ready to enqueue jobs using Solid Queue, but you need to start Solid Queue's supervisor to run them.
62+
After this, you'll be ready to enqueue jobs using Solid Queue, but you need to start Solid Queue's supervisor to run them.
6163
```bash
6264
$ bundle exec rake solid_queue:start
6365
```
@@ -83,6 +85,7 @@ production:
8385
dispatchers:
8486
- polling_interval: 1
8587
batch_size: 500
88+
concurrency_maintenance_interval: 300
8689
workers:
8790
- queues: "*"
8891
threads: 3
@@ -97,6 +100,7 @@ Everything is optional. If no configuration is provided, Solid Queue will run wi
97100
98101
- `polling_interval`: the time interval in seconds that workers and dispatchers will wait before checking for more jobs. This time defaults to `1` second for dispatchers and `0.1` seconds for workers.
99102
- `batch_size`: the dispatcher will dispatch jobs in batches of this size. The default is 500.
103+
- `concurrency_maintenance_interval`: the time interval in seconds that the dispatcher will wait before checking for blocked jobs that can be unblocked. Read more about [concurrency controls](#concurrency-controls) to learn more about this setting. It defaults to `600` seconds.
100104
- `queues`: the list of queues that workers will pick jobs from. You can use `*` to indicate all queues (which is also the default and the behaviour you'll get if you omit this). You can provide a single queue, or a list of queues as an array. Jobs will be polled from those queues in order, so for example, with `[ real_time, background ]`, no jobs will be taken from `background` unless there aren't any more jobs waiting in `real_time`. You can also provide a prefix with a wildcard to match queues starting with a prefix. For example:
101105

102106
```yml

0 commit comments

Comments
 (0)