catpm 0.1.1 → 0.1.2
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 +4 -4
- data/lib/catpm/flusher.rb +11 -10
- data/lib/catpm/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2a84d81e5f4bbf2dca6af9f3b1c91d18af2160e9a15e24c8093216be4b8c5e20
|
|
4
|
+
data.tar.gz: 347b9026049cb39becf4d7618996c3091ddc0243115efdf47e689c644ec03f89
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da7474f427ad062a4cad9098263adacc90df2835cc8e2425689363346e805ca3fa520870fe2366cb750ea0f47bb3579adc06872891c413a2bcb9bd9222467278
|
|
7
|
+
data.tar.gz: a1161b1475b8c45654a6e0833cc1884686adaf2bdb1de5293c8337085e5e290503399053a19d2c3d2ce1fce2c79cc7ec0b31ea5d0e31207ffaff3a32ce50710b
|
data/lib/catpm/flusher.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'concurrent'
|
|
4
|
-
|
|
5
3
|
module Catpm
|
|
6
4
|
class Flusher
|
|
7
5
|
attr_reader :running
|
|
@@ -13,26 +11,29 @@ module Catpm
|
|
|
13
11
|
@circuit = CircuitBreaker.new
|
|
14
12
|
@last_cleanup_at = Time.now
|
|
15
13
|
@running = false
|
|
16
|
-
@
|
|
14
|
+
@thread = nil
|
|
17
15
|
end
|
|
18
16
|
|
|
19
17
|
def start
|
|
20
18
|
return if @running
|
|
21
19
|
|
|
22
20
|
@running = true
|
|
23
|
-
@
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
@thread = Thread.new do
|
|
22
|
+
while @running
|
|
23
|
+
sleep(effective_interval)
|
|
24
|
+
flush_cycle if @running
|
|
25
|
+
end
|
|
26
|
+
rescue => e
|
|
27
|
+
Catpm.config.error_handler.call(e)
|
|
28
|
+
retry if @running
|
|
29
|
+
end
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
def stop(timeout: Catpm.config.shutdown_timeout)
|
|
31
33
|
return unless @running
|
|
32
34
|
|
|
33
35
|
@running = false
|
|
34
|
-
@
|
|
35
|
-
@timer&.wait_for_termination(timeout)
|
|
36
|
+
@thread&.join(timeout)
|
|
36
37
|
flush_cycle # Final flush
|
|
37
38
|
end
|
|
38
39
|
|
data/lib/catpm/version.rb
CHANGED