launchdarkly-server-sdk 7.0.3 → 7.1.0
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 +17 -0
- data/lib/ldclient-rb/ldclient.rb +1 -1
- data/lib/ldclient-rb/requestor.rb +3 -5
- data/lib/ldclient-rb/stream.rb +3 -1
- data/lib/ldclient-rb/util.rb +26 -0
- data/lib/ldclient-rb/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c7c60035c46d6e2284ad78f0f4e33637f804faf9c90229e09b9d7c5b64c3bf8
|
4
|
+
data.tar.gz: 38f330a730ce6459d7a50bf0afec0db47462afafa7f927f09a2978ae3bd1cf18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c15f778108d9fdc2d47b51846d068e553be322d4e072498368d9c8cc7161f2e15c8977ccc5dcf8e565a707d727029901bbd6e0a7780bb42c0407f21cbef959ec
|
7
|
+
data.tar.gz: c7eca9b4edb6c458b1a034161ca9adaac955d81155308c23f913c434cf02a6479e15a7df35ea9ae4cf4d5e21b288c485a3ef1c380f90d6e4581e8993a7bc1e37
|
data/lib/ldclient-rb/config.rb
CHANGED
@@ -57,6 +57,7 @@ module LaunchDarkly
|
|
57
57
|
# @option opts [#open] :socket_factory See {#socket_factory}.
|
58
58
|
# @option opts [BigSegmentsConfig] :big_segments See {#big_segments}.
|
59
59
|
# @option opts [Hash] :application See {#application}
|
60
|
+
# @option opts [String] :payload_filter_key See {#payload_filter_key}
|
60
61
|
#
|
61
62
|
def initialize(opts = {})
|
62
63
|
@base_uri = (opts[:base_uri] || Config.default_base_uri).chomp("/")
|
@@ -88,6 +89,7 @@ module LaunchDarkly
|
|
88
89
|
@socket_factory = opts[:socket_factory]
|
89
90
|
@big_segments = opts[:big_segments] || BigSegmentsConfig.new(store: nil)
|
90
91
|
@application = LaunchDarkly::Impl::Util.validate_application_info(opts[:application] || {}, @logger)
|
92
|
+
@payload_filter_key = opts[:payload_filter_key]
|
91
93
|
end
|
92
94
|
|
93
95
|
#
|
@@ -330,6 +332,21 @@ module LaunchDarkly
|
|
330
332
|
#
|
331
333
|
attr_reader :application
|
332
334
|
|
335
|
+
#
|
336
|
+
# LaunchDarkly Server SDKs historically downloaded all flag configuration and segments for a particular environment
|
337
|
+
# during initialization.
|
338
|
+
#
|
339
|
+
# For some customers, this is an unacceptably large amount of data, and has contributed to performance issues within
|
340
|
+
# their products.
|
341
|
+
#
|
342
|
+
# Filtered environments aim to solve this problem. By allowing customers to specify subsets of an environment's
|
343
|
+
# flags using a filter key, SDKs will initialize faster and use less memory.
|
344
|
+
#
|
345
|
+
# This payload filter key only applies to the default streaming and polling data sources. It will not affect TestData or FileData
|
346
|
+
# data sources, nor will it be applied to any data source provided through the {#data_source} config property.
|
347
|
+
#
|
348
|
+
attr_reader :payload_filter_key
|
349
|
+
|
333
350
|
#
|
334
351
|
# Set to true to opt out of sending diagnostics data.
|
335
352
|
#
|
data/lib/ldclient-rb/ldclient.rb
CHANGED
@@ -387,7 +387,7 @@ module LaunchDarkly
|
|
387
387
|
|
388
388
|
context = Impl::Context::make_context(context)
|
389
389
|
unless context.valid?
|
390
|
-
@config.logger.error { "[LDClient] Context was invalid for flag
|
390
|
+
@config.logger.error { "[LDClient] Context was invalid for evaluation of flag '#{key}' (#{context.error}); returning default value" }
|
391
391
|
detail = Evaluator.error_result(EvaluationReason::ERROR_USER_NOT_SPECIFIED, default)
|
392
392
|
return detail
|
393
393
|
end
|
@@ -43,12 +43,10 @@ module LaunchDarkly
|
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
-
def request_single_item(kind, path)
|
47
|
-
Impl::Model.deserialize(kind, make_request(path), @config.logger)
|
48
|
-
end
|
49
|
-
|
50
46
|
def make_request(path)
|
51
|
-
uri = URI(
|
47
|
+
uri = URI(
|
48
|
+
Util.add_payload_filter_key(@config.base_uri + path, @config)
|
49
|
+
)
|
52
50
|
headers = {}
|
53
51
|
Impl::Util.default_http_headers(@sdk_key, @config).each { |k, v| headers[k] = v }
|
54
52
|
headers["Connection"] = "keep-alive"
|
data/lib/ldclient-rb/stream.rb
CHANGED
@@ -51,7 +51,9 @@ module LaunchDarkly
|
|
51
51
|
reconnect_time: @config.initial_reconnect_delay,
|
52
52
|
}
|
53
53
|
log_connection_started
|
54
|
-
|
54
|
+
|
55
|
+
uri = Util.add_payload_filter_key(@config.stream_uri + "/all", @config)
|
56
|
+
@es = SSE::Client.new(uri, **opts) do |conn|
|
55
57
|
conn.on_event { |event| process_message(event) }
|
56
58
|
conn.on_error { |err|
|
57
59
|
log_connection_result(false)
|
data/lib/ldclient-rb/util.rb
CHANGED
@@ -4,6 +4,32 @@ require "http"
|
|
4
4
|
module LaunchDarkly
|
5
5
|
# @private
|
6
6
|
module Util
|
7
|
+
#
|
8
|
+
# Append the payload filter key query parameter to the provided URI.
|
9
|
+
#
|
10
|
+
# @param uri [String]
|
11
|
+
# @param config [Config]
|
12
|
+
# @return [String]
|
13
|
+
#
|
14
|
+
def self.add_payload_filter_key(uri, config)
|
15
|
+
return uri if config.payload_filter_key.nil?
|
16
|
+
|
17
|
+
unless config.payload_filter_key.is_a?(String) && !config.payload_filter_key.empty?
|
18
|
+
config.logger.warn { "[LDClient] Filter key must be a non-empty string. No filtering will be applied." }
|
19
|
+
return uri
|
20
|
+
end
|
21
|
+
|
22
|
+
begin
|
23
|
+
parsed = URI.parse(uri)
|
24
|
+
new_query_params = URI.decode_www_form(String(parsed.query)) << ["filter", config.payload_filter_key]
|
25
|
+
parsed.query = URI.encode_www_form(new_query_params)
|
26
|
+
parsed.to_s
|
27
|
+
rescue URI::InvalidURIError
|
28
|
+
config.logger.warn { "[LDClient] URI could not be parsed. No filtering will be applied." }
|
29
|
+
uri
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
7
33
|
def self.new_http_client(uri_s, config)
|
8
34
|
http_client_options = {}
|
9
35
|
if config.socket_factory
|
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: 7.0
|
4
|
+
version: 7.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LaunchDarkly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-dynamodb
|
@@ -338,7 +338,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
338
338
|
- !ruby/object:Gem::Version
|
339
339
|
version: '0'
|
340
340
|
requirements: []
|
341
|
-
rubygems_version: 3.4.
|
341
|
+
rubygems_version: 3.4.12
|
342
342
|
signing_key:
|
343
343
|
specification_version: 4
|
344
344
|
summary: LaunchDarkly SDK for Ruby
|