spikard 0.2.0 → 0.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.
@@ -1,27 +1,27 @@
1
- # frozen_string_literal: true
2
-
3
- module Spikard
4
- # Background job helpers.
5
- module Background
6
- module_function
7
-
8
- @queue = Queue.new
9
- @worker = Thread.new do
10
- loop do
11
- job = @queue.pop
12
- begin
13
- job.call
14
- rescue StandardError => e
15
- warn("[spikard.background] job failed: #{e.message}")
16
- end
17
- end
18
- end
19
-
20
- # Schedule a block to run after the response has been returned.
21
- def run(&block)
22
- raise ArgumentError, 'background.run requires a block' unless block
23
-
24
- @queue << block
25
- end
26
- end
27
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Spikard
4
+ # Background job helpers.
5
+ module Background
6
+ module_function
7
+
8
+ @queue = Queue.new
9
+ @worker = Thread.new do
10
+ loop do
11
+ job = @queue.pop
12
+ begin
13
+ job.call
14
+ rescue StandardError => e
15
+ warn("[spikard.background] job failed: #{e.message}")
16
+ end
17
+ end
18
+ end
19
+
20
+ # Schedule a block to run after the response has been returned.
21
+ def run(&block)
22
+ raise ArgumentError, 'background.run requires a block' unless block
23
+
24
+ @queue << block
25
+ end
26
+ end
27
+ end