shoryuken 6.1.1 → 6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: feeefb6a4aad595df6286c02928284e9403b0f0a81ba188f3fe399138dd8e32c
4
- data.tar.gz: a6dde4ed4a888f005580202bfd416fe2a41610fbc3c666efb31210cc2e831487
3
+ metadata.gz: 6168df5d49a143c56908e559afcaddc28f7416176881429069cd12680db867c6
4
+ data.tar.gz: 1c3a73c4e269457b29962f0a0ac9ba56093ab58cbfab7b00c9aa79c0eb7cb186
5
5
  SHA512:
6
- metadata.gz: 39df6a6ff9f262e7e9337487d484433c2182b8c71eb6401bdf7e0798505993a8b1a80af00f034eccf3718fafc0ca616c83cf8c5937eebbf73333ea52578077aa
7
- data.tar.gz: 0bec3c731f75b848a6b7ddcc8eaba03331f71e2eb98687c9955ff9fc9b83196044771d182d07bb470d4a7b16070c7d06fe988561955942c740dd0eb89b4d4356
6
+ metadata.gz: 3ba49924964a3c98336a3b68e008d831549247574d2f180c72e600bef1dfbcdfa142a863d5e49b100f226d6d5aaf3e0b00fc972968e0ec3502121f10661f9c10
7
+ data.tar.gz: 9cc7f3b45550ff308213ceb72f2098a0bd1ae868c4b1401fbe3fe1a0cb8b43467c347ac2b396e0bcb2148f1d9927a46da43951a8550d027c0e9ba28db0739840
@@ -10,7 +10,7 @@ jobs:
10
10
  issues: write
11
11
  pull-requests: write
12
12
  steps:
13
- - uses: actions/stale@v8
13
+ - uses: actions/stale@v9
14
14
  with:
15
15
  stale-issue-message: This issue is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon.
16
16
  stale-pr-message: This PR is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [v6.2.1] - 2024-02-09
2
+
3
+ - Bugfix: Not able to use extended polling strategy (#759)
4
+ - [#759](https://github.com/ruby-shoryuken/shoryuken/pull/759)
5
+
6
+ ## [v6.2.0] - 2024-02-04
7
+
8
+ - Enable hot-reload via adding ActiveSupport::Reloader delegate (#756)
9
+ - [#756](https://github.com/ruby-shoryuken/shoryuken/pull/756)
10
+
11
+ ## [v6.1.2] - 2024-01-30
12
+
13
+ - Fix activerecord 7.1 deprecation warnings
14
+ - [#755](https://github.com/ruby-shoryuken/shoryuken/pull/755)
15
+
1
16
  ## [v6.1.1] - 2023-11-27
2
17
 
3
18
  - Fix SQS API Changes causing nil returns instead of empty arrays
@@ -7,21 +22,27 @@
7
22
  ## [v6.1.0] - 2023-11-01
8
23
 
9
24
  - Add GitHub Codespaces
25
+
10
26
  - [#698](https://github.com/ruby-shoryuken/shoryuken/pull/698)
11
27
 
12
28
  - Fix spec for ruby 3.0
29
+
13
30
  - [#727](https://github.com/ruby-shoryuken/shoryuken/pull/727)
14
31
 
15
32
  - Upgrade test matrix. Add Ruby 3.1, Ruby 3.2 and Rails 7
33
+
16
34
  - [#739](https://github.com/ruby-shoryuken/shoryuken/pull/739)
17
35
 
18
36
  - Fire stopped event after executor is stopped
37
+
19
38
  - [#741](https://github.com/ruby-shoryuken/shoryuken/pull/741)
20
39
 
21
40
  - Allow setup custom exception handlers for failing jobs
41
+
22
42
  - [#742](https://github.com/ruby-shoryuken/shoryuken/pull/742)
23
43
 
24
44
  - Configure dependabot to update GH Actions
45
+
25
46
  - [#745](https://github.com/ruby-shoryuken/shoryuken/pull/745)
26
47
 
27
48
  - Stop the dispatching of new messages when a SIGTERM signal has been received
@@ -36,6 +57,7 @@
36
57
  ## [v5.3.2] - 2022-01-19
37
58
 
38
59
  - (Bugfix) Preserve queue weights when unpausing queues
60
+
39
61
  - [#687](https://github.com/ruby-shoryuken/shoryuken/pull/687)
40
62
 
41
63
  - Improve error message on startup when shoryuken has insufficient permissions to access a queue
@@ -49,6 +71,7 @@
49
71
  ## [v5.3.0] - 2021-10-31
50
72
 
51
73
  - (Refactor) Use Forwardable within Message to avoid method boilerplate
74
+
52
75
  - [#681](https://github.com/ruby-shoryuken/shoryuken/pull/681)
53
76
 
54
77
  - Add basic health check API
@@ -67,13 +90,16 @@
67
90
  ## [v5.2.1] - 2021-04-06
68
91
 
69
92
  - Reduce message batch sizes in `shoryuken sqs requeue` and `shoryuken sqs mv` commands
93
+
70
94
  - [#666](https://github.com/ruby-shoryuken/shoryuken/pull/666)
71
95
 
72
96
  - Fix bug in `shoryuken sqs requeue` and `shoryuken sqs mv` where those commands would exceed the SQS `SendMessageBatch` maximum payload size
97
+
73
98
  - [#663](https://github.com/ruby-shoryuken/shoryuken/issues/663)
74
99
  - [#664](https://github.com/ruby-shoryuken/shoryuken/pull/664)
75
100
 
76
101
  - Remove test stub for `Concurrent.global_io_executor`
102
+
77
103
  - [#662](https://github.com/ruby-shoryuken/shoryuken/pull/662)
78
104
 
79
105
  - Run integration tests on CI
@@ -92,14 +118,17 @@
92
118
  ## [v5.1.0] - 2021-02-06
93
119
 
94
120
  - Add support for specifying SQS SendMessage parameters with ActiveJob `.set`
121
+
95
122
  - [#635](https://github.com/phstc/shoryuken/pull/635)
96
123
  - [#648](https://github.com/phstc/shoryuken/pull/648)
97
124
  - [#651](https://github.com/phstc/shoryuken/pull/651)
98
125
 
99
126
  - Unpause FIFO queues on worker completion
127
+
100
128
  - [#644](https://github.com/phstc/shoryuken/pull/644)
101
129
 
102
130
  - Add multiple versions of Rails to test matrix
131
+
103
132
  - [#647](https://github.com/phstc/shoryuken/pull/647)
104
133
 
105
134
  - Migrate from Travis CI to Github Actions
@@ -141,9 +170,11 @@
141
170
  ## [v5.0.0] - 2019-06-18
142
171
 
143
172
  - Fix bug where empty queues were not paused in batch processing mode
173
+
144
174
  - [#569](https://github.com/phstc/shoryuken/pull/569)
145
175
 
146
176
  - Preserve batch limit when receiving messages from a FIFO queue
177
+
147
178
  - [#563](https://github.com/phstc/shoryuken/pull/563)
148
179
 
149
180
  - Replace static options with instance options
@@ -157,9 +188,11 @@
157
188
  ## [v4.0.2] - 2018-11-26
158
189
 
159
190
  - Fix the delegated methods to public warning
191
+
160
192
  - [#536](https://github.com/phstc/shoryuken/pull/536)
161
193
 
162
194
  - Specify exception class to `raise_error` matcher warning
195
+
163
196
  - [#537](https://github.com/phstc/shoryuken/pull/537)
164
197
 
165
198
  - Fix spelling of "visibility"
@@ -168,6 +201,7 @@
168
201
  ## [v4.0.1] - 2018-11-21
169
202
 
170
203
  - Allow caching visibility_timeout lookups
204
+
171
205
  - [#533](https://github.com/phstc/shoryuken/pull/533)
172
206
 
173
207
  - Add queue name to inline executor
@@ -186,12 +220,15 @@
186
220
  ## [v3.3.0] - 2018-09-30
187
221
 
188
222
  - Add support for TSTP
223
+
189
224
  - [#492](https://github.com/phstc/shoryuken/pull/492)
190
225
 
191
226
  - Support an empty list of queues as a CLI argument
227
+
192
228
  - [#507](https://github.com/phstc/shoryuken/pull/507)
193
229
 
194
230
  - Add batch support for inline workers
231
+
195
232
  - [#514](https://github.com/phstc/shoryuken/pull/514)
196
233
 
197
234
  - Make InlineExecutor to behave as the DefaultExecutor when calling perform_in
@@ -200,9 +237,11 @@
200
237
  ## [v3.2.3] - 2018-03-25
201
238
 
202
239
  - Don't force eager load for Rails 5
240
+
203
241
  - [#480](https://github.com/phstc/shoryuken/pull/480)
204
242
 
205
243
  - Allow Batch Size to be Specified for Requeue
244
+
206
245
  - [#478](https://github.com/phstc/shoryuken/pull/478)
207
246
 
208
247
  - Support FIFO queues in `shoryuken sqs` commands
@@ -216,9 +255,11 @@
216
255
  ## [v3.2.1] - 2018-02-12
217
256
 
218
257
  - Support FIFO queues in `shoryuken sqs` commands
258
+
219
259
  - [#473](https://github.com/phstc/shoryuken/pull/473)
220
260
 
221
261
  - Allow customizing the default executor launcher
262
+
222
263
  - [#469](https://github.com/phstc/shoryuken/pull/469)
223
264
 
224
265
  - Exclude job_id from message deduplication when ActiveJob
@@ -227,9 +268,11 @@
227
268
  ## [v3.2.0] - 2018-01-03
228
269
 
229
270
  - Preserve parent worker class options
271
+
230
272
  - [#451](https://github.com/phstc/shoryuken/pull/451)
231
273
 
232
274
  - Add -t (shutdown timeout) option to CL
275
+
233
276
  - [#449](https://github.com/phstc/shoryuken/pull/449)
234
277
 
235
278
  - Support inline (Active Job like) for standard workers
@@ -253,6 +296,7 @@
253
296
  ## [v3.1.9] - 2017-08-24
254
297
 
255
298
  - Add support for adding a middleware to the front of chain
299
+
256
300
  - [#427](https://github.com/phstc/shoryuken/pull/427)
257
301
 
258
302
  - Add support for dispatch fire event
@@ -266,9 +310,11 @@
266
310
  ## [v3.1.7] - 2017-07-31
267
311
 
268
312
  - Allow polling strategy per group
313
+
269
314
  - [#417](https://github.com/phstc/shoryuken/pull/417)
270
315
 
271
316
  - Add support for creating FIFO queues
317
+
272
318
  - [#419](https://github.com/phstc/shoryuken/pull/419)
273
319
 
274
320
  - Allow receive message options per queue
@@ -282,6 +328,7 @@
282
328
  ## [v3.1.5] - 2017-07-23
283
329
 
284
330
  - Fix memory leak
331
+
285
332
  - [#414](https://github.com/phstc/shoryuken/pull/414)
286
333
 
287
334
  - Fail fast on bad queue URLs
@@ -295,6 +342,7 @@
295
342
  ## [v3.1.3] - 2017-07-11
296
343
 
297
344
  - Add queue prefixing support for groups
345
+
298
346
  - [#405](https://github.com/phstc/shoryuken/pull/405)
299
347
 
300
348
  - Remove dead code
@@ -308,6 +356,7 @@
308
356
  ## [v3.1.1] - 2017-07-05
309
357
 
310
358
  - Reduce log verbosity introduced in 3.1.0
359
+
311
360
  - [#397](https://github.com/phstc/shoryuken/pull/397)
312
361
 
313
362
  - Try to prevent stack level too deep on Ubuntu
@@ -316,9 +365,11 @@
316
365
  ## [v3.1.0] - 2017-07-02
317
366
 
318
367
  - Add shoryuken sqs delete command
368
+
319
369
  - [#395](https://github.com/phstc/shoryuken/pull/395)
320
370
 
321
371
  - Add processing groups support; Concurrency per queue support
372
+
322
373
  - [#389](https://github.com/phstc/shoryuken/pull/389)
323
374
 
324
375
  - Terminate Shoryuken if the fetcher crashes
@@ -332,6 +383,7 @@
332
383
  ## [v3.0.10] - 2017-06-24
333
384
 
334
385
  - Allow aws sdk v3
386
+
335
387
  - [#381](https://github.com/phstc/shoryuken/pull/381)
336
388
 
337
389
  - Allow configuring Rails via the config file
@@ -345,9 +397,11 @@
345
397
  ## [v3.0.8] - 2017-06-02
346
398
 
347
399
  - Fix miss handling empty batch fetches
400
+
348
401
  - [#376](https://github.com/phstc/shoryuken/pull/376)
349
402
 
350
403
  - Various minor styling changes :lipstick:
404
+
351
405
  - [#373](https://github.com/phstc/shoryuken/pull/373)
352
406
 
353
407
  - Logout when batch delete returns any failure
@@ -356,9 +410,11 @@
356
410
  ## [v3.0.7] - 2017-05-18
357
411
 
358
412
  - Trigger events for dispatch
413
+
359
414
  - [#362](https://github.com/phstc/shoryuken/pull/362)
360
415
 
361
416
  - Log (warn) exponential backoff tries
417
+
362
418
  - [#365](https://github.com/phstc/shoryuken/pull/365)
363
419
 
364
420
  - Fix displaying of long queue names in `shoryuken sqs ls`
@@ -372,12 +428,15 @@
372
428
  ## [v3.0.5] - 2017-04-09
373
429
 
374
430
  - Pause endless dispatcher to avoid CPU overload
431
+
375
432
  - [#354](https://github.com/phstc/shoryuken/pull/354)
376
433
 
377
434
  - Auto log processor errors
435
+
378
436
  - [#355](https://github.com/phstc/shoryuken/pull/355)
379
437
 
380
438
  - Add a delay as a CLI param
439
+
381
440
  - [#350](https://github.com/phstc/shoryuken/pull/350)
382
441
 
383
442
  - Add `sqs purge` command. See https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_PurgeQueue.html
@@ -386,6 +445,7 @@
386
445
  ## [v3.0.4] - 2017-03-24
387
446
 
388
447
  - Add `sqs purge` command. See https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_PurgeQueue.html
448
+
389
449
  - [#344](https://github.com/phstc/shoryuken/pull/344)
390
450
 
391
451
  - Fix "Thread exhaustion" error. This issue was most noticed when using long polling. @waynerobinson :beers: for pairing up on this.
@@ -409,18 +469,23 @@
409
469
  ## [v3.0.0] - 2017-03-12
410
470
 
411
471
  - Replace Celluloid with Concurrent Ruby
472
+
412
473
  - [#291](https://github.com/phstc/shoryuken/pull/291)
413
474
 
414
475
  - Remove AWS configuration from Shoryuken. Now AWS should be configured from outside. Check [this](https://github.com/phstc/shoryuken/wiki/Configure-the-AWS-Client) for more details
476
+
415
477
  - [#317](https://github.com/phstc/shoryuken/pull/317)
416
478
 
417
479
  - Remove deprecation warnings
480
+
418
481
  - [#326](https://github.com/phstc/shoryuken/pull/326)
419
482
 
420
483
  - Allow dynamic adding queues
484
+
421
485
  - [#322](https://github.com/phstc/shoryuken/pull/322)
422
486
 
423
487
  - Support retry_intervals passed in as a lambda. Auto coerce intervals into integer
488
+
424
489
  - [#329](https://github.com/phstc/shoryuken/pull/329)
425
490
 
426
491
  - Add SQS commands `shoryuken help sqs`, such as `ls`, `mv`, `dump` and `requeue`
@@ -429,9 +494,11 @@
429
494
  ## [v2.1.3] - 2017-01-27
430
495
 
431
496
  - Show a warn message when batch isn't supported
497
+
432
498
  - [#302](https://github.com/phstc/shoryuken/pull/302)
433
499
 
434
500
  - Require Celluloid ~> 17
501
+
435
502
  - [#305](https://github.com/phstc/shoryuken/pull/305)
436
503
 
437
504
  - Fix excessive logging when 0 messages found
@@ -440,18 +507,23 @@
440
507
  ## [v2.1.2] - 2016-12-22
441
508
 
442
509
  - Fix loading `logfile` from shoryuken.yml
510
+
443
511
  - [#296](https://github.com/phstc/shoryuken/pull/296)
444
512
 
445
513
  - Add support for Strict priority polling (pending documentation)
514
+
446
515
  - [#288](https://github.com/phstc/shoryuken/pull/288)
447
516
 
448
517
  - Add `test_workers` for end-to-end testing supporting
518
+
449
519
  - [#286](https://github.com/phstc/shoryuken/pull/286)
450
520
 
451
521
  - Update README documenting `configure_client` and `configure_server`
522
+
452
523
  - [#283](https://github.com/phstc/shoryuken/pull/283)
453
524
 
454
525
  - Fix memory leak caused by async tracking busy threads
526
+
455
527
  - [#289](https://github.com/phstc/shoryuken/pull/289)
456
528
 
457
529
  - Refactor fetcher, polling strategy and manager
@@ -465,24 +537,31 @@
465
537
  ## [v2.1.0] - 2016-12-03
466
538
 
467
539
  - Fix celluloid "running in BACKPORTED mode" warning
540
+
468
541
  - [#260](https://github.com/phstc/shoryuken/pull/260)
469
542
 
470
543
  - Allow setting the aws configuration in 'Shoryuken.configure_server'
544
+
471
545
  - [#252](https://github.com/phstc/shoryuken/pull/252)
472
546
 
473
547
  - Allow requiring a file or dir a through `-r`
548
+
474
549
  - [#248](https://github.com/phstc/shoryuken/pull/248)
475
550
 
476
551
  - Reduce info log verbosity
552
+
477
553
  - [#243](https://github.com/phstc/shoryuken/pull/243)
478
554
 
479
555
  - Fix auto extender when using ActiveJob
556
+
480
557
  - [#3213](https://github.com/phstc/shoryuken/pull/213)
481
558
 
482
559
  - Add FIFO queue support
560
+
483
561
  - [#272](https://github.com/phstc/shoryuken/issues/272)
484
562
 
485
563
  - Deprecates initialize_aws
564
+
486
565
  - [#269](https://github.com/phstc/shoryuken/pull/269)
487
566
 
488
567
  - [Other miscellaneous updates](https://github.com/phstc/shoryuken/compare/v2.0.11...v2.1.0)
@@ -510,22 +589,28 @@
510
589
  ## [v2.0.7] - 2016-06-06
511
590
 
512
591
  - Daemonize before loading environment
592
+
513
593
  - [#219](https://github.com/phstc/shoryuken/pull/219)
514
594
 
515
595
  - Fix initialization when using rails
596
+
516
597
  - [#197](https://github.com/phstc/shoryuken/pull/197)
517
598
 
518
599
  - Improve message fetching
600
+
519
601
  - [#214](https://github.com/phstc/shoryuken/pull/214)
520
602
  - [#f4640d9](https://github.com/phstc/shoryuken/commit/f4640d9)
521
603
 
522
604
  - Fix hard shutdown if there are some busy workers when signal received
605
+
523
606
  - [#215](https://github.com/phstc/shoryuken/pull/215)
524
607
 
525
608
  - Fix `rake console` task
609
+
526
610
  - [#208](https://github.com/phstc/shoryuken/pull/208)
527
611
 
528
612
  - Isolate `MessageVisibilityExtender` as new middleware
613
+
529
614
  - [#199](https://github.com/phstc/shoryuken/pull/190)
530
615
 
531
616
  - Fail on non-existent queues
@@ -539,6 +624,7 @@
539
624
  ## [v2.0.5] - 2016-04-17
540
625
 
541
626
  - Fix log initialization when using `Shoryuken::EnvironmentLoader#load`
627
+
542
628
  - [#191](https://github.com/phstc/shoryuken/pull/191)
543
629
 
544
630
  - Fix `enqueue_at` in the ActiveJob Adapter
@@ -547,12 +633,15 @@
547
633
  ## [v2.0.4] - 2016-02-04
548
634
 
549
635
  - Add Rails 3 support
636
+
550
637
  - [#175](https://github.com/phstc/shoryuken/pull/175)
551
638
 
552
639
  - Allow symbol as a queue name in shoryuken_options
640
+
553
641
  - [#177](https://github.com/phstc/shoryuken/pull/177)
554
642
 
555
643
  - Make sure bundler is always updated on Travis CI
644
+
556
645
  - [#176](https://github.com/phstc/shoryuken/pull/176)
557
646
 
558
647
  - Add Rails 5 compatibility
@@ -561,6 +650,7 @@
561
650
  ## [v2.0.3] - 2015-12-30
562
651
 
563
652
  - Allow multiple queues per worker
653
+
564
654
  - [#164](https://github.com/phstc/shoryuken/pull/164)
565
655
 
566
656
  - Fix typo
@@ -569,15 +659,19 @@
569
659
  ## [v2.0.2] - 2015-10-27
570
660
 
571
661
  - Fix warnings that are triggered in some cases with the raise_error matcher
662
+
572
663
  - [#144](https://github.com/phstc/shoryuken/pull/144)
573
664
 
574
665
  - Add lifecycle event registration support
666
+
575
667
  - [#141](https://github.com/phstc/shoryuken/pull/141)
576
668
 
577
669
  - Allow passing array of messages to send_messages
670
+
578
671
  - [#140](https://github.com/phstc/shoryuken/pull/140)
579
672
 
580
673
  - Fix Active Job queue prefixing in Rails apps
674
+
581
675
  - [#139](https://github.com/phstc/shoryuken/pull/139)
582
676
 
583
677
  - Enable override the default queue with a :queue option
@@ -591,9 +685,11 @@
591
685
  ## [v2.0.0] - 2015-09-22
592
686
 
593
687
  - Allow configuration of SQS/SNS endpoints via environment variables
688
+
594
689
  - [#130](https://github.com/phstc/shoryuken/pull/130)
595
690
 
596
691
  - Expose queue_name in the message object
692
+
597
693
  - [#127](https://github.com/phstc/shoryuken/pull/127)
598
694
 
599
695
  - README updates
@@ -70,6 +70,13 @@ module Shoryuken
70
70
  ::Rails.application.config.eager_load = true
71
71
  end
72
72
  end
73
+ ::Rails::Application.initializer 'shoryuken.set_reloader_hook' do |app|
74
+ Shoryuken.reloader = proc do |&block|
75
+ app.reloader.wrap do
76
+ block.call
77
+ end
78
+ end
79
+ end
73
80
  if Shoryuken.active_job?
74
81
  require 'shoryuken/extensions/active_job_extensions'
75
82
  require 'shoryuken/extensions/active_job_adapter'
@@ -5,7 +5,11 @@ module Shoryuken
5
5
  def call(*_args)
6
6
  yield
7
7
  ensure
8
- ::ActiveRecord::Base.clear_active_connections!
8
+ if ::ActiveRecord.version >= Gem::Version.new('7.1')
9
+ ::ActiveRecord::Base.connection_handler.clear_active_connections!(:all)
10
+ else
11
+ ::ActiveRecord::Base.clear_active_connections!
12
+ end
9
13
  end
10
14
  end
11
15
  end
@@ -17,7 +17,7 @@ module Shoryuken
17
17
  }.freeze
18
18
 
19
19
  attr_accessor :active_job_queue_name_prefixing, :cache_visibility_timeout, :groups,
20
- :launcher_executor,
20
+ :launcher_executor, :reloader, :enable_reloading,
21
21
  :start_callback, :stop_callback, :worker_executor, :worker_registry, :exception_handlers
22
22
  attr_writer :default_worker_options, :sqs_client
23
23
  attr_reader :sqs_client_receive_message_opts
@@ -29,6 +29,8 @@ module Shoryuken
29
29
  self.active_job_queue_name_prefixing = false
30
30
  self.worker_executor = Worker::DefaultExecutor
31
31
  self.cache_visibility_timeout = false
32
+ self.reloader = proc { |&block| block.call }
33
+ self.enable_reloading ||= false
32
34
  # this is needed for keeping backward compatibility
33
35
  @sqs_client_receive_message_opts ||= {}
34
36
  end
@@ -65,10 +67,14 @@ module Shoryuken
65
67
  Polling::WeightedRoundRobin
66
68
  when 'StrictPriority'
67
69
  Polling::StrictPriority
70
+ when String
71
+ begin
72
+ Object.const_get(strategy)
73
+ rescue NameError
74
+ raise ArgumentError, "#{strategy} is not a valid polling_strategy"
75
+ end
68
76
  when Class
69
77
  strategy
70
- else
71
- raise ArgumentError, "#{strategy} is not a valid polling_strategy"
72
78
  end
73
79
  end
74
80
 
@@ -14,12 +14,21 @@ module Shoryuken
14
14
  end
15
15
 
16
16
  def process
17
- return logger.error { "No worker found for #{queue}" } unless worker
17
+ worker_perform = proc do
18
+ return logger.error { "No worker found for #{queue}" } unless worker
19
+ Shoryuken::Logging.with_context("#{worker_name(worker.class, sqs_msg, body)}/#{queue}/#{sqs_msg.message_id}") do
20
+ worker.class.server_middleware.invoke(worker, queue, sqs_msg, body) do
21
+ worker.perform(sqs_msg, body)
22
+ end
23
+ end
24
+ end
18
25
 
19
- Shoryuken::Logging.with_context("#{worker_name(worker.class, sqs_msg, body)}/#{queue}/#{sqs_msg.message_id}") do
20
- worker.class.server_middleware.invoke(worker, queue, sqs_msg, body) do
21
- worker.perform(sqs_msg, body)
26
+ if Shoryuken.enable_reloading
27
+ Shoryuken.reloader.call do
28
+ worker_perform.call
22
29
  end
30
+ else
31
+ worker_perform.call
23
32
  end
24
33
  rescue Exception => ex
25
34
  Array(Shoryuken.exception_handlers).each { |handler| handler.call(ex, queue, sqs_msg) }
@@ -1,3 +1,3 @@
1
1
  module Shoryuken
2
- VERSION = '6.1.1'.freeze
2
+ VERSION = '6.2.1'.freeze
3
3
  end
data/lib/shoryuken.rb CHANGED
@@ -91,6 +91,10 @@ module Shoryuken
91
91
  :on,
92
92
  :cache_visibility_timeout?,
93
93
  :cache_visibility_timeout=,
94
+ :reloader,
95
+ :reloader=,
96
+ :enable_reloading,
97
+ :enable_reloading=,
94
98
  :delay
95
99
  )
96
100
  end
@@ -159,5 +159,43 @@ RSpec.describe Shoryuken::Processor do
159
159
  subject.process
160
160
  end
161
161
  end
162
+
163
+ context 'when specifying a reloader' do
164
+ before do
165
+ Shoryuken.reloader = proc do |_|
166
+ TestWorker.new.called
167
+ end
168
+ end
169
+
170
+ after do
171
+ Shoryuken.reloader = proc { |&block| block.call }
172
+ end
173
+
174
+ context 'when reloader is enabled' do
175
+ before do
176
+ Shoryuken.enable_reloading = true
177
+ end
178
+
179
+ it 'wraps execution in reloader' do
180
+ expect_any_instance_of(TestWorker).to receive(:called)
181
+ expect_any_instance_of(TestWorker).to_not receive(:perform)
182
+
183
+ subject.process
184
+ end
185
+
186
+ after do
187
+ Shoryuken.enable_reloading = false
188
+ end
189
+ end
190
+
191
+ context 'when reloader is disabled' do
192
+ it 'does not wrap execution in reloader' do
193
+ expect_any_instance_of(TestWorker).to_not receive(:called)
194
+ expect_any_instance_of(TestWorker).to receive(:perform).with(sqs_msg, sqs_msg.body)
195
+
196
+ subject.process
197
+ end
198
+ end
199
+ end
162
200
  end
163
201
  end
@@ -17,14 +17,34 @@ describe 'Shoryuken::Util' do
17
17
 
18
18
  describe '#worker_name' do
19
19
  let(:sqs_msg) do
20
- double Shoryuken::Message, message_id: 'fc754df7-9cc2-4c41-96ca-5996a44b771e', message_attributes: {}
20
+ double Shoryuken::Message, message_id: 'fc754df7-9cc2-4c41-96ca-5996a44b771e', message_attributes: message_attributes
21
21
  end
22
22
 
23
- it 'returns Shoryuken worker name' do
24
- expect(subject.worker_name(TestWorker, sqs_msg)).to eq 'TestWorker'
23
+ context 'when has integration with ActiveJob' do
24
+ before do
25
+ allow(Shoryuken).to receive(:active_job?).and_return(true)
26
+ end
27
+
28
+ let(:message_attributes) do
29
+ { 'shoryuken_class' => { string_value: ActiveJob::QueueAdapters::ShoryukenAdapter::JobWrapper.to_s } }
30
+ end
31
+
32
+ let(:body) do
33
+ { 'job_class' => 'TestJob' }
34
+ end
35
+
36
+ it 'returns ActiveJob worker name' do
37
+ expect(subject.worker_name(TestWorker, sqs_msg, body)).to eq 'ActiveJob/TestJob'
38
+ end
25
39
  end
26
40
 
27
- it 'returns ActiveJob worker name'
41
+ context 'when has not integration with ActiveJob' do
42
+ let(:message_attributes) { {} }
43
+
44
+ it 'returns Shoryuken worker name' do
45
+ expect(subject.worker_name(TestWorker, sqs_msg)).to eq 'TestWorker'
46
+ end
47
+ end
28
48
  end
29
49
 
30
50
  describe '#fire_event' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoryuken
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.1
4
+ version: 6.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Cantero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-28 00:00:00.000000000 Z
11
+ date: 2024-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv