shoryuken 6.1.1 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: feeefb6a4aad595df6286c02928284e9403b0f0a81ba188f3fe399138dd8e32c
4
- data.tar.gz: a6dde4ed4a888f005580202bfd416fe2a41610fbc3c666efb31210cc2e831487
3
+ metadata.gz: f58520364e96d8d2d20cf583a062aba3565ca8cf742577498538fcfc76d5cc33
4
+ data.tar.gz: 6cbf5a7547b1c6fffd7155fe8963d4d55ea64aab831c5b6c972bbc5f6da6d244
5
5
  SHA512:
6
- metadata.gz: 39df6a6ff9f262e7e9337487d484433c2182b8c71eb6401bdf7e0798505993a8b1a80af00f034eccf3718fafc0ca616c83cf8c5937eebbf73333ea52578077aa
7
- data.tar.gz: 0bec3c731f75b848a6b7ddcc8eaba03331f71e2eb98687c9955ff9fc9b83196044771d182d07bb470d4a7b16070c7d06fe988561955942c740dd0eb89b4d4356
6
+ metadata.gz: 442b206899748e7758cfad575224b4975244ea502102f2a2221a3f1a2a1b4c018de5f7c21a4a06fb65d12ca841c7106488b43617f271484aff3681d8db038d53
7
+ data.tar.gz: 8da6672d08fafb6f61202b285b61b0da5ee380b5a51e22fd7868c7362926d6e7998d84327889af9f97767565ace9afaead43d7d128b9c0807318c2239e4cbac7
@@ -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,13 @@
1
+ ## [v6.2.0] - 2024-02-04
2
+
3
+ - Enable hot-reload via adding ActiveSupport::Reloader delegate (#756)
4
+ - [#756](https://github.com/ruby-shoryuken/shoryuken/pull/756)
5
+
6
+ ## [v6.1.2] - 2024-01-30
7
+
8
+ - Fix activerecord 7.1 deprecation warnings
9
+ - [#755](https://github.com/ruby-shoryuken/shoryuken/pull/755)
10
+
1
11
  ## [v6.1.1] - 2023-11-27
2
12
 
3
13
  - Fix SQS API Changes causing nil returns instead of empty arrays
@@ -7,21 +17,27 @@
7
17
  ## [v6.1.0] - 2023-11-01
8
18
 
9
19
  - Add GitHub Codespaces
20
+
10
21
  - [#698](https://github.com/ruby-shoryuken/shoryuken/pull/698)
11
22
 
12
23
  - Fix spec for ruby 3.0
24
+
13
25
  - [#727](https://github.com/ruby-shoryuken/shoryuken/pull/727)
14
26
 
15
27
  - Upgrade test matrix. Add Ruby 3.1, Ruby 3.2 and Rails 7
28
+
16
29
  - [#739](https://github.com/ruby-shoryuken/shoryuken/pull/739)
17
30
 
18
31
  - Fire stopped event after executor is stopped
32
+
19
33
  - [#741](https://github.com/ruby-shoryuken/shoryuken/pull/741)
20
34
 
21
35
  - Allow setup custom exception handlers for failing jobs
36
+
22
37
  - [#742](https://github.com/ruby-shoryuken/shoryuken/pull/742)
23
38
 
24
39
  - Configure dependabot to update GH Actions
40
+
25
41
  - [#745](https://github.com/ruby-shoryuken/shoryuken/pull/745)
26
42
 
27
43
  - Stop the dispatching of new messages when a SIGTERM signal has been received
@@ -36,6 +52,7 @@
36
52
  ## [v5.3.2] - 2022-01-19
37
53
 
38
54
  - (Bugfix) Preserve queue weights when unpausing queues
55
+
39
56
  - [#687](https://github.com/ruby-shoryuken/shoryuken/pull/687)
40
57
 
41
58
  - Improve error message on startup when shoryuken has insufficient permissions to access a queue
@@ -49,6 +66,7 @@
49
66
  ## [v5.3.0] - 2021-10-31
50
67
 
51
68
  - (Refactor) Use Forwardable within Message to avoid method boilerplate
69
+
52
70
  - [#681](https://github.com/ruby-shoryuken/shoryuken/pull/681)
53
71
 
54
72
  - Add basic health check API
@@ -67,13 +85,16 @@
67
85
  ## [v5.2.1] - 2021-04-06
68
86
 
69
87
  - Reduce message batch sizes in `shoryuken sqs requeue` and `shoryuken sqs mv` commands
88
+
70
89
  - [#666](https://github.com/ruby-shoryuken/shoryuken/pull/666)
71
90
 
72
91
  - Fix bug in `shoryuken sqs requeue` and `shoryuken sqs mv` where those commands would exceed the SQS `SendMessageBatch` maximum payload size
92
+
73
93
  - [#663](https://github.com/ruby-shoryuken/shoryuken/issues/663)
74
94
  - [#664](https://github.com/ruby-shoryuken/shoryuken/pull/664)
75
95
 
76
96
  - Remove test stub for `Concurrent.global_io_executor`
97
+
77
98
  - [#662](https://github.com/ruby-shoryuken/shoryuken/pull/662)
78
99
 
79
100
  - Run integration tests on CI
@@ -92,14 +113,17 @@
92
113
  ## [v5.1.0] - 2021-02-06
93
114
 
94
115
  - Add support for specifying SQS SendMessage parameters with ActiveJob `.set`
116
+
95
117
  - [#635](https://github.com/phstc/shoryuken/pull/635)
96
118
  - [#648](https://github.com/phstc/shoryuken/pull/648)
97
119
  - [#651](https://github.com/phstc/shoryuken/pull/651)
98
120
 
99
121
  - Unpause FIFO queues on worker completion
122
+
100
123
  - [#644](https://github.com/phstc/shoryuken/pull/644)
101
124
 
102
125
  - Add multiple versions of Rails to test matrix
126
+
103
127
  - [#647](https://github.com/phstc/shoryuken/pull/647)
104
128
 
105
129
  - Migrate from Travis CI to Github Actions
@@ -141,9 +165,11 @@
141
165
  ## [v5.0.0] - 2019-06-18
142
166
 
143
167
  - Fix bug where empty queues were not paused in batch processing mode
168
+
144
169
  - [#569](https://github.com/phstc/shoryuken/pull/569)
145
170
 
146
171
  - Preserve batch limit when receiving messages from a FIFO queue
172
+
147
173
  - [#563](https://github.com/phstc/shoryuken/pull/563)
148
174
 
149
175
  - Replace static options with instance options
@@ -157,9 +183,11 @@
157
183
  ## [v4.0.2] - 2018-11-26
158
184
 
159
185
  - Fix the delegated methods to public warning
186
+
160
187
  - [#536](https://github.com/phstc/shoryuken/pull/536)
161
188
 
162
189
  - Specify exception class to `raise_error` matcher warning
190
+
163
191
  - [#537](https://github.com/phstc/shoryuken/pull/537)
164
192
 
165
193
  - Fix spelling of "visibility"
@@ -168,6 +196,7 @@
168
196
  ## [v4.0.1] - 2018-11-21
169
197
 
170
198
  - Allow caching visibility_timeout lookups
199
+
171
200
  - [#533](https://github.com/phstc/shoryuken/pull/533)
172
201
 
173
202
  - Add queue name to inline executor
@@ -186,12 +215,15 @@
186
215
  ## [v3.3.0] - 2018-09-30
187
216
 
188
217
  - Add support for TSTP
218
+
189
219
  - [#492](https://github.com/phstc/shoryuken/pull/492)
190
220
 
191
221
  - Support an empty list of queues as a CLI argument
222
+
192
223
  - [#507](https://github.com/phstc/shoryuken/pull/507)
193
224
 
194
225
  - Add batch support for inline workers
226
+
195
227
  - [#514](https://github.com/phstc/shoryuken/pull/514)
196
228
 
197
229
  - Make InlineExecutor to behave as the DefaultExecutor when calling perform_in
@@ -200,9 +232,11 @@
200
232
  ## [v3.2.3] - 2018-03-25
201
233
 
202
234
  - Don't force eager load for Rails 5
235
+
203
236
  - [#480](https://github.com/phstc/shoryuken/pull/480)
204
237
 
205
238
  - Allow Batch Size to be Specified for Requeue
239
+
206
240
  - [#478](https://github.com/phstc/shoryuken/pull/478)
207
241
 
208
242
  - Support FIFO queues in `shoryuken sqs` commands
@@ -216,9 +250,11 @@
216
250
  ## [v3.2.1] - 2018-02-12
217
251
 
218
252
  - Support FIFO queues in `shoryuken sqs` commands
253
+
219
254
  - [#473](https://github.com/phstc/shoryuken/pull/473)
220
255
 
221
256
  - Allow customizing the default executor launcher
257
+
222
258
  - [#469](https://github.com/phstc/shoryuken/pull/469)
223
259
 
224
260
  - Exclude job_id from message deduplication when ActiveJob
@@ -227,9 +263,11 @@
227
263
  ## [v3.2.0] - 2018-01-03
228
264
 
229
265
  - Preserve parent worker class options
266
+
230
267
  - [#451](https://github.com/phstc/shoryuken/pull/451)
231
268
 
232
269
  - Add -t (shutdown timeout) option to CL
270
+
233
271
  - [#449](https://github.com/phstc/shoryuken/pull/449)
234
272
 
235
273
  - Support inline (Active Job like) for standard workers
@@ -253,6 +291,7 @@
253
291
  ## [v3.1.9] - 2017-08-24
254
292
 
255
293
  - Add support for adding a middleware to the front of chain
294
+
256
295
  - [#427](https://github.com/phstc/shoryuken/pull/427)
257
296
 
258
297
  - Add support for dispatch fire event
@@ -266,9 +305,11 @@
266
305
  ## [v3.1.7] - 2017-07-31
267
306
 
268
307
  - Allow polling strategy per group
308
+
269
309
  - [#417](https://github.com/phstc/shoryuken/pull/417)
270
310
 
271
311
  - Add support for creating FIFO queues
312
+
272
313
  - [#419](https://github.com/phstc/shoryuken/pull/419)
273
314
 
274
315
  - Allow receive message options per queue
@@ -282,6 +323,7 @@
282
323
  ## [v3.1.5] - 2017-07-23
283
324
 
284
325
  - Fix memory leak
326
+
285
327
  - [#414](https://github.com/phstc/shoryuken/pull/414)
286
328
 
287
329
  - Fail fast on bad queue URLs
@@ -295,6 +337,7 @@
295
337
  ## [v3.1.3] - 2017-07-11
296
338
 
297
339
  - Add queue prefixing support for groups
340
+
298
341
  - [#405](https://github.com/phstc/shoryuken/pull/405)
299
342
 
300
343
  - Remove dead code
@@ -308,6 +351,7 @@
308
351
  ## [v3.1.1] - 2017-07-05
309
352
 
310
353
  - Reduce log verbosity introduced in 3.1.0
354
+
311
355
  - [#397](https://github.com/phstc/shoryuken/pull/397)
312
356
 
313
357
  - Try to prevent stack level too deep on Ubuntu
@@ -316,9 +360,11 @@
316
360
  ## [v3.1.0] - 2017-07-02
317
361
 
318
362
  - Add shoryuken sqs delete command
363
+
319
364
  - [#395](https://github.com/phstc/shoryuken/pull/395)
320
365
 
321
366
  - Add processing groups support; Concurrency per queue support
367
+
322
368
  - [#389](https://github.com/phstc/shoryuken/pull/389)
323
369
 
324
370
  - Terminate Shoryuken if the fetcher crashes
@@ -332,6 +378,7 @@
332
378
  ## [v3.0.10] - 2017-06-24
333
379
 
334
380
  - Allow aws sdk v3
381
+
335
382
  - [#381](https://github.com/phstc/shoryuken/pull/381)
336
383
 
337
384
  - Allow configuring Rails via the config file
@@ -345,9 +392,11 @@
345
392
  ## [v3.0.8] - 2017-06-02
346
393
 
347
394
  - Fix miss handling empty batch fetches
395
+
348
396
  - [#376](https://github.com/phstc/shoryuken/pull/376)
349
397
 
350
398
  - Various minor styling changes :lipstick:
399
+
351
400
  - [#373](https://github.com/phstc/shoryuken/pull/373)
352
401
 
353
402
  - Logout when batch delete returns any failure
@@ -356,9 +405,11 @@
356
405
  ## [v3.0.7] - 2017-05-18
357
406
 
358
407
  - Trigger events for dispatch
408
+
359
409
  - [#362](https://github.com/phstc/shoryuken/pull/362)
360
410
 
361
411
  - Log (warn) exponential backoff tries
412
+
362
413
  - [#365](https://github.com/phstc/shoryuken/pull/365)
363
414
 
364
415
  - Fix displaying of long queue names in `shoryuken sqs ls`
@@ -372,12 +423,15 @@
372
423
  ## [v3.0.5] - 2017-04-09
373
424
 
374
425
  - Pause endless dispatcher to avoid CPU overload
426
+
375
427
  - [#354](https://github.com/phstc/shoryuken/pull/354)
376
428
 
377
429
  - Auto log processor errors
430
+
378
431
  - [#355](https://github.com/phstc/shoryuken/pull/355)
379
432
 
380
433
  - Add a delay as a CLI param
434
+
381
435
  - [#350](https://github.com/phstc/shoryuken/pull/350)
382
436
 
383
437
  - Add `sqs purge` command. See https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_PurgeQueue.html
@@ -386,6 +440,7 @@
386
440
  ## [v3.0.4] - 2017-03-24
387
441
 
388
442
  - Add `sqs purge` command. See https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_PurgeQueue.html
443
+
389
444
  - [#344](https://github.com/phstc/shoryuken/pull/344)
390
445
 
391
446
  - Fix "Thread exhaustion" error. This issue was most noticed when using long polling. @waynerobinson :beers: for pairing up on this.
@@ -409,18 +464,23 @@
409
464
  ## [v3.0.0] - 2017-03-12
410
465
 
411
466
  - Replace Celluloid with Concurrent Ruby
467
+
412
468
  - [#291](https://github.com/phstc/shoryuken/pull/291)
413
469
 
414
470
  - 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
471
+
415
472
  - [#317](https://github.com/phstc/shoryuken/pull/317)
416
473
 
417
474
  - Remove deprecation warnings
475
+
418
476
  - [#326](https://github.com/phstc/shoryuken/pull/326)
419
477
 
420
478
  - Allow dynamic adding queues
479
+
421
480
  - [#322](https://github.com/phstc/shoryuken/pull/322)
422
481
 
423
482
  - Support retry_intervals passed in as a lambda. Auto coerce intervals into integer
483
+
424
484
  - [#329](https://github.com/phstc/shoryuken/pull/329)
425
485
 
426
486
  - Add SQS commands `shoryuken help sqs`, such as `ls`, `mv`, `dump` and `requeue`
@@ -429,9 +489,11 @@
429
489
  ## [v2.1.3] - 2017-01-27
430
490
 
431
491
  - Show a warn message when batch isn't supported
492
+
432
493
  - [#302](https://github.com/phstc/shoryuken/pull/302)
433
494
 
434
495
  - Require Celluloid ~> 17
496
+
435
497
  - [#305](https://github.com/phstc/shoryuken/pull/305)
436
498
 
437
499
  - Fix excessive logging when 0 messages found
@@ -440,18 +502,23 @@
440
502
  ## [v2.1.2] - 2016-12-22
441
503
 
442
504
  - Fix loading `logfile` from shoryuken.yml
505
+
443
506
  - [#296](https://github.com/phstc/shoryuken/pull/296)
444
507
 
445
508
  - Add support for Strict priority polling (pending documentation)
509
+
446
510
  - [#288](https://github.com/phstc/shoryuken/pull/288)
447
511
 
448
512
  - Add `test_workers` for end-to-end testing supporting
513
+
449
514
  - [#286](https://github.com/phstc/shoryuken/pull/286)
450
515
 
451
516
  - Update README documenting `configure_client` and `configure_server`
517
+
452
518
  - [#283](https://github.com/phstc/shoryuken/pull/283)
453
519
 
454
520
  - Fix memory leak caused by async tracking busy threads
521
+
455
522
  - [#289](https://github.com/phstc/shoryuken/pull/289)
456
523
 
457
524
  - Refactor fetcher, polling strategy and manager
@@ -465,24 +532,31 @@
465
532
  ## [v2.1.0] - 2016-12-03
466
533
 
467
534
  - Fix celluloid "running in BACKPORTED mode" warning
535
+
468
536
  - [#260](https://github.com/phstc/shoryuken/pull/260)
469
537
 
470
538
  - Allow setting the aws configuration in 'Shoryuken.configure_server'
539
+
471
540
  - [#252](https://github.com/phstc/shoryuken/pull/252)
472
541
 
473
542
  - Allow requiring a file or dir a through `-r`
543
+
474
544
  - [#248](https://github.com/phstc/shoryuken/pull/248)
475
545
 
476
546
  - Reduce info log verbosity
547
+
477
548
  - [#243](https://github.com/phstc/shoryuken/pull/243)
478
549
 
479
550
  - Fix auto extender when using ActiveJob
551
+
480
552
  - [#3213](https://github.com/phstc/shoryuken/pull/213)
481
553
 
482
554
  - Add FIFO queue support
555
+
483
556
  - [#272](https://github.com/phstc/shoryuken/issues/272)
484
557
 
485
558
  - Deprecates initialize_aws
559
+
486
560
  - [#269](https://github.com/phstc/shoryuken/pull/269)
487
561
 
488
562
  - [Other miscellaneous updates](https://github.com/phstc/shoryuken/compare/v2.0.11...v2.1.0)
@@ -510,22 +584,28 @@
510
584
  ## [v2.0.7] - 2016-06-06
511
585
 
512
586
  - Daemonize before loading environment
587
+
513
588
  - [#219](https://github.com/phstc/shoryuken/pull/219)
514
589
 
515
590
  - Fix initialization when using rails
591
+
516
592
  - [#197](https://github.com/phstc/shoryuken/pull/197)
517
593
 
518
594
  - Improve message fetching
595
+
519
596
  - [#214](https://github.com/phstc/shoryuken/pull/214)
520
597
  - [#f4640d9](https://github.com/phstc/shoryuken/commit/f4640d9)
521
598
 
522
599
  - Fix hard shutdown if there are some busy workers when signal received
600
+
523
601
  - [#215](https://github.com/phstc/shoryuken/pull/215)
524
602
 
525
603
  - Fix `rake console` task
604
+
526
605
  - [#208](https://github.com/phstc/shoryuken/pull/208)
527
606
 
528
607
  - Isolate `MessageVisibilityExtender` as new middleware
608
+
529
609
  - [#199](https://github.com/phstc/shoryuken/pull/190)
530
610
 
531
611
  - Fail on non-existent queues
@@ -539,6 +619,7 @@
539
619
  ## [v2.0.5] - 2016-04-17
540
620
 
541
621
  - Fix log initialization when using `Shoryuken::EnvironmentLoader#load`
622
+
542
623
  - [#191](https://github.com/phstc/shoryuken/pull/191)
543
624
 
544
625
  - Fix `enqueue_at` in the ActiveJob Adapter
@@ -547,12 +628,15 @@
547
628
  ## [v2.0.4] - 2016-02-04
548
629
 
549
630
  - Add Rails 3 support
631
+
550
632
  - [#175](https://github.com/phstc/shoryuken/pull/175)
551
633
 
552
634
  - Allow symbol as a queue name in shoryuken_options
635
+
553
636
  - [#177](https://github.com/phstc/shoryuken/pull/177)
554
637
 
555
638
  - Make sure bundler is always updated on Travis CI
639
+
556
640
  - [#176](https://github.com/phstc/shoryuken/pull/176)
557
641
 
558
642
  - Add Rails 5 compatibility
@@ -561,6 +645,7 @@
561
645
  ## [v2.0.3] - 2015-12-30
562
646
 
563
647
  - Allow multiple queues per worker
648
+
564
649
  - [#164](https://github.com/phstc/shoryuken/pull/164)
565
650
 
566
651
  - Fix typo
@@ -569,15 +654,19 @@
569
654
  ## [v2.0.2] - 2015-10-27
570
655
 
571
656
  - Fix warnings that are triggered in some cases with the raise_error matcher
657
+
572
658
  - [#144](https://github.com/phstc/shoryuken/pull/144)
573
659
 
574
660
  - Add lifecycle event registration support
661
+
575
662
  - [#141](https://github.com/phstc/shoryuken/pull/141)
576
663
 
577
664
  - Allow passing array of messages to send_messages
665
+
578
666
  - [#140](https://github.com/phstc/shoryuken/pull/140)
579
667
 
580
668
  - Fix Active Job queue prefixing in Rails apps
669
+
581
670
  - [#139](https://github.com/phstc/shoryuken/pull/139)
582
671
 
583
672
  - Enable override the default queue with a :queue option
@@ -591,9 +680,11 @@
591
680
  ## [v2.0.0] - 2015-09-22
592
681
 
593
682
  - Allow configuration of SQS/SNS endpoints via environment variables
683
+
594
684
  - [#130](https://github.com/phstc/shoryuken/pull/130)
595
685
 
596
686
  - Expose queue_name in the message object
687
+
597
688
  - [#127](https://github.com/phstc/shoryuken/pull/127)
598
689
 
599
690
  - 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
@@ -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.0'.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.0
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-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv