Commit 17326e55d5dbbd8a64e51a54e781066b0af60426
1 parent
e6e032f9
Exists in
master
and in
2 other branches
Prefer mode: :async in docs
Showing
2 changed files
with
15 additions
and
10 deletions
Show diff stats
README.md
... | ... | @@ -1453,7 +1453,7 @@ end |
1453 | 1453 | For large data sets, you can use background jobs to parallelize reindexing. |
1454 | 1454 | |
1455 | 1455 | ```ruby |
1456 | -Product.reindex(async: true) | |
1456 | +Product.reindex(mode: :async) | |
1457 | 1457 | # {index_name: "products_production_20170111210018065"} |
1458 | 1458 | ``` |
1459 | 1459 | |
... | ... | @@ -1478,7 +1478,7 @@ Searchkick.reindex_status(index_name) |
1478 | 1478 | You can also have Searchkick wait for reindexing to complete |
1479 | 1479 | |
1480 | 1480 | ```ruby |
1481 | -Product.reindex(async: {wait: true}) | |
1481 | +Product.reindex(mode: :async, wait: true) | |
1482 | 1482 | ``` |
1483 | 1483 | |
1484 | 1484 | You can use [ActiveJob::TrafficControl](https://github.com/nickelser/activejob-traffic_control) to control concurrency. Install the gem: |
... | ... | @@ -1504,7 +1504,7 @@ This will allow only 3 jobs to run at once. |
1504 | 1504 | You can specify a longer refresh interval while reindexing to increase performance. |
1505 | 1505 | |
1506 | 1506 | ```ruby |
1507 | -Product.reindex(async: true, refresh_interval: "30s") | |
1507 | +Product.reindex(mode: :async, refresh_interval: "30s") | |
1508 | 1508 | ``` |
1509 | 1509 | |
1510 | 1510 | **Note:** This only makes a noticable difference with parallel reindexing. | ... | ... |
test/reindex_test.rb
... | ... | @@ -161,7 +161,7 @@ class ReindexTest < Minitest::Test |
161 | 161 | store_names ["Product A"], reindex: false |
162 | 162 | reindex = nil |
163 | 163 | perform_enqueued_jobs do |
164 | - reindex = Product.reindex(async: true) | |
164 | + reindex = Product.reindex(mode: :async) | |
165 | 165 | assert_search "product", [], conversions: false |
166 | 166 | end |
167 | 167 | |
... | ... | @@ -180,7 +180,7 @@ class ReindexTest < Minitest::Test |
180 | 180 | |
181 | 181 | reindex = nil |
182 | 182 | perform_enqueued_jobs do |
183 | - reindex = Product.reindex(async: true) | |
183 | + reindex = Product.reindex(mode: :async) | |
184 | 184 | end |
185 | 185 | |
186 | 186 | index = Searchkick::Index.new(reindex[:index_name]) |
... | ... | @@ -194,7 +194,7 @@ class ReindexTest < Minitest::Test |
194 | 194 | store_names ["Product A"], reindex: false |
195 | 195 | |
196 | 196 | capture_io do |
197 | - Product.reindex(async: {wait: true}) | |
197 | + Product.reindex(mode: :async, wait: true) | |
198 | 198 | end |
199 | 199 | |
200 | 200 | assert_search "product", ["Product A"] |
... | ... | @@ -205,7 +205,7 @@ class ReindexTest < Minitest::Test |
205 | 205 | |
206 | 206 | reindex = nil |
207 | 207 | perform_enqueued_jobs do |
208 | - reindex = Sku.reindex(async: true) | |
208 | + reindex = Sku.reindex(mode: :async) | |
209 | 209 | assert_search "sku", [], conversions: false |
210 | 210 | end |
211 | 211 | |
... | ... | @@ -217,7 +217,7 @@ class ReindexTest < Minitest::Test |
217 | 217 | end |
218 | 218 | |
219 | 219 | def test_full_refresh_interval |
220 | - reindex = Product.reindex(refresh_interval: "30s", async: true, import: false) | |
220 | + reindex = Product.reindex(refresh_interval: "30s", mode: :async, import: false) | |
221 | 221 | index = Searchkick::Index.new(reindex[:index_name]) |
222 | 222 | assert_nil Product.search_index.refresh_interval |
223 | 223 | assert_equal "30s", index.refresh_interval |
... | ... | @@ -244,10 +244,15 @@ class ReindexTest < Minitest::Test |
244 | 244 | |
245 | 245 | def test_full_partial_async |
246 | 246 | store_names ["Product A"] |
247 | + Product.reindex(:search_name, mode: :async) | |
248 | + assert_search "product", ["Product A"] | |
249 | + end | |
250 | + | |
251 | + def test_wait_not_async | |
247 | 252 | error = assert_raises(ArgumentError) do |
248 | - Product.reindex(:search_name, async: true) | |
253 | + Product.reindex(wait: false) | |
249 | 254 | end |
250 | - assert_match "unsupported keywords: :async", error.message | |
255 | + assert_equal "wait only available in :async mode", error.message | |
251 | 256 | end |
252 | 257 | |
253 | 258 | def test_callbacks_false | ... | ... |