rollout-redis 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d7d811416500c11c77ca8c8490d301c0ce266db5dc6e7967e07c25e435be454
4
- data.tar.gz: c8e76ea2823845c3c3ef2d1929e4e1e75d0f19688ac99b5e4a6e903dae3a57ec
3
+ metadata.gz: 3b85cb7955ab58bf0ede95038078e71e534db5e477af94d9af605b3c3f48aee3
4
+ data.tar.gz: a210b3007e3cc5f1bad76c3574b9729d138c5eec19df5ef4b620b29c56f7ba72
5
5
  SHA512:
6
- metadata.gz: e03a813c99336b16cdee142457f04e56a3cb12b8292f95034a583cd79ae12e97b9586db54cb3070d297bf762259acdb3a9026496124a1a6a40dbcf880fd4433d
7
- data.tar.gz: 632ad6cf617ba379149383ad21e1033d5c6c3c12f9f8de58b1c1465d1440e957760f7ac4c15c011886dd9b188c73f2387b16d7cc144f4ece16446183f8dfcc21
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
  [![Gem Version](https://badge.fury.io/rb/rollout-redis.svg)](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
@@ -46,6 +46,17 @@ class Rollout
46
46
  def errors
47
47
  @data[:errors] || 0
48
48
  end
49
+
50
+ def to_h
51
+ {
52
+ name: @name,
53
+ percentage: @percentage,
54
+ data: {
55
+ requests: requests,
56
+ errors: errors
57
+ }
58
+ }
59
+ end
49
60
 
50
61
  private
51
62
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Rollout
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
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
- "feature-rollout-redis:#{name}"
181
+ "#{key_prefix}:#{name}"
182
+ end
183
+
184
+ def key_prefix
185
+ "feature-rollout-redis"
169
186
  end
170
187
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollout-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Carlos García