rudder-sdk-ruby 3.0.1 → 3.1.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '084150c87a3fde0078c943a043e13a6111027e769069116120a0bdb2abfb2919'
|
4
|
+
data.tar.gz: d47c206b6905e4534bc593d577ee5ad7739dcce0b00cea1b023d54fe97263f6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b327dda8c0f62e16975240e52db0da6ccd02ec9cd56ae193eb7a94bbd37259cbb5bcfff256efd9fa3b3b72318dfd42df137ed10b68f8ecbd5a4f7f7258615259
|
7
|
+
data.tar.gz: 327ea9a0761c08033c10dfea40510fbf9d52155217caf630b307fb302bc3b597ef5316853dd0221ae2a4da12979944197bcfeaa3851b9491a997097328183ff9
|
@@ -24,6 +24,7 @@ module Rudder
|
|
24
24
|
# @option opts [FixNum] :max_queue_size Maximum number of calls to be
|
25
25
|
# remain queued.
|
26
26
|
# @option opts [Proc] :on_error Handles error calls from the API.
|
27
|
+
# @option opts [Proc] :on_error_with_messages Handles error calls from the API, with failed messages.
|
27
28
|
def initialize(opts = {})
|
28
29
|
@config = Configuration.new(opts)
|
29
30
|
@queue = Queue.new
|
@@ -7,7 +7,7 @@ module Rudder
|
|
7
7
|
class Configuration
|
8
8
|
include Rudder::Analytics::Utils
|
9
9
|
|
10
|
-
attr_reader :write_key, :data_plane_url, :on_error, :stub, :gzip, :ssl, :batch_size, :test, :max_queue_size, :backoff_policy, :retries
|
10
|
+
attr_reader :write_key, :data_plane_url, :on_error, :on_error_with_messages, :stub, :gzip, :ssl, :batch_size, :test, :max_queue_size, :backoff_policy, :retries
|
11
11
|
|
12
12
|
def initialize(settings = {})
|
13
13
|
symbolized_settings = symbolize_keys(settings)
|
@@ -18,6 +18,7 @@ module Rudder
|
|
18
18
|
@max_queue_size = symbolized_settings[:max_queue_size] || Defaults::Queue::MAX_SIZE
|
19
19
|
@ssl = symbolized_settings[:ssl]
|
20
20
|
@on_error = symbolized_settings[:on_error] || proc { |status, error| }
|
21
|
+
@on_error_with_messages = symbolized_settings[:on_error_with_messages] || proc { |status, error, messages| }
|
21
22
|
@stub = symbolized_settings[:stub]
|
22
23
|
@batch_size = symbolized_settings[:batch_size] || Defaults::MessageBatch::MAX_SIZE
|
23
24
|
@gzip = symbolized_settings[:gzip]
|
@@ -26,7 +26,7 @@ module Rudder
|
|
26
26
|
message_json = message.to_json
|
27
27
|
# puts message_json
|
28
28
|
rescue StandardError => e
|
29
|
-
raise JSONGenerationError, "Serialization error: #{e}"
|
29
|
+
raise JSONGenerationError, "Serialization error: #{e} for message: #{message.inspect}"
|
30
30
|
end
|
31
31
|
|
32
32
|
message_json_size = message_json.bytesize
|
@@ -29,6 +29,7 @@ module Rudder
|
|
29
29
|
@write_key = config.write_key
|
30
30
|
@ssl = config.ssl
|
31
31
|
@on_error = config.on_error
|
32
|
+
@on_error_with_messages = config.on_error_with_messages
|
32
33
|
@batch = MessageBatch.new(config.batch_size)
|
33
34
|
@lock = Mutex.new
|
34
35
|
@transport = Transport.new(config)
|
@@ -46,7 +47,10 @@ module Rudder
|
|
46
47
|
|
47
48
|
# res = Request.new(:data_plane_url => @data_plane_url, :ssl => @ssl).post @write_key, @batch
|
48
49
|
res = @transport.send @write_key, @batch
|
49
|
-
|
50
|
+
unless res.status == 200
|
51
|
+
@on_error.call(res.status, res.error)
|
52
|
+
@on_error_with_messages.call(res.status, res.error, @batch.messages)
|
53
|
+
end
|
50
54
|
|
51
55
|
@lock.synchronize { @batch.clear }
|
52
56
|
end
|
@@ -66,6 +70,7 @@ module Rudder
|
|
66
70
|
@batch << @queue.pop
|
67
71
|
rescue MessageBatch::JSONGenerationError => e
|
68
72
|
@on_error.call(-1, e.to_s)
|
73
|
+
@on_error_with_messages.call(-1, e.to_s, [])
|
69
74
|
end
|
70
75
|
end
|
71
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rudder-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rudder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|