ff-ruby-server-sdk 1.1.3 → 1.2.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: 91515d01fe58895653204c1eda4d36e0d48298afb8849104a92c8bcab341d9d4
4
- data.tar.gz: 2f9d430480d7b50071ade6b2ff20c8b6e6be9a82908abcfcc2f9d7bd620c435c
3
+ metadata.gz: 6887a6e72ac05dffee1a385833108097515b8f11a32df209a581d11b174b958c
4
+ data.tar.gz: dc8ba8218ad7951c2ecefc8f82df088a69dd713153d9c511c5fa9cf1c113fb72
5
5
  SHA512:
6
- metadata.gz: 5de27ffb1a3f4ee42dde0627a300becf96ca59cd8b38c87caddcc3f5ea481d4665db1c27c673ea325244381e735f2fdb0166153cf83925618662753871b4442d
7
- data.tar.gz: 817e2c49ea331c6629a8e6495f17a520219dab73e77deab535eda29a7d13d5cdc682fcaae0da00527d5ef08e0dc90f2ed2df4a2d1f78dabcb1ce28b552740ffd
6
+ metadata.gz: b99aa618e90bc98dcbb810ec32724d51d1d253b8b8d0857cf0e14cc2c04399f4253ff9d402eaf97c0f818bbf9b41bc82ada6cd105335b18ddd2009fb9a59dc66
7
+ data.tar.gz: 9bb2ab662306eed3d77e5220e465692d2c23f4b56887fac393ce5b6190479a00339f3f6b2cd3d918c726ff27cd2d4a11af3b1db5f1921d9148d89020c42020ce
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.2.0] ** BREAKING **
2
+
3
+ - [FFM-9804] - The percentage rollout hash algorithm was slightly different compared to other Feature Flags SDKs, which resulted
4
+ in a different bucket allocation for the same target. While the overall percentage distribution was correct with the previous
5
+ algorithm; this fix ensures that the same target will get the same allocation per SDK. We are marking as a breaking change
6
+ as existing targets may get different allocations in a percentage rollout flag.
7
+
1
8
  # [1.1.0]
2
9
 
3
10
  - [FFM-7285] - Remove Metrics queue and implement Map for better memory usage
data/Gemfile CHANGED
@@ -9,19 +9,19 @@ gem "minitest", "~> 5.0"
9
9
  gem "standard", "~> 1.3"
10
10
 
11
11
  # Caching support:
12
- gem "rufus-scheduler"
13
- gem "libcache"
14
- gem "jwt"
15
- gem "moneta"
12
+ gem "rufus-scheduler", "~> 3.8"
13
+ gem "libcache", "0.4.2"
14
+ gem "jwt", "~> 2.3"
15
+ gem "moneta", "~> 1.4"
16
16
 
17
17
  # SSE support:
18
- gem "rest-client"
18
+ gem "rest-client", "~> 2.1"
19
19
 
20
20
  # Concurrency support:
21
- gem "concurrent-ruby", "1.1.10", require: "concurrent"
21
+ gem "concurrent-ruby", "~> 1.1", require: "concurrent"
22
22
 
23
23
  # Evaluator dependencies:
24
- gem "murmurhash3"
24
+ gem "murmurhash3", "~> 0.1.6"
25
25
 
26
26
  gem "typhoeus"
27
27
 
@@ -181,20 +181,24 @@ class Evaluator < Evaluation
181
181
  end
182
182
 
183
183
  def get_normalized_number(property, bucket_by)
184
-
185
- joined = property.to_s + ":" + bucket_by.to_s
186
- hash = MurmurHash3::V32.str_hash(joined, joined.length)
184
+ joined = bucket_by.to_s + ":" + property.to_s
185
+ hash = MurmurHash3::V32.str_hash(joined, 0)
187
186
  (hash % 100) + 1
188
187
  end
189
188
 
190
189
  def is_enabled(target, bucket_by, percentage)
191
-
192
190
  property = get_attr_value(target, bucket_by)
193
191
 
194
- if property != nil
192
+ if property == nil
193
+ old_bb = bucket_by
194
+ bucket_by = "identifier"
195
+ property = get_attr_value(target, bucket_by)
196
+ SdkCodes.warn_bucket_by_attr_not_found @logger, old_bb, property
197
+ end
195
198
 
199
+ if property != nil
196
200
  bucket_id = get_normalized_number(property, bucket_by)
197
-
201
+ @logger.debug "MM3 percentage_check=%s bucket_by=%s value=%s bucket=%s" % [percentage, bucket_by, property, bucket_id]
198
202
  return percentage > 0 && bucket_id <= percentage
199
203
  end
200
204
 
@@ -206,13 +210,11 @@ class Evaluator < Evaluation
206
210
  if distribution != nil
207
211
 
208
212
  variation = nil
209
-
213
+ total_percentage = 0
210
214
  distribution.variations.each do |weighted_variation|
211
-
212
215
  variation = weighted_variation.variation
213
-
214
- if is_enabled(target, distribution.bucket_by, weighted_variation.weight)
215
-
216
+ total_percentage = total_percentage + weighted_variation.weight
217
+ if is_enabled(target, distribution.bucket_by, total_percentage)
216
218
  return variation
217
219
  end
218
220
  end
@@ -54,6 +54,13 @@ class SdkCodes
54
54
  logger.warn SdkCodes.sdk_err_msg(6001, "identifier=%s, target=%s, default=%s" % [identifier, target.identifier, default])
55
55
  end
56
56
 
57
+ def self.warn_bucket_by_attr_not_found(logger, attr_name, new_value)
58
+ if new_value == nil
59
+ new_value = "NOT FOUND"
60
+ end
61
+ logger.warn SdkCodes.sdk_err_msg(6002, "missing=%s, using value=%s" % [attr_name, new_value])
62
+ end
63
+
57
64
  private
58
65
 
59
66
  @map =
@@ -77,6 +84,7 @@ class SdkCodes
77
84
  # SDK_EVAL_6xxx
78
85
  6000 => "Evaluated variation successfully",
79
86
  6001 => "Default variation was served",
87
+ 6002 => "BucketBy attribute not found in target attributes, falling back to 'identifier':",
80
88
  # SDK_METRICS_7xxx
81
89
  7000 => "Metrics thread started",
82
90
  7001 => "Metrics thread exited",
@@ -12,7 +12,7 @@ class Target
12
12
 
13
13
  @name = name
14
14
  @identifier = identifier
15
- @attributes = attributes
15
+ @attributes = attributes == nil ? {} : attributes.transform_keys(&:to_sym)
16
16
  @is_private = is_private
17
17
  @private_attributes = Set[]
18
18
  end
@@ -5,7 +5,7 @@ module Ff
5
5
  module Server
6
6
  module Sdk
7
7
 
8
- VERSION = "1.1.3"
8
+ VERSION = "1.2.0"
9
9
  end
10
10
  end
11
11
  end
data/scripts/sdk_specs.sh CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/bin/bash
2
2
 
3
3
  export ff_ruby_sdk="ff-ruby-server-sdk"
4
- export ff_ruby_sdk_version="1.1.3"
4
+ export ff_ruby_sdk_version="1.2.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ff-ruby-server-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 'Miloš Vasić, cyr.: Милош Васић'
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-24 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -178,9 +178,6 @@ executables: []
178
178
  extensions: []
179
179
  extra_rdoc_files: []
180
180
  files:
181
- - ".idea/.gitignore"
182
- - ".run/example.run.xml"
183
- - ".run/sdk_test.rb.run.xml"
184
181
  - ".standard.yml"
185
182
  - CHANGELOG.md
186
183
  - Gemfile
data/.idea/.gitignore DELETED
File without changes
data/.run/example.run.xml DELETED
@@ -1,21 +0,0 @@
1
- <component name="ProjectRunConfigurationManager">
2
- <configuration default="false" name="example" type="RubyRunConfigurationType" factoryName="Ruby">
3
- <module name="ff-ruby-server-sdk" />
4
- <RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="" />
5
- <RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$MODULE_DIR$/lib/ff/ruby/server/sdk" />
6
- <RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
7
- <RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
8
- <RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
9
- <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
10
- <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
11
- <EXTENSION ID="RubyCoverageRunConfigurationExtension" track_test_folders="true" runner="rcov" ENABLE_BRANCH_COVERAGE="true" ENABLE_FORKED_COVERAGE="true">
12
- <COVERAGE_PATTERN ENABLED="true">
13
- <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
14
- </COVERAGE_PATTERN>
15
- </EXTENSION>
16
- <EXTENSION ID="org.jetbrains.plugins.ruby.rails.run.RailsRunConfigurationExtension" SCRATCH_USE_RAILS_RUNNER="false" />
17
- <RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$MODULE_DIR$/example/example.rb" />
18
- <RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
19
- <method v="2" />
20
- </configuration>
21
- </component>
@@ -1,33 +0,0 @@
1
- <component name="ProjectRunConfigurationManager">
2
- <configuration default="false" name="SDK test" type="TestUnitRunConfigurationType" factoryName="Test::Unit/Shoulda/Minitest">
3
- <module name="ff-ruby-server-sdk" />
4
- <predefined_log_file enabled="true" id="RUBY_TESTUNIT" />
5
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-Ilib:test" />
6
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
7
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
8
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
9
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
10
- <envs>
11
- <env name="JRUBY_OPTS" value="-X+O" />
12
- </envs>
13
- <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
14
- <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
15
- <EXTENSION ID="RubyCoverageRunConfigurationExtension" track_test_folders="true" runner="rcov" ENABLE_BRANCH_COVERAGE="true" ENABLE_FORKED_COVERAGE="true">
16
- <COVERAGE_PATTERN ENABLED="true">
17
- <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
18
- </COVERAGE_PATTERN>
19
- </EXTENSION>
20
- <EXTENSION ID="org.jetbrains.plugins.ruby.rails.run.RailsRunConfigurationExtension" SCRATCH_USE_RAILS_RUNNER="false" />
21
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
22
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/test/ff/ruby/server/sdk/sdk_test.rb" />
23
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPTS_PATHS" VALUE="$MODULE_DIR$/test/ff/ruby/server/sdk/sdk_test.rb" />
24
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="" />
25
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_METHOD_NAME" VALUE="" />
26
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="CUSTOM_SET_OF_FILES" />
27
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
28
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
29
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
30
- <RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_OPTIONS" VALUE="" />
31
- <method v="2" />
32
- </configuration>
33
- </component>