launchdarkly-server-sdk 8.6.0 → 8.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ldclient-rb/config.rb +21 -1
- data/lib/ldclient-rb/events.rb +1 -1
- data/lib/ldclient-rb/impl/event_sender.rb +13 -1
- data/lib/ldclient-rb/impl/util.rb +15 -0
- data/lib/ldclient-rb/util.rb +0 -5
- data/lib/ldclient-rb/version.rb +1 -1
- metadata +37 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1692535bf245c0627c6e08cb87f168b11d7518d895bf9faacb2858da227f9d70
|
4
|
+
data.tar.gz: fa60f044217ac286dd817b325ea87c431ce0399decc5ee84741638959b1a5697
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92fc2011f8a0a8ca594863155081e60abfdeec0be8d50a1ebf051ed0a7a97406eac7560a12cf9a5c2beed7de71b58ff0dc720569b67f65f2f582fb2f7b1528c0
|
7
|
+
data.tar.gz: e6a8b529997e0df8dfdf2a1b82c716211661bbeece2b50777146b5c6fdb7c8d97f69d23057ad6586b0730c9717fcb15b07a9808213da21ad7f9fbc91595c91f9
|
data/lib/ldclient-rb/config.rb
CHANGED
@@ -65,6 +65,7 @@ module LaunchDarkly
|
|
65
65
|
@all_attributes_private = opts[:all_attributes_private] || false
|
66
66
|
@private_attributes = opts[:private_attributes] || []
|
67
67
|
@send_events = opts.has_key?(:send_events) ? opts[:send_events] : Config.default_send_events
|
68
|
+
@compress_events = opts.has_key?(:compress_events) ? opts[:compress_events] : Config.default_compress_events
|
68
69
|
@context_keys_capacity = opts[:context_keys_capacity] || Config.default_context_keys_capacity
|
69
70
|
@context_keys_flush_interval = opts[:context_keys_flush_interval] || Config.default_context_keys_flush_interval
|
70
71
|
@data_source = opts[:data_source]
|
@@ -76,7 +77,7 @@ module LaunchDarkly
|
|
76
77
|
@socket_factory = opts[:socket_factory]
|
77
78
|
@big_segments = opts[:big_segments] || BigSegmentsConfig.new(store: nil)
|
78
79
|
@application = LaunchDarkly::Impl::Util.validate_application_info(opts[:application] || {}, @logger)
|
79
|
-
@payload_filter_key = opts[:payload_filter_key]
|
80
|
+
@payload_filter_key = LaunchDarkly::Impl::Util.validate_payload_filter_key(opts[:payload_filter_key] , @logger)
|
80
81
|
@hooks = (opts[:hooks] || []).keep_if { |hook| hook.is_a? Interfaces::Hooks::Hook }
|
81
82
|
@omit_anonymous_contexts = opts.has_key?(:omit_anonymous_contexts) && opts[:omit_anonymous_contexts]
|
82
83
|
@data_source_update_sink = nil
|
@@ -254,6 +255,17 @@ module LaunchDarkly
|
|
254
255
|
#
|
255
256
|
attr_reader :send_events
|
256
257
|
|
258
|
+
#
|
259
|
+
# Should the event payload sent to LaunchDarkly use gzip compression. By default this is false to prevent backward
|
260
|
+
# breaking compatibility issues with older versions of the relay proxy.
|
261
|
+
#
|
262
|
+
# Customers not using the relay proxy are strongly encouraged to enable this feature to reduce egress bandwidth
|
263
|
+
# cost.
|
264
|
+
#
|
265
|
+
# @return [Boolean]
|
266
|
+
#
|
267
|
+
attr_reader :compress_events
|
268
|
+
|
257
269
|
#
|
258
270
|
# The number of context keys that the event processor can remember at any one time. This reduces the
|
259
271
|
# amount of duplicate context details sent in analytics events.
|
@@ -539,6 +551,14 @@ module LaunchDarkly
|
|
539
551
|
true
|
540
552
|
end
|
541
553
|
|
554
|
+
#
|
555
|
+
# The default value for {#compress_events}.
|
556
|
+
# @return [Boolean] false
|
557
|
+
#
|
558
|
+
def self.default_compress_events
|
559
|
+
false
|
560
|
+
end
|
561
|
+
|
542
562
|
#
|
543
563
|
# The default value for {#context_keys_capacity}.
|
544
564
|
# @return [Integer] 1000
|
data/lib/ldclient-rb/events.rb
CHANGED
@@ -513,13 +513,13 @@ module LaunchDarkly
|
|
513
513
|
evaluation: {
|
514
514
|
key: event.key,
|
515
515
|
value: event.evaluation.value,
|
516
|
+
reason: event.evaluation.reason,
|
516
517
|
},
|
517
518
|
}
|
518
519
|
|
519
520
|
out[:evaluation][:version] = event.version unless event.version.nil?
|
520
521
|
out[:evaluation][:default] = event.default unless event.default.nil?
|
521
522
|
out[:evaluation][:variation] = event.evaluation.variation_index unless event.evaluation.variation_index.nil?
|
522
|
-
out[:evaluation][:reason] = event.evaluation.reason unless event.evaluation.reason.nil?
|
523
523
|
out[:samplingRatio] = event.sampling_ratio unless event.sampling_ratio.nil? || event.sampling_ratio == 1
|
524
524
|
|
525
525
|
measurements = []
|
@@ -2,6 +2,8 @@ require "ldclient-rb/impl/unbounded_pool"
|
|
2
2
|
|
3
3
|
require "securerandom"
|
4
4
|
require "http"
|
5
|
+
require "stringio"
|
6
|
+
require "zlib"
|
5
7
|
|
6
8
|
module LaunchDarkly
|
7
9
|
module Impl
|
@@ -42,14 +44,24 @@ module LaunchDarkly
|
|
42
44
|
@logger.debug { "[LDClient] sending #{description}: #{event_data}" }
|
43
45
|
headers = {}
|
44
46
|
headers["content-type"] = "application/json"
|
47
|
+
headers["content-encoding"] = "gzip" if @config.compress_events
|
45
48
|
Impl::Util.default_http_headers(@sdk_key, @config).each { |k, v| headers[k] = v }
|
46
49
|
unless is_diagnostic
|
47
50
|
headers["X-LaunchDarkly-Event-Schema"] = CURRENT_SCHEMA_VERSION.to_s
|
48
51
|
headers["X-LaunchDarkly-Payload-ID"] = payload_id
|
49
52
|
end
|
53
|
+
|
54
|
+
body = event_data
|
55
|
+
if @config.compress_events
|
56
|
+
gzip = Zlib::GzipWriter.new(StringIO.new)
|
57
|
+
gzip << event_data
|
58
|
+
|
59
|
+
body = gzip.close.string
|
60
|
+
end
|
61
|
+
|
50
62
|
response = http_client.request("POST", uri, {
|
51
63
|
headers: headers,
|
52
|
-
body:
|
64
|
+
body: body,
|
53
65
|
})
|
54
66
|
rescue StandardError => exn
|
55
67
|
@logger.warn { "[LDClient] Error sending events: #{exn.inspect}." }
|
@@ -75,6 +75,21 @@ module LaunchDarkly
|
|
75
75
|
version: validate_application_value(app[:version], :version, logger),
|
76
76
|
}
|
77
77
|
end
|
78
|
+
|
79
|
+
#
|
80
|
+
# @param value [String, nil]
|
81
|
+
# @param logger [Logger]
|
82
|
+
# @return [String, nil]
|
83
|
+
#
|
84
|
+
def self.validate_payload_filter_key(value, logger)
|
85
|
+
return nil if value.nil?
|
86
|
+
return value if value.is_a?(String) && /^[a-zA-Z0-9][._\-a-zA-Z0-9]*$/.match?(value)
|
87
|
+
|
88
|
+
logger.warn {
|
89
|
+
"Invalid payload filter configured, full environment will be fetched. Ensure the filter key is not empty and was copied correctly from LaunchDarkly settings."
|
90
|
+
}
|
91
|
+
nil
|
92
|
+
end
|
78
93
|
end
|
79
94
|
end
|
80
95
|
end
|
data/lib/ldclient-rb/util.rb
CHANGED
@@ -77,11 +77,6 @@ module LaunchDarkly
|
|
77
77
|
def self.add_payload_filter_key(uri, config)
|
78
78
|
return uri if config.payload_filter_key.nil?
|
79
79
|
|
80
|
-
unless config.payload_filter_key.is_a?(String) && !config.payload_filter_key.empty?
|
81
|
-
config.logger.warn { "[LDClient] Filter key must be a non-empty string. No filtering will be applied." }
|
82
|
-
return uri
|
83
|
-
end
|
84
|
-
|
85
80
|
begin
|
86
81
|
parsed = URI.parse(uri)
|
87
82
|
new_query_params = URI.decode_www_form(String(parsed.query)) << ["filter", config.payload_filter_key]
|
data/lib/ldclient-rb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: launchdarkly-server-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LaunchDarkly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-dynamodb
|
@@ -24,6 +24,26 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.57'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rexml
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.3'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 3.3.7
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.3'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 3.3.7
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
48
|
name: bundler
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -248,6 +268,20 @@ dependencies:
|
|
248
268
|
- - "~>"
|
249
269
|
- !ruby/object:Gem::Version
|
250
270
|
version: 0.1.2
|
271
|
+
- !ruby/object:Gem::Dependency
|
272
|
+
name: zlib
|
273
|
+
requirement: !ruby/object:Gem::Requirement
|
274
|
+
requirements:
|
275
|
+
- - "~>"
|
276
|
+
- !ruby/object:Gem::Version
|
277
|
+
version: '3.1'
|
278
|
+
type: :runtime
|
279
|
+
prerelease: false
|
280
|
+
version_requirements: !ruby/object:Gem::Requirement
|
281
|
+
requirements:
|
282
|
+
- - "~>"
|
283
|
+
- !ruby/object:Gem::Version
|
284
|
+
version: '3.1'
|
251
285
|
- !ruby/object:Gem::Dependency
|
252
286
|
name: json
|
253
287
|
requirement: !ruby/object:Gem::Requirement
|
@@ -376,7 +410,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
376
410
|
- !ruby/object:Gem::Version
|
377
411
|
version: '0'
|
378
412
|
requirements: []
|
379
|
-
rubygems_version: 3.5.
|
413
|
+
rubygems_version: 3.5.16
|
380
414
|
signing_key:
|
381
415
|
specification_version: 4
|
382
416
|
summary: LaunchDarkly SDK for Ruby
|