flipper 0.21.0 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -0
- data/.github/workflows/ci.yml +23 -18
- data/.github/workflows/examples.yml +67 -0
- data/.rspec +1 -0
- data/Changelog.md +87 -2
- data/Dockerfile +1 -1
- data/Gemfile +4 -3
- data/README.md +16 -67
- data/docker-compose.yml +37 -34
- data/docs/README.md +1 -0
- data/docs/images/banner.jpg +0 -0
- data/examples/api/basic.ru +19 -0
- data/examples/api/custom_memoized.ru +37 -0
- data/examples/api/memoized.ru +43 -0
- data/examples/instrumentation_last_accessed_at.rb +37 -0
- data/lib/flipper/actor.rb +4 -0
- data/lib/flipper/adapters/dual_write.rb +9 -15
- data/lib/flipper/adapters/failover.rb +83 -0
- data/lib/flipper/adapters/failsafe.rb +76 -0
- data/lib/flipper/adapters/http/client.rb +11 -1
- data/lib/flipper/adapters/http/error.rb +19 -1
- data/lib/flipper/adapters/memoizable.rb +8 -16
- data/lib/flipper/adapters/pstore.rb +2 -5
- data/lib/flipper/adapters/sync/interval_synchronizer.rb +1 -6
- data/lib/flipper/adapters/sync/synchronizer.rb +2 -1
- data/lib/flipper/adapters/sync.rb +9 -15
- data/lib/flipper/dsl.rb +4 -2
- data/lib/flipper/errors.rb +0 -17
- data/lib/flipper/instrumenters/memory.rb +6 -2
- data/lib/flipper/middleware/memoizer.rb +3 -13
- data/lib/flipper/railtie.rb +21 -12
- data/lib/flipper/types/actor.rb +8 -2
- data/lib/flipper/types/group.rb +8 -1
- data/lib/flipper/version.rb +1 -1
- data/spec/flipper/actor_spec.rb +10 -2
- data/spec/flipper/adapter_spec.rb +0 -2
- data/spec/flipper/adapters/dual_write_spec.rb +0 -2
- data/spec/flipper/adapters/failover_spec.rb +129 -0
- data/spec/flipper/adapters/failsafe_spec.rb +58 -0
- data/spec/flipper/adapters/http_spec.rb +39 -3
- data/spec/flipper/adapters/instrumented_spec.rb +0 -2
- data/spec/flipper/adapters/memoizable_spec.rb +0 -2
- data/spec/flipper/adapters/memory_spec.rb +0 -3
- data/spec/flipper/adapters/operation_logger_spec.rb +0 -2
- data/spec/flipper/adapters/pstore_spec.rb +0 -2
- data/spec/flipper/adapters/read_only_spec.rb +0 -1
- data/spec/flipper/adapters/sync/feature_synchronizer_spec.rb +0 -1
- data/spec/flipper/adapters/sync/interval_synchronizer_spec.rb +4 -5
- data/spec/flipper/adapters/sync/synchronizer_spec.rb +0 -1
- data/spec/flipper/adapters/sync_spec.rb +0 -2
- data/spec/flipper/configuration_spec.rb +0 -1
- data/spec/flipper/dsl_spec.rb +13 -4
- data/spec/flipper/feature_check_context_spec.rb +0 -2
- data/spec/flipper/feature_spec.rb +0 -1
- data/spec/flipper/gate_spec.rb +0 -2
- data/spec/flipper/gate_values_spec.rb +0 -1
- data/spec/flipper/gates/actor_spec.rb +0 -2
- data/spec/flipper/gates/boolean_spec.rb +0 -2
- data/spec/flipper/gates/group_spec.rb +0 -2
- data/spec/flipper/gates/percentage_of_actors_spec.rb +0 -2
- data/spec/flipper/gates/percentage_of_time_spec.rb +0 -2
- data/spec/flipper/identifier_spec.rb +0 -1
- data/spec/flipper/instrumentation/log_subscriber_spec.rb +0 -1
- data/spec/flipper/instrumentation/statsd_subscriber_spec.rb +0 -1
- data/spec/flipper/instrumenters/memory_spec.rb +18 -1
- data/spec/flipper/instrumenters/noop_spec.rb +14 -8
- data/spec/flipper/middleware/memoizer_spec.rb +0 -23
- data/spec/flipper/middleware/setup_env_spec.rb +0 -2
- data/spec/flipper/railtie_spec.rb +37 -33
- data/spec/flipper/registry_spec.rb +0 -1
- data/spec/flipper/typecast_spec.rb +0 -1
- data/spec/flipper/types/actor_spec.rb +0 -1
- data/spec/flipper/types/boolean_spec.rb +0 -1
- data/spec/flipper/types/group_spec.rb +0 -1
- data/spec/flipper/types/percentage_of_actors_spec.rb +0 -1
- data/spec/flipper/types/percentage_of_time_spec.rb +0 -1
- data/spec/flipper/types/percentage_spec.rb +0 -1
- data/spec/flipper_integration_spec.rb +0 -1
- data/spec/flipper_spec.rb +0 -1
- data/spec/{helper.rb → spec_helper.rb} +4 -2
- data/spec/support/spec_helpers.rb +2 -6
- metadata +18 -13
- data/docs/Adapters.md +0 -124
- data/docs/Caveats.md +0 -4
- data/docs/Gates.md +0 -167
- data/docs/Instrumentation.md +0 -27
- data/docs/Optimization.md +0 -137
- data/docs/api/README.md +0 -884
- data/docs/http/README.md +0 -36
- data/docs/read-only/README.md +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 896d9fb7468ffbc19e1200a6abe2a5c3992fae7abb3d4211fd29829364fb1a42
|
4
|
+
data.tar.gz: e157fa74da897e4ad56b3548cd438adc0ddbc0e2fec89e4d8214dd4ca2b2596e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c99039ff6cc5dc62953289d9343bcee6b2d2935e52b4cc7b33f5134c266a3ac99180d713220432cbde7e2cb57a90d42e41249eb0bcf55f20eb60a9e0cc379208
|
7
|
+
data.tar.gz: 9f3b2dea4b9137b20f86d359a5dd5eb3b220655364dc9baf498faecbd42ddca286f6d94e91694b203d21cce8c0a986ed421e6f7436ec0fd956d9e590698ec59c
|
data/.codeclimate.yml
CHANGED
data/.github/workflows/ci.yml
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
name: CI
|
2
|
-
on:
|
3
|
-
push:
|
4
|
-
branches: [master]
|
5
|
-
pull_request:
|
2
|
+
on: [push, pull_request]
|
6
3
|
jobs:
|
7
|
-
|
4
|
+
test:
|
5
|
+
name: Test on ruby ${{ matrix.ruby }} and rails ${{ matrix.rails }}
|
8
6
|
runs-on: ubuntu-latest
|
9
7
|
services:
|
10
8
|
redis:
|
@@ -17,9 +15,18 @@ jobs:
|
|
17
15
|
--health-retries 5
|
18
16
|
strategy:
|
19
17
|
matrix:
|
20
|
-
ruby: ['2.
|
18
|
+
ruby: ['2.6', '2.7', '3.0', '3.1']
|
19
|
+
rails: ['5.2', '6.0.0', '6.1.0', '7.0.0']
|
20
|
+
exclude:
|
21
|
+
- ruby: "2.6"
|
22
|
+
rails: "7.0.0"
|
23
|
+
- ruby: "3.0"
|
24
|
+
rails: "5.2"
|
25
|
+
- ruby: "3.1"
|
26
|
+
rails: "5.2"
|
27
|
+
- ruby: "3.1"
|
28
|
+
rails: "6.0.0"
|
21
29
|
env:
|
22
|
-
RAILS_VERSION: 6.0.0
|
23
30
|
SQLITE3_VERSION: 1.4.1
|
24
31
|
REDIS_URL: redis://localhost:6379/0
|
25
32
|
CI: true
|
@@ -36,22 +43,20 @@ jobs:
|
|
36
43
|
uses: actions/cache@v1
|
37
44
|
with:
|
38
45
|
path: vendor/bundle
|
39
|
-
key: ${{ runner.os }}-
|
46
|
+
key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-${{ hashFiles('**/Gemfile.lock') }}
|
40
47
|
restore-keys: |
|
41
|
-
${{ runner.os }}-
|
42
|
-
- name: Set up Ruby
|
43
|
-
uses:
|
48
|
+
${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-
|
49
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
50
|
+
uses: ruby/setup-ruby@v1
|
44
51
|
with:
|
45
52
|
ruby-version: ${{ matrix.ruby }}
|
46
53
|
- name: Install libpq-dev
|
47
54
|
run: sudo apt-get -yqq install libpq-dev
|
48
55
|
- name: Install bundler
|
49
56
|
run: gem install bundler
|
50
|
-
- name: Run
|
51
|
-
run: bundle install --jobs 4 --retry 3
|
52
|
-
- name: Run Rake
|
53
|
-
run: bundle exec rake
|
54
|
-
- name: Run Examples
|
57
|
+
- name: Run Rake with Rails ${{ matrix.rails }}
|
55
58
|
env:
|
56
|
-
|
57
|
-
run:
|
59
|
+
RAILS_VERSION: ${{ matrix.rails }}
|
60
|
+
run: |
|
61
|
+
bundle install --jobs 4 --retry 3
|
62
|
+
bundle exec rake
|
@@ -0,0 +1,67 @@
|
|
1
|
+
name: Examples
|
2
|
+
on: [push, pull_request]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
if: github.repository_owner == 'jnunemaker'
|
6
|
+
name: Test on ruby ${{ matrix.ruby }} and rails ${{ matrix.rails }}
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
services:
|
9
|
+
redis:
|
10
|
+
image: redis
|
11
|
+
ports: ['6379:6379']
|
12
|
+
options: >-
|
13
|
+
--health-cmd "redis-cli ping"
|
14
|
+
--health-interval 10s
|
15
|
+
--health-timeout 5s
|
16
|
+
--health-retries 5
|
17
|
+
strategy:
|
18
|
+
matrix:
|
19
|
+
ruby: ['2.6', '2.7', '3.0', '3.1']
|
20
|
+
rails: ['5.2', '6.0.0', '6.1.0', '7.0.0']
|
21
|
+
exclude:
|
22
|
+
- ruby: "2.6"
|
23
|
+
rails: "7.0.0"
|
24
|
+
- ruby: "3.0"
|
25
|
+
rails: "5.2"
|
26
|
+
- ruby: "3.1"
|
27
|
+
rails: "5.2"
|
28
|
+
- ruby: "3.1"
|
29
|
+
rails: "6.0.0"
|
30
|
+
|
31
|
+
env:
|
32
|
+
SQLITE3_VERSION: 1.4.1
|
33
|
+
REDIS_URL: redis://localhost:6379/0
|
34
|
+
CI: true
|
35
|
+
steps:
|
36
|
+
- name: Setup memcached
|
37
|
+
uses: KeisukeYamashita/memcached-actions@v1
|
38
|
+
- name: Start MongoDB
|
39
|
+
uses: supercharge/mongodb-github-action@1.3.0
|
40
|
+
with:
|
41
|
+
mongodb-version: 4.0
|
42
|
+
- name: Check out repository code
|
43
|
+
uses: actions/checkout@v2
|
44
|
+
- name: Do some action caching
|
45
|
+
uses: actions/cache@v1
|
46
|
+
with:
|
47
|
+
path: vendor/bundle
|
48
|
+
key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-${{ hashFiles('**/Gemfile.lock') }}
|
49
|
+
restore-keys: |
|
50
|
+
${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-
|
51
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
52
|
+
uses: ruby/setup-ruby@v1
|
53
|
+
with:
|
54
|
+
ruby-version: ${{ matrix.ruby }}
|
55
|
+
- name: Install libpq-dev
|
56
|
+
run: sudo apt-get -yqq install libpq-dev
|
57
|
+
- name: Install bundler
|
58
|
+
run: gem install bundler
|
59
|
+
- name: Bundle install with Rails ${{ matrix.rails }}
|
60
|
+
env:
|
61
|
+
RAILS_VERSION: ${{ matrix.rails }}
|
62
|
+
run: bundle install --jobs 4 --retry 3
|
63
|
+
- name: Run Examples with Rails ${{ matrix.rails }}
|
64
|
+
env:
|
65
|
+
FLIPPER_CLOUD_TOKEN: ${{ secrets.FLIPPER_CLOUD_TOKEN }}
|
66
|
+
RAILS_VERSION: ${{ matrix.rails }}
|
67
|
+
run: script/examples
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/Changelog.md
CHANGED
@@ -1,3 +1,85 @@
|
|
1
|
+
## Unreleased
|
2
|
+
|
3
|
+
### Additions/Changes
|
4
|
+
|
5
|
+
* Added a prompt in Flipper UI for the 'Delete' button to prevent accidental delete of features (https://github.com/jnunemaker/flipper/pull/625)
|
6
|
+
* Added failsafe adapter (https://github.com/jnunemaker/flipper/pull/626)
|
7
|
+
* Removed previously deprecated options and settings. Those upgrading from `<0.21` should upgrade to `~>0.24` first and fix any deprecation warnings when initializing Flipper. (https://github.com/jnunemaker/flipper/pull/627)
|
8
|
+
* ActiveRecord: base class for internal models (https://github.com/jnunemaker/flipper/pull/629)
|
9
|
+
* Remove use of `Rack::BodyProxy` in the memoizer middleware (https://github.com/jnunemaker/flipper/pull/631)
|
10
|
+
|
11
|
+
## 0.24.1
|
12
|
+
|
13
|
+
### Additions/Changes
|
14
|
+
|
15
|
+
* flipper-api: `exclude_gates` parameter to exclude gate data in GETs (https://github.com/jnunemaker/flipper/pull/572).
|
16
|
+
* Make it possible to disable internal memoization (https://github.com/jnunemaker/flipper/pull/612).
|
17
|
+
* Add Flipper::Actor#hash so actors can be hash keys (https://github.com/jnunemaker/flipper/pull/616).
|
18
|
+
* Pretty Up `rails routes` again and make rack-protection dependency less strict (https://github.com/jnunemaker/flipper/pull/619).
|
19
|
+
* Add kwargs for method_missing using ruby 3.0 (https://github.com/jnunemaker/flipper/pull/620).
|
20
|
+
* Relax the rack-protection dependency (https://github.com/jnunemaker/flipper/commit/c1cb9cd78140c2b09123687642558101e6e5d37d).
|
21
|
+
|
22
|
+
## 0.24.0
|
23
|
+
|
24
|
+
### Additions/Changes
|
25
|
+
|
26
|
+
* Add Ruby 3.0 and 3.1 to the CI matrix and fix groups block arity check for ruby 3 (https://github.com/jnunemaker/flipper/pull/601)
|
27
|
+
* Removed support for Ruby 2.5 (which was end of line 9 months ago)
|
28
|
+
* Add (alpha) client side instrumentation of events to cloud (https://github.com/jnunemaker/flipper/pull/602)
|
29
|
+
* Fix deprecated uses of Redis#pipelined (https://github.com/jnunemaker/flipper/pull/603). redis-rb >= 3 now required.
|
30
|
+
* Fix Flipper UI Rack application when `Rack::Session::Pool` is used to build it (https://github.com/jnunemaker/flipper/pull/606).
|
31
|
+
|
32
|
+
## 0.23.1
|
33
|
+
|
34
|
+
### Additions/Changes
|
35
|
+
|
36
|
+
* Relax dalli version constraint (https://github.com/jnunemaker/flipper/pull/596)
|
37
|
+
|
38
|
+
### Bug Fixes
|
39
|
+
|
40
|
+
* Fix railtie initialization to mount middleware after config/intializers/* (https://github.com/jnunemaker/flipper/pull/586)
|
41
|
+
|
42
|
+
## 0.23.0
|
43
|
+
|
44
|
+
### Additions/Changes
|
45
|
+
|
46
|
+
* Allow some HTML in banner and descriptions (https://github.com/jnunemaker/flipper/pull/570).
|
47
|
+
* Moved some cloud headers to http client (https://github.com/jnunemaker/flipper/pull/567).
|
48
|
+
* Update flipper-ui jquery and bootstrap versions (https://github.com/jnunemaker/flipper/issues/565 and https://github.com/jnunemaker/flipper/pull/566).
|
49
|
+
* Moved docs to www.flippercloud.io/docs (https://github.com/jnunemaker/flipper/pull/574).
|
50
|
+
* PStore adapter now defaults to thread safe and no longer supports `.thread_safe` (https://github.com/jnunemaker/flipper/commit/4048704fefe41b716015294a19a0b94546637630).
|
51
|
+
* Add failover adapter (https://github.com/jnunemaker/flipper/pull/584).
|
52
|
+
* Improve http adapter error message (https://github.com/jnunemaker/flipper/pull/587).
|
53
|
+
* Rails 7 support (mostly in https://github.com/jnunemaker/flipper/pull/592).
|
54
|
+
|
55
|
+
## 0.22.2
|
56
|
+
|
57
|
+
### Additions/Changes
|
58
|
+
|
59
|
+
* Allow adding multiple actors at once in flipper-ui via comma separation (configurable via `Flipper::UI.configuration.actors_separator`) (https://github.com/jnunemaker/flipper/pull/556)
|
60
|
+
|
61
|
+
### Bug Fixes
|
62
|
+
|
63
|
+
* Fix railtie initialization to avoid altering middleware order (https://github.com/jnunemaker/flipper/pull/563)
|
64
|
+
|
65
|
+
## 0.22.1
|
66
|
+
|
67
|
+
### Additions/Changes
|
68
|
+
|
69
|
+
* Remove Octicons and replace with a pure CSS status circle (https://github.com/jnunemaker/flipper/pull/547)
|
70
|
+
* Rescue unique errors in AR and Sequel when setting value (https://github.com/jnunemaker/flipper/commit/87f5a98bce7baad7a27b75b5bce3256967769f27)
|
71
|
+
* Add a Content-Security-Policy to flipper-ui (https://github.com/jnunemaker/flipper/pull/552)
|
72
|
+
* Fix Synchronizer issue that occurs for ActiveRecord adapter (https://github.com/jnunemaker/flipper/pull/554)
|
73
|
+
|
74
|
+
## 0.22.0
|
75
|
+
|
76
|
+
### Additions/Changes
|
77
|
+
|
78
|
+
* Enable log subscriber by default in Rails (https://github.com/jnunemaker/flipper/pull/525)
|
79
|
+
* Remove memoizer from API and UI (https://github.com/jnunemaker/flipper/pull/527). If you are using the UI or API without configuring the default instance of Flipper, you'll need to enable memoization if you want it. For examples, see the examples/ui and examples/api directories.
|
80
|
+
* Fix SQL reserved word use in get_all for ActiveRecord and Sequel (https://github.com/jnunemaker/flipper/pull/536).
|
81
|
+
* Handle spaces in names gracefully in UI (https://github.com/jnunemaker/flipper/pull/541).
|
82
|
+
|
1
83
|
## 0.21.0
|
2
84
|
|
3
85
|
### Additions/Changes
|
@@ -7,7 +89,7 @@
|
|
7
89
|
* Added cloud recommendation to flipper-ui. Can be disabled with `Flipper::UI.configure { |config| config.cloud_recommendation = false }`. Just want to raise awareness that more is available if people want it (https://github.com/jnunemaker/flipper/pull/504)
|
8
90
|
* Added default `flipper_id` implementation via `Flipper::Identifier` and automatically included it in ActiveRecord and Sequel models (https://github.com/jnunemaker/flipper/pull/505)
|
9
91
|
* Deprecate superflous sync_method setting (https://github.com/jnunemaker/flipper/pull/511)
|
10
|
-
* Flipper is now pre-configured when used with Rails. By default, it will [memoize and preload all features for each request](docs/
|
92
|
+
* Flipper is now pre-configured when used with Rails. By default, it will [memoize and preload all features for each request](https://flippercloud.io/docs/optimization#memoization). (https://github.com/jnunemaker/flipper/pull/506)
|
11
93
|
|
12
94
|
### Upgrading
|
13
95
|
|
@@ -22,7 +104,7 @@ You should be able to upgrade to 0.21 without any breaking changes. However, if
|
|
22
104
|
- end
|
23
105
|
```
|
24
106
|
|
25
|
-
2. `Flipper::Middleware::Memoizer` will be enabled by default.
|
107
|
+
2. `Flipper::Middleware::Memoizer` will be enabled by default -- including preloading. **Note**: You may want to disable preloading (see below) if you have > 100 features.
|
26
108
|
|
27
109
|
```diff
|
28
110
|
# config/initializers/flipper.rb
|
@@ -31,6 +113,9 @@ You should be able to upgrade to 0.21 without any breaking changes. However, if
|
|
31
113
|
+ Rails.application.configure do
|
32
114
|
+ # Uncomment to configure which features to preload on all requests
|
33
115
|
+ # config.flipper.preload = [:stats, :search, :some_feature]
|
116
|
+
+ #
|
117
|
+
+ # Or, you may want to disable preloading entirely:
|
118
|
+
+ # config.flipper.preload = false
|
34
119
|
+ end
|
35
120
|
```
|
36
121
|
|
data/Dockerfile
CHANGED
data/Gemfile
CHANGED
@@ -6,19 +6,20 @@ Dir['flipper-*.gemspec'].each do |gemspec|
|
|
6
6
|
gemspec(name: "flipper-#{plugin}", development_group: plugin)
|
7
7
|
end
|
8
8
|
|
9
|
-
gem '
|
9
|
+
gem 'debug'
|
10
10
|
gem 'rake', '~> 12.3.3'
|
11
11
|
gem 'shotgun', '~> 0.9'
|
12
12
|
gem 'statsd-ruby', '~> 1.2.1'
|
13
13
|
gem 'rspec', '~> 3.0'
|
14
14
|
gem 'rack-test', '~> 0.6.3'
|
15
15
|
gem 'sqlite3', "~> #{ENV['SQLITE3_VERSION'] || '1.4.1'}"
|
16
|
-
gem 'rails', "~> #{ENV['RAILS_VERSION'] || '
|
16
|
+
gem 'rails', "~> #{ENV['RAILS_VERSION'] || '7.0.0'}"
|
17
17
|
gem 'minitest', '~> 5.8'
|
18
18
|
gem 'minitest-documentation'
|
19
19
|
gem 'webmock', '~> 3.0'
|
20
|
-
gem '
|
20
|
+
gem 'ice_age'
|
21
21
|
gem 'redis-namespace'
|
22
|
+
gem 'webrick'
|
22
23
|
|
23
24
|
group(:guard) do
|
24
25
|
gem 'guard', '~> 2.15'
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
[![Flipper Mark](docs/images/banner.jpg)](https://www.flippercloud.io)
|
2
2
|
|
3
|
+
[Website](https://flippercloud.io) | [Documentation](https://flippercloud.io/docs) | [Examples](examples) | [Twitter](https://twitter.com/flipper_cloud)
|
4
|
+
|
3
5
|
# Flipper
|
4
6
|
|
5
7
|
> Beautiful, performant feature flags for Ruby.
|
@@ -19,7 +21,7 @@ Add this line to your application's Gemfile:
|
|
19
21
|
|
20
22
|
gem 'flipper'
|
21
23
|
|
22
|
-
You'll also want to pick a storage [adapter](
|
24
|
+
You'll also want to pick a storage [adapter](https://flippercloud.io/docs/adapters), for example:
|
23
25
|
|
24
26
|
gem 'flipper-active_record'
|
25
27
|
|
@@ -31,6 +33,10 @@ Or install it yourself with:
|
|
31
33
|
|
32
34
|
$ gem install flipper
|
33
35
|
|
36
|
+
## Subscribe & Ship
|
37
|
+
|
38
|
+
[💌 Subscribe](https://buttondown.email/flipper) - I'll send you short and sweet emails when we release new versions.
|
39
|
+
|
34
40
|
## Getting Started
|
35
41
|
|
36
42
|
Use `Flipper#enabled?` in your app to check if a feature is enabled.
|
@@ -46,74 +52,25 @@ end
|
|
46
52
|
|
47
53
|
All features are disabled by default, so you'll need to explicitly enable them.
|
48
54
|
|
49
|
-
#### Enable a feature for everyone
|
50
|
-
|
51
55
|
```ruby
|
56
|
+
# Enable a feature for everyone
|
52
57
|
Flipper.enable :search
|
53
|
-
```
|
54
58
|
|
55
|
-
|
56
|
-
|
57
|
-
```ruby
|
59
|
+
# Enable a feature for a specific actor
|
58
60
|
Flipper.enable_actor :search, current_user
|
59
|
-
```
|
60
|
-
|
61
|
-
#### Enable a feature for a group of actors
|
62
61
|
|
63
|
-
|
64
|
-
|
65
|
-
```ruby
|
66
|
-
# config/initializers/flipper.rb
|
67
|
-
Flipper.register(:admin) do |actor|
|
68
|
-
actor.respond_to?(:admin?) && actor.admin?
|
69
|
-
end
|
70
|
-
```
|
71
|
-
|
72
|
-
Then enable the feature for that group:
|
73
|
-
|
74
|
-
```ruby
|
62
|
+
# Enable a feature for a group of actors
|
75
63
|
Flipper.enable_group :search, :admin
|
76
|
-
```
|
77
|
-
|
78
|
-
#### Enable a feature for a percentage of actors
|
79
64
|
|
80
|
-
|
65
|
+
# Enable a feature for a percentage of actors
|
81
66
|
Flipper.enable_percentage_of_actors :search, 2
|
82
67
|
```
|
83
68
|
|
84
|
-
|
85
|
-
Read more about enabling and disabling features with [Gates](docs/Gates.md). Check out the [examples directory](examples/) for more, and take a peek at the [DSL](lib/flipper/dsl.rb) and [Feature](lib/flipper/feature.rb) classes for code/docs.
|
86
|
-
|
87
|
-
## Adapters
|
88
|
-
|
89
|
-
Flipper is built on adapters for maximum flexibility. Regardless of what data store you are using, Flipper can performantly store data in it.
|
90
|
-
|
91
|
-
Pick one of our [supported adapters](docs/Adapters.md#officially-supported) and follow the installation instructions:
|
92
|
-
|
93
|
-
* [Active Record](docs/active_record/README.md)
|
94
|
-
* [Sequel](docs/sequel/README.md)
|
95
|
-
* [Redis](docs/redis/README.md)
|
96
|
-
* [Mongo](docs/mongo/README.md)
|
97
|
-
* [Moneta](docs/moneta/README.md)
|
98
|
-
* [Rollout](docs/rollout/README.md)
|
99
|
-
|
100
|
-
Or [roll your own](docs/Adapters.md#roll-your-own). We even provide automatic (rspec and minitest) tests for you, so you know you've built your custom adapter correctly.
|
101
|
-
|
102
|
-
Read more about [Adapters](docs/Adapters.md).
|
103
|
-
|
104
|
-
## Flipper UI
|
105
|
-
|
106
|
-
If you prefer a web UI to an IRB console, you can setup the [Flipper UI](docs/ui/README.md).
|
107
|
-
|
108
|
-
It's simple and pretty.
|
109
|
-
|
110
|
-
![Flipper UI Screenshot](docs/ui/images/feature.png)
|
111
|
-
|
112
|
-
|
69
|
+
Read more about [getting started with Flipper](https://flippercloud.io/docs) and [enabling features](https://flippercloud.io/docs/features).
|
113
70
|
|
114
71
|
## Flipper Cloud
|
115
72
|
|
116
|
-
|
73
|
+
Like Flipper and want more? Check out [Flipper Cloud](https://www.flippercloud.io), which comes with:
|
117
74
|
|
118
75
|
* **everything in one place** — no need to bounce around from different application UIs or IRB consoles.
|
119
76
|
* **permissions** — grant access to everyone in your organization or lockdown each project to particular people.
|
@@ -127,21 +84,11 @@ Or, (even better than OSS + UI) use [Flipper Cloud](https://www.flippercloud.io)
|
|
127
84
|
|
128
85
|
Cloud is super simple to integrate with Rails ([demo app](https://github.com/fewerandfaster/flipper-rails-demo)), Sinatra or any other framework.
|
129
86
|
|
130
|
-
## Advanced
|
131
|
-
|
132
|
-
A few miscellaneous docs with more info for the hungry.
|
133
|
-
|
134
|
-
* [Instrumentation](docs/Instrumentation.md) - ActiveSupport::Notifications and Statsd
|
135
|
-
* [Optimization](docs/Optimization.md) - Memoization middleware and Cache adapters
|
136
|
-
* [API](docs/api/README.md) - HTTP API interface
|
137
|
-
* [Caveats](docs/Caveats.md) - Flipper beware! (see what I did there)
|
138
|
-
* [Docker-Compose](docs/DockerCompose.md) - Using docker-compose in contributing
|
139
|
-
|
140
87
|
## Contributing
|
141
88
|
|
142
89
|
1. Fork it
|
143
90
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
144
|
-
3. Run the tests (`bundle exec rake`)
|
91
|
+
3. Run the tests (`bundle exec rake`). Check out [Docker-Compose](docs/DockerCompose.md) if you need help getting all the adapters running.
|
145
92
|
4. Commit your changes (`git commit -am 'Added some feature'`)
|
146
93
|
5. Push to the branch (`git push origin my-new-feature`)
|
147
94
|
6. Create new Pull Request
|
@@ -157,6 +104,8 @@ A few miscellaneous docs with more info for the hungry.
|
|
157
104
|
| pic | @mention | area |
|
158
105
|
|---|---|---|
|
159
106
|
| ![@jnunemaker](https://avatars3.githubusercontent.com/u/235?s=64) | [@jnunemaker](https://github.com/jnunemaker) | most things |
|
107
|
+
| ![@bkeepers](https://avatars3.githubusercontent.com/u/173?s=64) | [@bkeepers](https://github.com/bkeepers) | most things |
|
108
|
+
| ![@dpep](https://avatars3.githubusercontent.com/u/918804?s=64) | [@dpep](https://github.com/dpep) | tbd |
|
160
109
|
| ![@alexwheeler](https://avatars3.githubusercontent.com/u/3260042?s=64) | [@alexwheeler](https://github.com/alexwheeler) | api |
|
161
110
|
| ![@thetimbanks](https://avatars1.githubusercontent.com/u/471801?s=64) | [@thetimbanks](https://github.com/thetimbanks) | ui |
|
162
111
|
| ![@lazebny](https://avatars1.githubusercontent.com/u/6276766?s=64) | [@lazebny](https://github.com/lazebny) | docker |
|
data/docker-compose.yml
CHANGED
@@ -1,34 +1,37 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
1
|
+
version: "2.4"
|
2
|
+
services:
|
3
|
+
# postgres:
|
4
|
+
# container_name: flipper_postgres
|
5
|
+
# image: postgres:9.4
|
6
|
+
redis:
|
7
|
+
container_name: flipper_redis
|
8
|
+
image: redis:6.2.5
|
9
|
+
mongo:
|
10
|
+
container_name: flipper_mongo
|
11
|
+
image: mongo:4.4.8
|
12
|
+
memcached:
|
13
|
+
container_name: flipper_memcached
|
14
|
+
image: memcached:1.4.33
|
15
|
+
app:
|
16
|
+
container_name: flipper_app
|
17
|
+
build:
|
18
|
+
context: .
|
19
|
+
dockerfile: Dockerfile
|
20
|
+
volumes:
|
21
|
+
- .:/srv/app
|
22
|
+
volumes_from:
|
23
|
+
- bundle_cache
|
24
|
+
links:
|
25
|
+
# - postgres
|
26
|
+
- redis
|
27
|
+
- mongo
|
28
|
+
- memcached
|
29
|
+
environment:
|
30
|
+
- REDIS_URL=redis://redis:6379
|
31
|
+
- MONGODB_HOST=mongo
|
32
|
+
- MEMCACHED_URL=memcached:11211
|
33
|
+
bundle_cache:
|
34
|
+
container_name: flipper_bundle_cache
|
35
|
+
image: busybox
|
36
|
+
volumes:
|
37
|
+
- /bundle_cache
|
data/docs/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
See [flippercloud.io](https://flippercloud.io/docs) for extensive docs.
|
data/docs/images/banner.jpg
CHANGED
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# Usage:
|
3
|
+
# # if you want it to not reload and be really fast
|
4
|
+
# bin/rackup examples/api/basic.ru -p 9999
|
5
|
+
#
|
6
|
+
# # if you want reloading
|
7
|
+
# bin/shotgun examples/api/basic.ru -p 9999
|
8
|
+
#
|
9
|
+
# http://localhost:9999/
|
10
|
+
#
|
11
|
+
|
12
|
+
require 'bundler/setup'
|
13
|
+
require "flipper/api"
|
14
|
+
require "flipper/adapters/pstore"
|
15
|
+
|
16
|
+
# You can uncomment this to get some default data:
|
17
|
+
# Flipper.enable :logging
|
18
|
+
|
19
|
+
run Flipper::Api.app
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# Usage:
|
3
|
+
# # if you want it to not reload and be really fast
|
4
|
+
# bin/rackup examples/api/custom_memoized.ru -p 9999
|
5
|
+
#
|
6
|
+
# # if you want reloading
|
7
|
+
# bin/shotgun examples/api/custom_memoized.ru -p 9999
|
8
|
+
#
|
9
|
+
# http://localhost:9999/
|
10
|
+
#
|
11
|
+
|
12
|
+
require 'bundler/setup'
|
13
|
+
require "active_support/notifications"
|
14
|
+
require "flipper/api"
|
15
|
+
require "flipper/adapters/pstore"
|
16
|
+
|
17
|
+
adapter = Flipper::Adapters::Instrumented.new(
|
18
|
+
Flipper::Adapters::PStore.new,
|
19
|
+
instrumenter: ActiveSupport::Notifications,
|
20
|
+
)
|
21
|
+
flipper = Flipper.new(adapter)
|
22
|
+
|
23
|
+
ActiveSupport::Notifications.subscribe(/.*/, ->(*args) {
|
24
|
+
name, start, finish, id, data = args
|
25
|
+
case name
|
26
|
+
when "adapter_operation.flipper"
|
27
|
+
p data[:adapter_name] => data[:operation]
|
28
|
+
end
|
29
|
+
})
|
30
|
+
|
31
|
+
# You can uncomment this to get some default data:
|
32
|
+
# flipper[:logging].enable_percentage_of_time 5
|
33
|
+
|
34
|
+
run Flipper::Api.app(flipper) { |builder|
|
35
|
+
builder.use Flipper::Middleware::SetupEnv, flipper
|
36
|
+
builder.use Flipper::Middleware::Memoizer, preload: true
|
37
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#
|
2
|
+
# Usage:
|
3
|
+
# # if you want it to not reload and be really fast
|
4
|
+
# bin/rackup examples/api/memoized.ru -p 9999
|
5
|
+
#
|
6
|
+
# # if you want reloading
|
7
|
+
# bin/shotgun examples/api/memoized.ru -p 9999
|
8
|
+
#
|
9
|
+
# http://localhost:9999/
|
10
|
+
#
|
11
|
+
|
12
|
+
require 'bundler/setup'
|
13
|
+
require "active_support/notifications"
|
14
|
+
require "flipper/api"
|
15
|
+
require "flipper/adapters/pstore"
|
16
|
+
|
17
|
+
Flipper.configure do |config|
|
18
|
+
config.adapter {
|
19
|
+
Flipper::Adapters::Instrumented.new(
|
20
|
+
Flipper::Adapters::PStore.new,
|
21
|
+
instrumenter: ActiveSupport::Notifications,
|
22
|
+
)
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
ActiveSupport::Notifications.subscribe(/.*/, ->(*args) {
|
27
|
+
name, start, finish, id, data = args
|
28
|
+
case name
|
29
|
+
when "adapter_operation.flipper"
|
30
|
+
p data[:adapter_name] => data[:operation]
|
31
|
+
end
|
32
|
+
})
|
33
|
+
|
34
|
+
Flipper.register(:admins) { |actor|
|
35
|
+
actor.respond_to?(:admin?) && actor.admin?
|
36
|
+
}
|
37
|
+
|
38
|
+
# You can uncomment this to get some default data:
|
39
|
+
# Flipper.enable :logging
|
40
|
+
|
41
|
+
run Flipper::Api.app { |builder|
|
42
|
+
builder.use Flipper::Middleware::Memoizer, preload: true
|
43
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Quick example of how to keep track of when a feature was last checked.
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'securerandom'
|
4
|
+
require 'active_support/notifications'
|
5
|
+
require 'flipper'
|
6
|
+
|
7
|
+
class FlipperSubscriber
|
8
|
+
def self.stats
|
9
|
+
@stats ||= {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(name, start, finish, id, payload)
|
13
|
+
if payload[:operation] == :enabled?
|
14
|
+
feature_name = payload.fetch(:feature_name)
|
15
|
+
self.class.stats[feature_name] = Time.now
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
ActiveSupport::Notifications.subscribe(/feature_operation.flipper/, new)
|
20
|
+
end
|
21
|
+
|
22
|
+
Flipper.configure do |config|
|
23
|
+
config.default {
|
24
|
+
Flipper.new(config.adapter, instrumenter: ActiveSupport::Notifications)
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
Flipper.enabled?(:search)
|
29
|
+
Flipper.enabled?(:booyeah)
|
30
|
+
Flipper.enabled?(:hooray)
|
31
|
+
sleep 1
|
32
|
+
Flipper.enabled?(:booyeah)
|
33
|
+
Flipper.enabled?(:hooray)
|
34
|
+
sleep 1
|
35
|
+
Flipper.enabled?(:hooray)
|
36
|
+
|
37
|
+
pp FlipperSubscriber.stats
|