rollout-redis 0.2.0 → 0.3.1

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: 3b85cb7955ab58bf0ede95038078e71e534db5e477af94d9af605b3c3f48aee3
4
- data.tar.gz: a210b3007e3cc5f1bad76c3574b9729d138c5eec19df5ef4b620b29c56f7ba72
3
+ metadata.gz: '09b02bf812a6d2bf771a7d9b3d299113d6600c43d88516e40ff43d724c6681b9'
4
+ data.tar.gz: d18a8829c7ded0e56c2c9f43da26a73e2011d28a7aee15a9011d6246bcc5a166
5
5
  SHA512:
6
- metadata.gz: eb078df42c0404c25f3439635391751cc83b3ad90a3647fac163d42240cac7afefe376d4c7de50bd9eb8565bf724bf8288fec7823f81ae10d8eb894643cad852
7
- data.tar.gz: f6a3a0c1da29db894c75fbb3b5516f9975ae6031fe0569b158ca3e5707dfa0bdd3fffe924da8bdaf6720501d75ac0073b99eea66bfb937393367f5a431e6a2e1
6
+ metadata.gz: 8da06a204a6133487f43c52c013485476391b1ff8d2d5680eda8ef9f419aa6b516a63a27fbae3627f0b747b7515fff2347b0594802252ab8b05f78a8b9988154
7
+ data.tar.gz: 2850a4238642e603504ea4034bd036d09649d319127d99eae4afbe2903f099c7af6d6cc49e50248bfff4b01354982ce93b4b8e58468fdbf7c37dae6801bd0f10
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ 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.3.0] - 2023-10-24
9
+
10
+ ### Added
11
+ - Providing some rake tasks to the consumers of the gem for allowing them to easily manage their feature flags in their applications:
12
+ - `bundle exec rake rollout:on` rake task for activating feature flags
13
+ - `bundle exec rake rollout:off` rake task for deactivating feature flags
14
+ - `bundle exec rake rollout:list` rake task for listing stored feature flags
15
+
8
16
  ## [0.2.0] - 2023-10-23
9
17
 
10
18
  ### Added
data/README.md CHANGED
@@ -9,12 +9,13 @@ Based on the discontinued [rollout](https://github.com/fetlife/rollout) project,
9
9
  Topics covered in this README:
10
10
 
11
11
  - [Install it](#install-it)
12
- - [Quick Start](#quick-start-💨)
13
- - [Advanced features](#advanced-features-🦾)
12
+ - [Quick Start](#quick-start-)
13
+ - [Advanced features](#advanced-features-)
14
14
  - [Gradual activation based on percentages](#gradual-activation-based-on-percentages)
15
15
  - [Caching Feature Flags](#caching-feature-flags)
16
16
  - [Auto-deactivating flags](#auto-deactivating-flags)
17
- - [Migrating from rollout gem](#migrating-from-rollout-gem-🚨)
17
+ - [Rake tasks](#rake-tasks)
18
+ - [Migrating from rollout gem](#migrating-from-rollout-gem-)
18
19
  - [Changelog](#changelog)
19
20
  - [Contributing](#contributing)
20
21
 
@@ -146,7 +147,7 @@ If you want to allow the gem to deactivate your feature flag automatically when
146
147
  ```ruby
147
148
  @rollout ||= Rollout.new(redis)
148
149
  .with_cache
149
- .with_degrade(sample: 5000, min: 100, threshold: 0.1)
150
+ .with_degrade(min: 100, threshold: 0.1)
150
151
  ```
151
152
 
152
153
  So now, instead of using the `active?` method, you need to wrap your new code under the `with_feature` method.
@@ -159,6 +160,46 @@ end
159
160
 
160
161
  When any unexpected error appears during the wrapped code execution, the Rollout gem will take it into account for automatically deactivating the feature flag if the threshold of errors is reached. All the managed or captured errors inside the wrapped code will not be taken into consideration.
161
162
 
163
+ ## Rake tasks
164
+
165
+ In order to have access to the rollout rakes, you have to load manually the task definitions. For doing so load the rollout rake task:
166
+
167
+ ```ruby
168
+ require 'rollout'
169
+
170
+ load 'rollout/tasks/rollout.rake'
171
+ ```
172
+
173
+ Also, for using the rake tasks, you must set the following env variables
174
+
175
+ ```shell
176
+ ROLLOUT_REDIS_HOST=localhost
177
+ ROLLOUT_REDIS_PORT=6379
178
+ ```
179
+
180
+ ### Usage
181
+
182
+ To activate/deactivate features, execute the following rake tasks:
183
+
184
+ ```shell
185
+ bundle exec rake rollout:on[feature_name]
186
+ bundle exec rake rollout:off[feature_name]
187
+ ```
188
+
189
+ To a gradual activation based on percentages, pass the percentage as the second parameter when executing the `on` task.
190
+
191
+ ```shell
192
+ bundle exec rake rollout:on[feature_name,50]
193
+ ```
194
+
195
+ _NOTE_: In both cases, `feature_name` **must not** include quotes e.g. `bundle exec rake rollout:on['feature_name']`, as the gem will be unable to fetch its activation status if so.
196
+
197
+ For listing all the stored feature flags, do:
198
+
199
+ ```shell
200
+ bundle exec rake rollout:list
201
+ ```
202
+
162
203
  ## Migrating from rollout gem 🚨
163
204
 
164
205
  If you are currently using the unmaintained [rollout](https://github.com/fetlife/rollout) gem, you should consider checking this [migration guide](https://github.com/jcagarcia/rollout-redis/blob/main/MIGRATING_FROM_ROLLOUT_GEM.md) for start using the new `rollout-redis` gem.
@@ -0,0 +1,63 @@
1
+
2
+ namespace :rollout do
3
+ desc "Activate a feature"
4
+ task :on, [:feature, :percentage] => :environment do |task, args|
5
+ if args.feature
6
+ puts "Activating feature #{args.feature}..."
7
+ if args.percentage
8
+ activated = rollout.activate(args.feature, args.percentage.to_i)
9
+ else
10
+ activated = rollout.activate(args.feature)
11
+ end
12
+
13
+ if activated
14
+ puts "Feature flag #{args.feature} has been activated! :)"
15
+ else
16
+ puts "Feature flag #{args.feature} has NOT been activated! :("
17
+ end
18
+ end
19
+ end
20
+
21
+ desc "Deactivate a feature"
22
+ task :off, [:feature] => :environment do |task, args|
23
+ if args.feature
24
+ puts "Deactivating feature #{args.feature}..."
25
+ deactivated = rollout.deactivate(args.feature)
26
+ if deactivated
27
+ puts "Feature flag #{args.feature} has been deactivated! :)"
28
+ else
29
+ puts "Feature flag #{args.feature} has NOT been deactivated! :("
30
+ end
31
+ end
32
+ end
33
+
34
+ desc "List features"
35
+ task list: :environment do
36
+ features = rollout.features
37
+ puts "This is the list of all the available features:"
38
+ puts ""
39
+ if !features.empty?
40
+ puts features
41
+ else
42
+ puts "- No feature flags stored"
43
+ end
44
+ end
45
+
46
+ private
47
+
48
+ def rollout
49
+ @rollout ||= Rollout.new(storage)
50
+ end
51
+
52
+ def storage
53
+ begin
54
+ @storage ||= Redis.new(
55
+ host: ENV.fetch('ROLLOUT_REDIS_HOST'),
56
+ port: ENV.fetch('ROLLOUT_REDIS_PORT')
57
+ )
58
+ rescue KeyError => e
59
+ puts "ROLLOUT_REDIS_HOST and ROLLOUT_REDIS_PORT are mandatory env variables to define in order to run rollout rake tasks"
60
+ raise e
61
+ end
62
+ end
63
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Rollout
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.1'
5
5
  end
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'bundler', '>= 2.4'
28
28
  spec.add_development_dependency 'rspec', '~> 3.12'
29
29
  spec.add_development_dependency 'mock_redis', '~> 0.37'
30
+ spec.add_development_dependency 'rake', '~> 13'
30
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollout-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Carlos García
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-23 00:00:00.000000000 Z
11
+ date: 2023-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0.37'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rake
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '13'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '13'
75
89
  description: Fast and easy feature flags based on the latest Redis versions.
76
90
  email:
77
91
  - jugade92@gmail.com
@@ -84,6 +98,7 @@ files:
84
98
  - Rakefile
85
99
  - lib/rollout.rb
86
100
  - lib/rollout/feature.rb
101
+ - lib/rollout/tasks/rollout.rake
87
102
  - lib/rollout/version.rb
88
103
  - rollout-redis.gemspec
89
104
  homepage: https://github.com/jcagarcia/rollout-redis