Skip to content

Commit ed636c3

Browse files
committed
Add table of contents to README and reorganise sections a little bit
1 parent 18e7b0e commit ed636c3

File tree

1 file changed

+53
-26
lines changed

1 file changed

+53
-26
lines changed

README.md

+53-26
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ Besides regular job enqueuing and processing, Solid Queue supports delayed jobs,
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's multi-threading.
88

9+
## Table of contents
10+
11+
- [Installation](#installation)
12+
- [Single database configuration](#single-database-configuration)
13+
- [Incremental adoption](#incremental-adoption)
14+
- [High performance requirements](#high-performance-requirements)
15+
- [Configuration](#configuration)
16+
- [Workers, dispatchers and scheduler](#workers-dispatchers-and-scheduler)
17+
- [Queue order and priorities](#queue-order-and-priorities)
18+
- [Queues specification and performance](#queues-specification-and-performance)
19+
- [Threads, processes and signals](#threads-processes-and-signals)
20+
- [Database configuration](#database-configuration)
21+
- [Other configuration settings](#other-configuration-settings)
22+
- [Lifecycle hooks](#lifecycle-hooks)
23+
- [Errors when enqueuing](#errors-when-enqueuing)
24+
- [Concurrency controls](#concurrency-controls)
25+
- [Failed jobs and retries](#failed-jobs-and-retries)
26+
- [Error reporting on jobs](#error-reporting-on-jobs)
27+
- [Puma plugin](#puma-plugin)
28+
- [Jobs and transactional integrity](#jobs-and-transactional-integrity)
29+
- [Recurring tasks](#recurring-tasks)
30+
- [Inspiration](#inspiration)
31+
- [License](#license)
32+
33+
934
## Installation
1035

1136
Solid Queue is configured by default in new Rails 8 applications. But if you're running an earlier version, you can add it manually following these steps:
@@ -64,7 +89,7 @@ Running Solid Queue in a separate database is recommended, but it's also possibl
6489

6590
You won't have multiple databases, so `database.yml` doesn't need to have primary and queue database.
6691

67-
## Incremental adoption
92+
### Incremental adoption
6893

6994
If you're planning to adopt Solid Queue incrementally by switching one job at the time, you can do so by leaving the `config.active_job.queue_adapter` set to your old backend, and then set the `queue_adapter` directly in the jobs you're moving:
7095

@@ -77,7 +102,7 @@ class MyJob < ApplicationJob
77102
end
78103
```
79104

80-
## High performance requirements
105+
### High performance requirements
81106

82107
Solid Queue was designed for the highest throughput when used with MySQL 8+ or PostgreSQL 9.5+, as they support `FOR UPDATE SKIP LOCKED`. You can use it with older versions, but in that case, you might run into lock waits if you run multiple workers for the same queue. You can also use it with SQLite on smaller applications.
83108

@@ -250,6 +275,32 @@ You can configure the database used by Solid Queue via the `config.solid_queue.c
250275

251276
All the options available to Active Record for multiple databases can be used here.
252277

278+
### Other configuration settings
279+
280+
_Note_: The settings in this section should be set in your `config/application.rb` or your environment config like this: `config.solid_queue.silence_polling = true`
281+
282+
There are several settings that control how Solid Queue works that you can set as well:
283+
- `logger`: the logger you want Solid Queue to use. Defaults to the app logger.
284+
- `app_executor`: the [Rails executor](https://guides.rubyonrails.org/threading_and_code_execution.html#executor) used to wrap asynchronous operations, defaults to the app executor
285+
- `on_thread_error`: custom lambda/Proc to call when there's an error within a Solid Queue thread that takes the exception raised as argument. Defaults to
286+
287+
```ruby
288+
-> (exception) { Rails.error.report(exception, handled: false) }
289+
```
290+
291+
**This is not used for errors raised within a job execution**. Errors happening in jobs are handled by Active Job's `retry_on` or `discard_on`, and ultimately will result in [failed jobs](#failed-jobs-and-retries). This is for errors happening within Solid Queue itself.
292+
293+
- `use_skip_locked`: whether to use `FOR UPDATE SKIP LOCKED` when performing locking reads. This will be automatically detected in the future, and for now, you'd only need to set this to `false` if your database doesn't support it. For MySQL, that'd be versions < 8, and for PostgreSQL, versions < 9.5. If you use SQLite, this has no effect, as writes are sequential.
294+
- `process_heartbeat_interval`: the heartbeat interval that all processes will follow—defaults to 60 seconds.
295+
- `process_alive_threshold`: how long to wait until a process is considered dead after its last heartbeat—defaults to 5 minutes.
296+
- `shutdown_timeout`: time the supervisor will wait since it sent the `TERM` signal to its supervised processes before sending a `QUIT` version to them requesting immediate termination—defaults to 5 seconds.
297+
- `silence_polling`: whether to silence Active Record logs emitted when polling for both workers and dispatchers—defaults to `true`.
298+
- `supervisor_pidfile`: path to a pidfile that the supervisor will create when booting to prevent running more than one supervisor in the same host, or in case you want to use it for a health check. It's `nil` by default.
299+
- `preserve_finished_jobs`: whether to keep finished jobs in the `solid_queue_jobs` table—defaults to `true`.
300+
- `clear_finished_jobs_after`: period to keep finished jobs around, in case `preserve_finished_jobs` is true—defaults to 1 day. **Note:** Right now, there's no automatic cleanup of finished jobs. You'd need to do this by periodically invoking `SolidQueue::Job.clear_finished_in_batches`, but this will happen automatically in the near future.
301+
- `default_concurrency_control_period`: the value to be used as the default for the `duration` parameter in [concurrency controls](#concurrency-controls). It defaults to 3 minutes.
302+
303+
253304
## Lifecycle hooks
254305

255306
In Solid queue, you can hook into two different points in the supervisor's life:
@@ -277,30 +328,6 @@ SolidQueue.on_stop { stop_metrics_server }
277328

278329
These can be called several times to add multiple hooks, but it needs to happen before Solid Queue is started. An initializer would be a good place to do this.
279330

280-
### Other configuration settings
281-
282-
_Note_: The settings in this section should be set in your `config/application.rb` or your environment config like this: `config.solid_queue.silence_polling = true`
283-
284-
There are several settings that control how Solid Queue works that you can set as well:
285-
- `logger`: the logger you want Solid Queue to use. Defaults to the app logger.
286-
- `app_executor`: the [Rails executor](https://guides.rubyonrails.org/threading_and_code_execution.html#executor) used to wrap asynchronous operations, defaults to the app executor
287-
- `on_thread_error`: custom lambda/Proc to call when there's an error within a Solid Queue thread that takes the exception raised as argument. Defaults to
288-
289-
```ruby
290-
-> (exception) { Rails.error.report(exception, handled: false) }
291-
```
292-
293-
**This is not used for errors raised within a job execution**. Errors happening in jobs are handled by Active Job's `retry_on` or `discard_on`, and ultimately will result in [failed jobs](#failed-jobs-and-retries). This is for errors happening within Solid Queue itself.
294-
295-
- `use_skip_locked`: whether to use `FOR UPDATE SKIP LOCKED` when performing locking reads. This will be automatically detected in the future, and for now, you'd only need to set this to `false` if your database doesn't support it. For MySQL, that'd be versions < 8, and for PostgreSQL, versions < 9.5. If you use SQLite, this has no effect, as writes are sequential.
296-
- `process_heartbeat_interval`: the heartbeat interval that all processes will follow—defaults to 60 seconds.
297-
- `process_alive_threshold`: how long to wait until a process is considered dead after its last heartbeat—defaults to 5 minutes.
298-
- `shutdown_timeout`: time the supervisor will wait since it sent the `TERM` signal to its supervised processes before sending a `QUIT` version to them requesting immediate termination—defaults to 5 seconds.
299-
- `silence_polling`: whether to silence Active Record logs emitted when polling for both workers and dispatchers—defaults to `true`.
300-
- `supervisor_pidfile`: path to a pidfile that the supervisor will create when booting to prevent running more than one supervisor in the same host, or in case you want to use it for a health check. It's `nil` by default.
301-
- `preserve_finished_jobs`: whether to keep finished jobs in the `solid_queue_jobs` table—defaults to `true`.
302-
- `clear_finished_jobs_after`: period to keep finished jobs around, in case `preserve_finished_jobs` is true—defaults to 1 day. **Note:** Right now, there's no automatic cleanup of finished jobs. You'd need to do this by periodically invoking `SolidQueue::Job.clear_finished_in_batches`, but this will happen automatically in the near future.
303-
- `default_concurrency_control_period`: the value to be used as the default for the `duration` parameter in [concurrency controls](#concurrency-controls). It defaults to 3 minutes.
304331

305332
## Errors when enqueuing
306333

0 commit comments

Comments
 (0)