feature_flagger 2.1.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -0
- data/lib/feature_flagger/configuration.rb +3 -7
- data/lib/feature_flagger/feature.rb +12 -0
- data/lib/feature_flagger/manifest_sources/storage_only.rb +13 -0
- data/lib/feature_flagger/manifest_sources/with_yaml_file.rb +14 -0
- data/lib/feature_flagger/manifest_sources/yaml_with_backup_to_storage.rb +18 -0
- data/lib/feature_flagger/model.rb +1 -1
- data/lib/feature_flagger/storage/redis.rb +13 -2
- data/lib/feature_flagger/version.rb +1 -1
- data/lib/feature_flagger.rb +3 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e47425945eb8f6c2d9313945998c30a8eea4a3d80c7a55d2bd0e614a486861e1
|
4
|
+
data.tar.gz: 8aa356e8674ec959b6f39fd0a58cf3af70f670093e41b9445be0797a5e521105
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d314b635d2a8aba39bd0b6d3e668a4cd624ad1ebab86978c4f904ec1ba947e5dd37a9285cb17c579b8d130402597d676e689898ebf540ba9da0946f9842b455b
|
7
|
+
data.tar.gz: a1ec62fad951f8c6b4a46eaf78192c7dcc4700a8557e36de205b4aca622882da48dacc27911bdce6a1d3402d104dc1f6373ee658ad2ca23964578b8e9992d673
|
data/README.md
CHANGED
@@ -161,6 +161,32 @@ to ensure the data stored in Redis storage is right. Check [#67](https://github.
|
|
161
161
|
|
162
162
|
$ bundle exec rake feature_flagger:migrate_to_resource_keys
|
163
163
|
|
164
|
+
## Extra options
|
165
|
+
|
166
|
+
There are a few options to store/retrieve your rollout manifest (a.k.a rollout.yml):
|
167
|
+
|
168
|
+
If you have a rollout.yml file and want to use Redis to keep a backup, add the follow code to the configuration block:
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
FeatureFlagger.configure do |config|
|
172
|
+
...
|
173
|
+
config.manifest_source = FeatureFlagger::ManifestSources::YAMLWithBackupToStorage.new(config.storage)
|
174
|
+
...
|
175
|
+
end
|
176
|
+
```
|
177
|
+
|
178
|
+
If you already have your manifest on Redis and prefer not to keep a copy in your application, add the following code to the configuration block:
|
179
|
+
|
180
|
+
```ruby
|
181
|
+
FeatureFlagger.configure do |config|
|
182
|
+
...
|
183
|
+
config.manifest_source = FeatureFlagger::ManifestSources::StorageOnly.new(config.storage)
|
184
|
+
...
|
185
|
+
end
|
186
|
+
```
|
187
|
+
|
188
|
+
If you have the YAML file and don't need a backup, it is unnecessary to do any different configuration.
|
189
|
+
|
164
190
|
## Contributing
|
165
191
|
|
166
192
|
Bug reports and pull requests are welcome!
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module FeatureFlagger
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :storage, :cache_store, :
|
3
|
+
attr_accessor :storage, :cache_store, :manifest_source, :notifier_callback
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@storage ||= Storage::Redis.default_client
|
7
|
-
@
|
7
|
+
@manifest_source ||= FeatureFlagger::ManifestSources::WithYamlFile.new
|
8
8
|
@notifier_callback = nil
|
9
9
|
@cache_store = nil
|
10
10
|
end
|
@@ -17,7 +17,7 @@ module FeatureFlagger
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def info
|
20
|
-
@
|
20
|
+
@manifest_source.resolved_info
|
21
21
|
end
|
22
22
|
|
23
23
|
def mapped_feature_keys(resource_name = nil)
|
@@ -29,10 +29,6 @@ module FeatureFlagger
|
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
|
-
def default_yaml_filepath
|
33
|
-
"#{Rails.root}/config/rollout.yml" if defined?(Rails)
|
34
|
-
end
|
35
|
-
|
36
32
|
def make_keys_recursively(hash, keys = [], composed_key = [])
|
37
33
|
unless hash.values[0].is_a?(Hash)
|
38
34
|
keys.push(composed_key)
|
@@ -10,6 +10,18 @@ module FeatureFlagger
|
|
10
10
|
@data['description']
|
11
11
|
end
|
12
12
|
|
13
|
+
def created_at
|
14
|
+
@data['created_at']
|
15
|
+
end
|
16
|
+
|
17
|
+
def owner
|
18
|
+
@data['owner']
|
19
|
+
end
|
20
|
+
|
21
|
+
def full_rollout_until
|
22
|
+
@data['full_rollout_until']
|
23
|
+
end
|
24
|
+
|
13
25
|
def key
|
14
26
|
@feature_key.join(':')
|
15
27
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module FeatureFlagger
|
2
|
+
module ManifestSources
|
3
|
+
class WithYamlFile
|
4
|
+
def initialize(yaml_path = nil)
|
5
|
+
@yaml_path = yaml_path
|
6
|
+
@yaml_path ||= "#{Rails.root}/config/rollout.yml" if defined?(Rails)
|
7
|
+
end
|
8
|
+
|
9
|
+
def resolved_info
|
10
|
+
@resolved_info ||= ::YAML.load_file(@yaml_path) if @yaml_path
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module FeatureFlagger
|
2
|
+
module ManifestSources
|
3
|
+
class YAMLWithBackupToStorage
|
4
|
+
def initialize(storage, yaml_path = nil)
|
5
|
+
@yaml_path = yaml_path || ("#{Rails.root}/config/rollout.yml" if defined?(Rails))
|
6
|
+
@storage = storage
|
7
|
+
end
|
8
|
+
|
9
|
+
def resolved_info
|
10
|
+
@resolved_info ||= begin
|
11
|
+
yaml_data = YAML.load_file(@yaml_path) if @yaml_path
|
12
|
+
@storage.write_manifest_backup(YAML.dump(yaml_data))
|
13
|
+
yaml_data
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -13,7 +13,7 @@ module FeatureFlagger
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def released?(*feature_key, **options)
|
16
|
-
self.class.released_id?(feature_flagger_identifier, feature_key, options)
|
16
|
+
self.class.released_id?(feature_flagger_identifier, *feature_key, **options)
|
17
17
|
end
|
18
18
|
|
19
19
|
def release(*feature_key)
|
@@ -5,8 +5,10 @@ require_relative './keys'
|
|
5
5
|
module FeatureFlagger
|
6
6
|
module Storage
|
7
7
|
class Redis
|
8
|
-
DEFAULT_NAMESPACE
|
9
|
-
RESOURCE_PREFIX
|
8
|
+
DEFAULT_NAMESPACE = :feature_flagger
|
9
|
+
RESOURCE_PREFIX = "_r".freeze
|
10
|
+
MANIFEST_PREFIX = "_m".freeze
|
11
|
+
MANIFEST_KEY = "manifest_file".freeze
|
10
12
|
SCAN_EACH_BATCH_SIZE = 1000.freeze
|
11
13
|
|
12
14
|
def initialize(redis)
|
@@ -75,6 +77,7 @@ module FeatureFlagger
|
|
75
77
|
# Reject keys related to feature responsible for return
|
76
78
|
# released features for a given account.
|
77
79
|
next if key.start_with?("#{RESOURCE_PREFIX}:")
|
80
|
+
next if key.start_with?("#{MANIFEST_PREFIX}:")
|
78
81
|
|
79
82
|
feature_keys << key
|
80
83
|
end
|
@@ -89,6 +92,14 @@ module FeatureFlagger
|
|
89
92
|
).call
|
90
93
|
end
|
91
94
|
|
95
|
+
def read_manifest_backup
|
96
|
+
@redis.get("#{MANIFEST_PREFIX}:#{MANIFEST_KEY}")
|
97
|
+
end
|
98
|
+
|
99
|
+
def write_manifest_backup(yaml_as_string)
|
100
|
+
@redis.set("#{MANIFEST_PREFIX}:#{MANIFEST_KEY}", yaml_as_string)
|
101
|
+
end
|
102
|
+
|
92
103
|
private
|
93
104
|
|
94
105
|
def resource_key(resource_name, resource_id)
|
data/lib/feature_flagger.rb
CHANGED
@@ -11,6 +11,9 @@ require 'feature_flagger/configuration'
|
|
11
11
|
require 'feature_flagger/manager'
|
12
12
|
require 'feature_flagger/railtie'
|
13
13
|
require 'feature_flagger/notifier'
|
14
|
+
require 'feature_flagger/manifest_sources/with_yaml_file'
|
15
|
+
require 'feature_flagger/manifest_sources/yaml_with_backup_to_storage'
|
16
|
+
require 'feature_flagger/manifest_sources/storage_only'
|
14
17
|
|
15
18
|
module FeatureFlagger
|
16
19
|
class << self
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feature_flagger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Sousa
|
8
8
|
- Geison Biazus
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-03-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
@@ -139,6 +139,9 @@ files:
|
|
139
139
|
- lib/feature_flagger/core_ext.rb
|
140
140
|
- lib/feature_flagger/feature.rb
|
141
141
|
- lib/feature_flagger/manager.rb
|
142
|
+
- lib/feature_flagger/manifest_sources/storage_only.rb
|
143
|
+
- lib/feature_flagger/manifest_sources/with_yaml_file.rb
|
144
|
+
- lib/feature_flagger/manifest_sources/yaml_with_backup_to_storage.rb
|
142
145
|
- lib/feature_flagger/model.rb
|
143
146
|
- lib/feature_flagger/model_settings.rb
|
144
147
|
- lib/feature_flagger/notifier.rb
|
@@ -152,7 +155,7 @@ homepage: http://github.com/ResultadosDigitais/feature_flagger
|
|
152
155
|
licenses:
|
153
156
|
- MIT
|
154
157
|
metadata: {}
|
155
|
-
post_install_message:
|
158
|
+
post_install_message:
|
156
159
|
rdoc_options: []
|
157
160
|
require_paths:
|
158
161
|
- lib
|
@@ -167,8 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
170
|
- !ruby/object:Gem::Version
|
168
171
|
version: 2.0.0
|
169
172
|
requirements: []
|
170
|
-
rubygems_version: 3.2.
|
171
|
-
signing_key:
|
173
|
+
rubygems_version: 3.2.32
|
174
|
+
signing_key:
|
172
175
|
specification_version: 4
|
173
176
|
summary: Partial release your features.
|
174
177
|
test_files: []
|