Skip to content

Commit 090edb9

Browse files
authored
Merge pull request #390 from evdevdev/main
Add explicit development instructions to the README.
2 parents 4e0255e + 8e69554 commit 090edb9

File tree

1 file changed

+62
-3
lines changed

1 file changed

+62
-3
lines changed

README.md

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ production:
6868
migrations_paths: db/queue_migrate
6969
```
7070
71-
Note: Calling `bin/rails solid_queue:install` will automatically add `config.solid_queue.connects_to = { database: { writing: :queue } }` to `config/environments/production.rb`, so no additional configuration is needed there (although you must make sure that you use the `queue` name in `database.yml` for this to match!). But if you want to use Solid Queue in a different environment (like staging or even development), you'll have to manually add that `config.solid_queue.connects_to` line to the respective environment file. And, as always, make sure that the name you're using for the database in `config/database.yml` matches the name you use in `config.solid_queue.connects_to`.
72-
7371
Then run `db:prepare` in production to ensure the database is created and the schema is loaded.
7472

7573
Now you're ready to start processing jobs by running `bin/jobs` on the server that's doing the work. This will start processing jobs in all queues using the default configuration. See [below](#configuration) to learn more about configuring Solid Queue.
@@ -78,6 +76,67 @@ For small projects, you can run Solid Queue on the same machine as your webserve
7876

7977
**Note**: future changes to the schema will come in the form of regular migrations.
8078

79+
### Usage in development and other non-production environments
80+
81+
Calling `bin/rails solid_queue:install` will automatically add `config.solid_queue.connects_to = { database: { writing: :queue } }` to `config/environments/production.rb`. In order to use Solid Queue in other environments (such as development or staging), you'll need to add a similar configuration(s).
82+
83+
For example, if you're using SQLite in development, update `database.yml` as follows:
84+
85+
```diff
86+
development:
87+
primary:
88+
<<: *default
89+
database: storage/development.sqlite3
90+
+ queue:
91+
+ <<: *default
92+
+ database: storage/development_queue.sqlite3
93+
+ migrations_paths: db/queue_migrate
94+
```
95+
96+
Next, add the following to `development.rb`
97+
98+
```ruby
99+
# Use Solid Queue in Development.
100+
config.active_job.queue_adapter = :solid_queue
101+
config.solid_queue.connects_to = {database: {writing: :queue}}
102+
```
103+
104+
Once you've added this, run `db:prepare` to create the Solid Queue database and load the schema.
105+
106+
Finally, in order for jobs to be processed, you'll need to have Solid Queue running. In Development, this can be done via the Puma plugin. In `puma.rb` update the following line:
107+
108+
```ruby
109+
# You can either set the env var, or check for development
110+
plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"] || Rails.env.development?
111+
```
112+
113+
**Import Note about Action Cable**: If you use Action Cable (or anything dependent on Action Cable, such as Turbo Streams), you will need to also need to update it to use a database.
114+
115+
In `config/cable.yml`
116+
117+
```diff
118+
development:
119+
- adapter: async
120+
+ adapter: solid_cable
121+
+ connects_to:
122+
+ database:
123+
+ writing: cable
124+
+ polling_interval: 0.1.seconds
125+
+ message_retention: 1.day
126+
```
127+
128+
In `config/database.yml`
129+
130+
```diff
131+
development:
132+
primary:
133+
<<: *default
134+
database: storage/development.sqlite3
135+
+ cable:
136+
+ <<: *default
137+
+ database: storage/development_cable.sqlite3
138+
+ migrations_paths: db/cable_migrate
139+
```
81140

82141
### Single database configuration
83142

@@ -111,6 +170,7 @@ Solid Queue was designed for the highest throughput when used with MySQL 8+ or P
111170
### Workers, dispatchers and scheduler
112171

113172
We have several types of actors in Solid Queue:
173+
114174
- _Workers_ are in charge of picking jobs ready to run from queues and processing them. They work off the `solid_queue_ready_executions` table.
115175
- _Dispatchers_ are in charge of selecting jobs scheduled to run in the future that are due and _dispatching_ them, which is simply moving them from the `solid_queue_scheduled_executions` table over to the `solid_queue_ready_executions` table so that workers can pick them up. On top of that, they do some maintenance work related to [concurrency controls](#concurrency-controls).
116176
- The _scheduler_ manages [recurring tasks](#recurring-tasks), enqueuing jobs for them when they're due.
@@ -124,7 +184,6 @@ By default, Solid Queue will try to find your configuration under `config/queue.
124184
bin/jobs -c config/calendar.yml
125185
```
126186

127-
128187
This is what this configuration looks like:
129188

130189
```yml

0 commit comments

Comments
 (0)