rollout-redis 0.1.0 → 0.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +17 -1
- data/lib/rollout/feature.rb +11 -0
- data/lib/rollout/version.rb +1 -1
- data/lib/rollout.rb +18 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b85cb7955ab58bf0ede95038078e71e534db5e477af94d9af605b3c3f48aee3
|
4
|
+
data.tar.gz: a210b3007e3cc5f1bad76c3574b9729d138c5eec19df5ef4b620b29c56f7ba72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb078df42c0404c25f3439635391751cc83b3ad90a3647fac163d42240cac7afefe376d4c7de50bd9eb8565bf724bf8288fec7823f81ae10d8eb894643cad852
|
7
|
+
data.tar.gz: f6a3a0c1da29db894c75fbb3b5516f9975ae6031fe0569b158ca3e5707dfa0bdd3fffe924da8bdaf6720501d75ac0073b99eea66bfb937393367f5a431e6a2e1
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
7
|
|
8
|
+
## [0.2.0] - 2023-10-23
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- `#features` method for listing all the feature flags stored in Redis
|
13
|
+
|
8
14
|
## [0.1.0] - 2023-10-23
|
9
15
|
|
10
16
|
- Initial version
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# rollout-redis
|
1
|
+
# rollout-redis ⛳️
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/rollout-redis)
|
4
4
|
|
@@ -67,6 +67,22 @@ If there is an issue, you have the option to disable a feature:
|
|
67
67
|
@rollout.deactivate('FEATURE_FLAG_NAME')
|
68
68
|
```
|
69
69
|
|
70
|
+
If you want to list all the stored feature flags, you can use the `features` method:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
@rollout.features
|
74
|
+
```
|
75
|
+
|
76
|
+
The response will be an array of hashes with all the information about the stored feature flags
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
[
|
80
|
+
{ name: 'a-feature-flag', percentage: 100, data: { requests: 50, errors: 1 } },
|
81
|
+
{ name: 'another-feature-flag', percentage: 20, data: { requests: 1, errors: 0 } },
|
82
|
+
{ name: 'super-feature-flag', percentage: 50, data: { requests: 828, errors: 34 } }
|
83
|
+
]
|
84
|
+
```
|
85
|
+
|
70
86
|
## Advanced features 🦾
|
71
87
|
|
72
88
|
### Gradual activation based on percentages
|
data/lib/rollout/feature.rb
CHANGED
data/lib/rollout/version.rb
CHANGED
data/lib/rollout.rb
CHANGED
@@ -78,6 +78,19 @@ class Rollout
|
|
78
78
|
raise e
|
79
79
|
end
|
80
80
|
|
81
|
+
def features
|
82
|
+
keys = @storage.keys("#{key_prefix}:*")
|
83
|
+
return [] if keys.empty?
|
84
|
+
|
85
|
+
keys.map do |key|
|
86
|
+
data = @storage.get(key)
|
87
|
+
next unless data
|
88
|
+
|
89
|
+
feature_name = key.gsub("#{key_prefix}:", '')
|
90
|
+
Feature.new(feature_name, JSON.parse(data, symbolize_names: true)).to_h
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
81
94
|
def clean_cache
|
82
95
|
return unless @cache_enabled
|
83
96
|
|
@@ -165,6 +178,10 @@ class Rollout
|
|
165
178
|
end
|
166
179
|
|
167
180
|
def key(name)
|
168
|
-
"
|
181
|
+
"#{key_prefix}:#{name}"
|
182
|
+
end
|
183
|
+
|
184
|
+
def key_prefix
|
185
|
+
"feature-rollout-redis"
|
169
186
|
end
|
170
187
|
end
|