openfeature-sdk 0.3.1 → 0.4.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 +4 -4
- data/.release-please-manifest.json +1 -1
- data/.ruby-version +1 -1
- data/.tool-versions +1 -1
- data/CHANGELOG.md +17 -0
- data/Gemfile.lock +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/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,22 @@
|
|
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
|
+
|
3
20
|
## [0.3.1](https://github.com/open-feature/ruby-sdk/compare/v0.3.0...v0.3.1) (2024-04-22)
|
4
21
|
|
5
22
|
|
data/Gemfile.lock
CHANGED
@@ -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
|
@@ -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
|