openfeature-sdk 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.release-please-manifest.json +1 -1
- data/.ruby-version +1 -1
- data/.tool-versions +1 -1
- data/CHANGELOG.md +24 -0
- data/Gemfile.lock +1 -1
- data/lib/open_feature/sdk/client.rb +1 -1
- data/lib/open_feature/sdk/configuration.rb +8 -5
- data/lib/open_feature/sdk/hooks/hints.rb +32 -0
- data/lib/open_feature/sdk/provider/error_code.rb +8 -7
- data/lib/open_feature/sdk/provider/in_memory_provider.rb +10 -2
- data/lib/open_feature/sdk/provider/no_op_provider.rb +8 -0
- data/lib/open_feature/sdk/provider/reason.rb +9 -9
- data/lib/open_feature/sdk/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 121bf1c0f068a672898b818d3241b8a62eb31bfc16b5c777064b509c05c75ffa
|
4
|
+
data.tar.gz: e48cd05f98c6cc4c54697d716ea6c3fcee273b602de2fdf743a3bfb2b7cc65c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60bea62f478cc58a7a5b4a5defc6b51fc1dc9af83770102ef49ad26d3604d25ceb76f2752edbfdec6d598c8ee0f7aaefb6d8ded5d437ab1e041c921438b5be71
|
7
|
+
data.tar.gz: b13c80c92cbafe9902f445e9bbd170cec6ca4fd2a73c86f72bfaf7c09cd208ef75ba27b6f69f9a72d58a0f59bf1b65f44275abb27b18493029524661697d6f64
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.3.
|
1
|
+
3.3.3
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 3.3.
|
1
|
+
ruby 3.3.3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.4.0](https://github.com/open-feature/ruby-sdk/compare/v0.3.1...v0.4.0) (2024-06-13)
|
4
|
+
|
5
|
+
|
6
|
+
### ⚠ BREAKING CHANGES
|
7
|
+
|
8
|
+
* Use strings from spec for error and reason enums ([#131](https://github.com/open-feature/ruby-sdk/issues/131))
|
9
|
+
|
10
|
+
### Features
|
11
|
+
|
12
|
+
* add hook hints ([#135](https://github.com/open-feature/ruby-sdk/issues/135)) ([51155a7](https://github.com/open-feature/ruby-sdk/commit/51155a7d9cd2c28b38accb9d9b49018bd4868040))
|
13
|
+
* Use strings from spec for error and reason enums ([#131](https://github.com/open-feature/ruby-sdk/issues/131)) ([cb2a4cd](https://github.com/open-feature/ruby-sdk/commit/cb2a4cd54059ffe7ed3484be6705ca2a9d590c1a))
|
14
|
+
|
15
|
+
|
16
|
+
### Bug Fixes
|
17
|
+
|
18
|
+
* synchronize provider registration ([#136](https://github.com/open-feature/ruby-sdk/issues/136)) ([1ff6fd0](https://github.com/open-feature/ruby-sdk/commit/1ff6fd0c3732e9e074c8b30cbe4164a67286b0a4))
|
19
|
+
|
20
|
+
## [0.3.1](https://github.com/open-feature/ruby-sdk/compare/v0.3.0...v0.3.1) (2024-04-22)
|
21
|
+
|
22
|
+
|
23
|
+
### Features
|
24
|
+
|
25
|
+
* add integer and float specific resolver methods ([#124](https://github.com/open-feature/ruby-sdk/issues/124)) ([eea9d17](https://github.com/open-feature/ruby-sdk/commit/eea9d17e5892064cec9d81bb0ef452e7e1761764))
|
26
|
+
|
3
27
|
## [0.3.0](https://github.com/open-feature/ruby-sdk/compare/v0.2.1...v0.3.0) (2024-04-05)
|
4
28
|
|
5
29
|
|
data/Gemfile.lock
CHANGED
@@ -5,7 +5,7 @@ module OpenFeature
|
|
5
5
|
# TODO: Write documentation
|
6
6
|
#
|
7
7
|
class Client
|
8
|
-
RESULT_TYPE = %i[boolean string number object].freeze
|
8
|
+
RESULT_TYPE = %i[boolean string number integer float object].freeze
|
9
9
|
SUFFIXES = %i[value details].freeze
|
10
10
|
|
11
11
|
attr_reader :metadata, :evaluation_context
|
@@ -16,6 +16,7 @@ module OpenFeature
|
|
16
16
|
def initialize
|
17
17
|
@hooks = []
|
18
18
|
@providers = {}
|
19
|
+
@provider_mutex = Mutex.new
|
19
20
|
end
|
20
21
|
|
21
22
|
def provider(domain: nil)
|
@@ -27,11 +28,13 @@ module OpenFeature
|
|
27
28
|
# 2. On the new provider, call `init`.
|
28
29
|
# 3. Finally, set the internal provider to the new provider
|
29
30
|
def set_provider(provider, domain: nil)
|
30
|
-
@
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
@provider_mutex.synchronize do
|
32
|
+
@providers[domain].shutdown if @providers[domain].respond_to?(:shutdown)
|
33
|
+
provider.init if provider.respond_to?(:init)
|
34
|
+
new_providers = @providers.dup
|
35
|
+
new_providers[domain] = provider
|
36
|
+
@providers = new_providers
|
37
|
+
end
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OpenFeature
|
4
|
+
module SDK
|
5
|
+
module Hooks
|
6
|
+
class Hints < DelegateClass(Hash)
|
7
|
+
ALLOWED_TYPES = [String, Symbol, Numeric, TrueClass, FalseClass, Time, Hash, Array].freeze
|
8
|
+
|
9
|
+
def initialize(hash = {})
|
10
|
+
hash.each do |key, value|
|
11
|
+
assert_allowed_key(key)
|
12
|
+
assert_allowed_value(value)
|
13
|
+
end
|
14
|
+
@hash = hash.dup
|
15
|
+
super(@hash)
|
16
|
+
freeze
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def assert_allowed_key(key)
|
22
|
+
raise ArgumentError, "Only String or Symbol are allowed as keys." unless key.is_a?(String) || key.is_a?(Symbol)
|
23
|
+
end
|
24
|
+
|
25
|
+
def assert_allowed_value(value)
|
26
|
+
allowed_type = ALLOWED_TYPES.any? { |t| value.is_a?(t) }
|
27
|
+
raise ArgumentError, "Only #{ALLOWED_TYPES.join(", ")} are allowed as values." unless allowed_type
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -2,13 +2,14 @@ module OpenFeature
|
|
2
2
|
module SDK
|
3
3
|
module Provider
|
4
4
|
module ErrorCode
|
5
|
-
PROVIDER_NOT_READY = "
|
6
|
-
FLAG_NOT_FOUND = "
|
7
|
-
PARSE_ERROR = "
|
8
|
-
TYPE_MISMATCH = "
|
9
|
-
TARGETING_KEY_MISSING = "
|
10
|
-
INVALID_CONTEXT = "
|
11
|
-
|
5
|
+
PROVIDER_NOT_READY = "PROVIDER_NOT_READY"
|
6
|
+
FLAG_NOT_FOUND = "FLAG_NOT_FOUND"
|
7
|
+
PARSE_ERROR = "PARSE_ERROR"
|
8
|
+
TYPE_MISMATCH = "TYPE_MISMATCH"
|
9
|
+
TARGETING_KEY_MISSING = "TARGETING_KEY_MISSING"
|
10
|
+
INVALID_CONTEXT = "INVALID_CONTEXT"
|
11
|
+
PROVIDER_FATAL = "PROVIDER_FATAL"
|
12
|
+
GENERAL = "GENERAL"
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -34,7 +34,15 @@ module OpenFeature
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def fetch_number_value(flag_key:, default_value:, evaluation_context: nil)
|
37
|
-
fetch_value(allowed_classes: [
|
37
|
+
fetch_value(allowed_classes: [Numeric], flag_key:, default_value:, evaluation_context:)
|
38
|
+
end
|
39
|
+
|
40
|
+
def fetch_integer_value(flag_key:, default_value:, evaluation_context: nil)
|
41
|
+
fetch_value(allowed_classes: [Integer], flag_key:, default_value:, evaluation_context:)
|
42
|
+
end
|
43
|
+
|
44
|
+
def fetch_float_value(flag_key:, default_value:, evaluation_context: nil)
|
45
|
+
fetch_value(allowed_classes: [Float], flag_key:, default_value:, evaluation_context:)
|
38
46
|
end
|
39
47
|
|
40
48
|
def fetch_object_value(flag_key:, default_value:, evaluation_context: nil)
|
@@ -52,7 +60,7 @@ module OpenFeature
|
|
52
60
|
return ResolutionDetails.new(value: default_value, error_code: ErrorCode::FLAG_NOT_FOUND, reason: Reason::ERROR)
|
53
61
|
end
|
54
62
|
|
55
|
-
if allowed_classes.
|
63
|
+
if allowed_classes.any? { |klass| value.is_a?(klass) }
|
56
64
|
ResolutionDetails.new(value:, reason: Reason::STATIC)
|
57
65
|
else
|
58
66
|
ResolutionDetails.new(value: default_value, error_code: ErrorCode::TYPE_MISMATCH, reason: Reason::ERROR)
|
@@ -44,6 +44,14 @@ module OpenFeature
|
|
44
44
|
no_op(default_value)
|
45
45
|
end
|
46
46
|
|
47
|
+
def fetch_integer_value(flag_key:, default_value:, evaluation_context: nil)
|
48
|
+
no_op(default_value)
|
49
|
+
end
|
50
|
+
|
51
|
+
def fetch_float_value(flag_key:, default_value:, evaluation_context: nil)
|
52
|
+
no_op(default_value)
|
53
|
+
end
|
54
|
+
|
47
55
|
def fetch_object_value(flag_key:, default_value:, evaluation_context: nil)
|
48
56
|
no_op(default_value)
|
49
57
|
end
|
@@ -2,15 +2,15 @@ module OpenFeature
|
|
2
2
|
module SDK
|
3
3
|
module Provider
|
4
4
|
module Reason
|
5
|
-
STATIC = "
|
6
|
-
DEFAULT = "
|
7
|
-
TARGETING_MATCH = "
|
8
|
-
SPLIT = "
|
9
|
-
CACHED = "
|
10
|
-
DISABLED = "
|
11
|
-
UNKNOWN = "
|
12
|
-
STALE = "
|
13
|
-
ERROR = "
|
5
|
+
STATIC = "STATIC"
|
6
|
+
DEFAULT = "DEFAULT"
|
7
|
+
TARGETING_MATCH = "TARGETING_MATCH"
|
8
|
+
SPLIT = "SPLIT"
|
9
|
+
CACHED = "CACHED"
|
10
|
+
DISABLED = "DISABLED"
|
11
|
+
UNKNOWN = "UNKNOWN"
|
12
|
+
STALE = "STALE"
|
13
|
+
ERROR = "ERROR"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openfeature-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenFeature Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debug
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- lib/open_feature/sdk/evaluation_context.rb
|
153
153
|
- lib/open_feature/sdk/evaluation_context_builder.rb
|
154
154
|
- lib/open_feature/sdk/evaluation_details.rb
|
155
|
+
- lib/open_feature/sdk/hooks/hints.rb
|
155
156
|
- lib/open_feature/sdk/provider.rb
|
156
157
|
- lib/open_feature/sdk/provider/error_code.rb
|
157
158
|
- lib/open_feature/sdk/provider/in_memory_provider.rb
|
@@ -186,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
187
|
- !ruby/object:Gem::Version
|
187
188
|
version: '0'
|
188
189
|
requirements: []
|
189
|
-
rubygems_version: 3.5.
|
190
|
+
rubygems_version: 3.5.11
|
190
191
|
signing_key:
|
191
192
|
specification_version: 4
|
192
193
|
summary: OpenFeature SDK for Ruby
|