usps-support 0.2.48 → 0.2.49

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: eccae8acbe04df79930069ce8a386b4f0d8ddb1757731e0b2e75d32367e8c73a
4
- data.tar.gz: 67bf18bca51ff61bb7d720dcc48afe1e1599e7a4469ac291cab7f6babfd74814
3
+ metadata.gz: 5764f3cd03bbd09cf0cc9be4873c9ecba705c6f4a5676058a6577de01999a66f
4
+ data.tar.gz: 50784833a152814d04f12ad8785f2d4c6199b0b88af40ead54c7d0e8c6a0cdf9
5
5
  SHA512:
6
- metadata.gz: 0a6f6fb6a20f6537c8c22a30e5002943be03af6ef0ad22c8ab89c53d82b2e70efc9e2b37e497a7fccb379605b64d2dbc8c6d9c854a247f4977766684f4f4c354
7
- data.tar.gz: 10b196a6d9594e131b005d768e182c9056a3338a6dd5fb4837ec6ac3e4d18a5b225e143af9e806a8faaf22cabf4947ca974d6e2517dcf75275d2ac77815b9c22
6
+ metadata.gz: 1ad1f146fd493edbeb08d110abb5de5b825cb5ab93ef494c6f8e12b554615a056940acf8d9ef9a3f39f64fb6ea2adba5ac7f8870282cecd4dd838f2aa01547fd
7
+ data.tar.gz: 6d0a9a31c61db44949f1852853f53e2eb29b6b47cb2aa828398cdc1492f81d29c511d250eae688463a5f018b418a64949bd071bec798db7bd8ff23cb790b98db
@@ -23,6 +23,11 @@ module Usps
23
23
  NAMESPACE = 'USPS/HealthCheck'
24
24
  MAX_QUEUE = 1_000
25
25
 
26
+ # Exponential backoff bounds for the delivery thread, so a persistent failure (e.g. missing
27
+ # logs:CreateLogStream) throttles to one retry per MAX_BACKOFF instead of one per probe.
28
+ BASE_BACKOFF_SECONDS = 1
29
+ MAX_BACKOFF_SECONDS = 60
30
+
26
31
  class << self
27
32
  # Enqueue one probe's component results for delivery. Non-blocking; returns nil.
28
33
  # components: [{ label:, ok:, latency_ms:, error: }, ...]
@@ -82,10 +87,21 @@ module Usps
82
87
 
83
88
  def start_worker
84
89
  queue = Thread::Queue.new
85
- Thread.new { loop { ship(queue.pop) } }
90
+ Thread.new do
91
+ failures = 0
92
+ loop do
93
+ if ship(queue.pop)
94
+ failures = 0
95
+ else
96
+ failures += 1
97
+ sleep([BASE_BACKOFF_SECONDS * (2**(failures - 1)), MAX_BACKOFF_SECONDS].min)
98
+ end
99
+ end
100
+ end
86
101
  queue
87
102
  end
88
103
 
104
+ # Ships one probe's events; returns true on success, false (dropping the batch) on any error.
89
105
  def ship(item)
90
106
  ensure_stream
91
107
  client.put_log_events(
@@ -93,8 +109,10 @@ module Usps
93
109
  log_stream_name: stream_name,
94
110
  log_events: emf_events(**item)
95
111
  )
112
+ true
96
113
  rescue StandardError
97
- @stream_ensured = false # force a re-create next time; drop this batch
114
+ @stream_ensured = false # force a re-create next time
115
+ false
98
116
  end
99
117
 
100
118
  def client
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Support
5
- VERSION = '0.2.48'
5
+ VERSION = '0.2.49'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.48
4
+ version: 0.2.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander