flipper 0.21.0 → 0.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +1 -0
  3. data/.github/workflows/ci.yml +17 -16
  4. data/.github/workflows/examples.yml +57 -0
  5. data/.rspec +1 -0
  6. data/Changelog.md +46 -2
  7. data/Gemfile +3 -2
  8. data/README.md +16 -67
  9. data/docker-compose.yml +37 -34
  10. data/docs/README.md +1 -0
  11. data/docs/images/banner.jpg +0 -0
  12. data/examples/api/basic.ru +19 -0
  13. data/examples/api/custom_memoized.ru +37 -0
  14. data/examples/api/memoized.ru +43 -0
  15. data/examples/instrumentation_last_accessed_at.rb +37 -0
  16. data/lib/flipper/adapters/dual_write.rb +9 -15
  17. data/lib/flipper/adapters/failover.rb +83 -0
  18. data/lib/flipper/adapters/http/client.rb +11 -1
  19. data/lib/flipper/adapters/http/error.rb +19 -1
  20. data/lib/flipper/adapters/memoizable.rb +8 -16
  21. data/lib/flipper/adapters/pstore.rb +2 -5
  22. data/lib/flipper/adapters/sync/interval_synchronizer.rb +1 -6
  23. data/lib/flipper/adapters/sync/synchronizer.rb +2 -1
  24. data/lib/flipper/adapters/sync.rb +9 -15
  25. data/lib/flipper/instrumenters/memory.rb +6 -2
  26. data/lib/flipper/middleware/memoizer.rb +1 -1
  27. data/lib/flipper/railtie.rb +10 -2
  28. data/lib/flipper/version.rb +1 -1
  29. data/spec/flipper/actor_spec.rb +0 -2
  30. data/spec/flipper/adapter_spec.rb +0 -2
  31. data/spec/flipper/adapters/dual_write_spec.rb +0 -2
  32. data/spec/flipper/adapters/failover_spec.rb +129 -0
  33. data/spec/flipper/adapters/http_spec.rb +39 -3
  34. data/spec/flipper/adapters/instrumented_spec.rb +0 -2
  35. data/spec/flipper/adapters/memoizable_spec.rb +0 -2
  36. data/spec/flipper/adapters/memory_spec.rb +0 -3
  37. data/spec/flipper/adapters/operation_logger_spec.rb +0 -2
  38. data/spec/flipper/adapters/pstore_spec.rb +0 -2
  39. data/spec/flipper/adapters/read_only_spec.rb +0 -1
  40. data/spec/flipper/adapters/sync/feature_synchronizer_spec.rb +0 -1
  41. data/spec/flipper/adapters/sync/interval_synchronizer_spec.rb +4 -5
  42. data/spec/flipper/adapters/sync/synchronizer_spec.rb +0 -1
  43. data/spec/flipper/adapters/sync_spec.rb +0 -2
  44. data/spec/flipper/configuration_spec.rb +0 -1
  45. data/spec/flipper/dsl_spec.rb +0 -1
  46. data/spec/flipper/feature_check_context_spec.rb +0 -2
  47. data/spec/flipper/feature_spec.rb +0 -1
  48. data/spec/flipper/gate_spec.rb +0 -2
  49. data/spec/flipper/gate_values_spec.rb +0 -1
  50. data/spec/flipper/gates/actor_spec.rb +0 -2
  51. data/spec/flipper/gates/boolean_spec.rb +0 -2
  52. data/spec/flipper/gates/group_spec.rb +0 -2
  53. data/spec/flipper/gates/percentage_of_actors_spec.rb +0 -2
  54. data/spec/flipper/gates/percentage_of_time_spec.rb +0 -2
  55. data/spec/flipper/identifier_spec.rb +0 -1
  56. data/spec/flipper/instrumentation/log_subscriber_spec.rb +0 -1
  57. data/spec/flipper/instrumentation/statsd_subscriber_spec.rb +0 -1
  58. data/spec/flipper/instrumenters/memory_spec.rb +18 -1
  59. data/spec/flipper/instrumenters/noop_spec.rb +14 -8
  60. data/spec/flipper/middleware/memoizer_spec.rb +0 -2
  61. data/spec/flipper/middleware/setup_env_spec.rb +0 -2
  62. data/spec/flipper/railtie_spec.rb +17 -19
  63. data/spec/flipper/registry_spec.rb +0 -1
  64. data/spec/flipper/typecast_spec.rb +0 -1
  65. data/spec/flipper/types/actor_spec.rb +0 -1
  66. data/spec/flipper/types/boolean_spec.rb +0 -1
  67. data/spec/flipper/types/group_spec.rb +0 -1
  68. data/spec/flipper/types/percentage_of_actors_spec.rb +0 -1
  69. data/spec/flipper/types/percentage_of_time_spec.rb +0 -1
  70. data/spec/flipper/types/percentage_spec.rb +0 -1
  71. data/spec/flipper_integration_spec.rb +0 -1
  72. data/spec/flipper_spec.rb +0 -1
  73. data/spec/{helper.rb → spec_helper.rb} +2 -1
  74. data/spec/support/spec_helpers.rb +2 -6
  75. metadata +15 -13
  76. data/docs/Adapters.md +0 -124
  77. data/docs/Caveats.md +0 -4
  78. data/docs/Gates.md +0 -167
  79. data/docs/Instrumentation.md +0 -27
  80. data/docs/Optimization.md +0 -137
  81. data/docs/api/README.md +0 -884
  82. data/docs/http/README.md +0 -36
  83. data/docs/read-only/README.md +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25b07936734df32fbd0331822a97059e76ee9919db287e1073c15b338afc5924
4
- data.tar.gz: 221fbb5002318b366d022365b7597f23094d2b50215e9545d3e1c2435faa03ec
3
+ metadata.gz: c7754b40752e0c255308fedfb6ef7784e7e9b3cf4ba0035a289a02074e61e4e7
4
+ data.tar.gz: 7e0add2ac95c2dc929a97fef218ece9fbc904c911ffe6f4ac1d3ccbc36befab9
5
5
  SHA512:
6
- metadata.gz: 4529f945a2c71a3c776940cc091e48280e5088e080c203d478aca91e94e52855d4b5c912bae8aad2b7ca95248f42cabf62599a67f307fc98c34faf46c6361bf1
7
- data.tar.gz: 3fed3febaf673456551dea59b13b01777f9f59f9ee267424547b495b4d7f06a7cc5c50521431ef29260585c01f93e05f2c1c30c4e55d5833cfb1cb40fccfb7c3
6
+ metadata.gz: 3e5b7b82f89f1cdbb93f0a07d6909aea686214e9ce6a7c1daf4661f900da5e3dfe3176ed89ffe1bb63b8317788bce1a662ad27b2e88b01bebb77856213be7f4d
7
+ data.tar.gz: e8d25c0ed393a34f4f7ec93b2d2ec8707f009ba35e83ef606d4850c7031bb7e923af83c2472fd2d6d00004d6561f410156021b7892dab20883dd0c6fe2efcb15
data/.codeclimate.yml CHANGED
@@ -1,2 +1,3 @@
1
1
  exclude_patterns:
2
2
  - "lib/flipper/ui/public"
3
+ - "spec/"
@@ -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
- build:
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:
@@ -18,8 +16,13 @@ jobs:
18
16
  strategy:
19
17
  matrix:
20
18
  ruby: ['2.5', '2.6', '2.7']
19
+ rails: ['5.2', '6.0.0', '6.1.0', '7.0.0']
20
+ exclude:
21
+ - ruby: "2.5"
22
+ rails: "7.0.0"
23
+ - ruby: "2.6"
24
+ rails: "7.0.0"
21
25
  env:
22
- RAILS_VERSION: 6.0.0
23
26
  SQLITE3_VERSION: 1.4.1
24
27
  REDIS_URL: redis://localhost:6379/0
25
28
  CI: true
@@ -36,10 +39,10 @@ jobs:
36
39
  uses: actions/cache@v1
37
40
  with:
38
41
  path: vendor/bundle
39
- key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
42
+ key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-${{ hashFiles('**/Gemfile.lock') }}
40
43
  restore-keys: |
41
- ${{ runner.os }}-gem-
42
- - name: Set up Ruby
44
+ ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-
45
+ - name: Set up Ruby ${{ matrix.ruby }}
43
46
  uses: actions/setup-ruby@v1
44
47
  with:
45
48
  ruby-version: ${{ matrix.ruby }}
@@ -47,11 +50,9 @@ jobs:
47
50
  run: sudo apt-get -yqq install libpq-dev
48
51
  - name: Install bundler
49
52
  run: gem install bundler
50
- - name: Run bundler
51
- run: bundle install --jobs 4 --retry 3
52
- - name: Run Rake
53
- run: bundle exec rake
54
- - name: Run Examples
53
+ - name: Run Rake with Rails ${{ matrix.rails }}
55
54
  env:
56
- FLIPPER_CLOUD_TOKEN: ${{ secrets.FLIPPER_CLOUD_TOKEN }}
57
- run: script/examples
55
+ RAILS_VERSION: ${{ matrix.rails }}
56
+ run: |
57
+ bundle install --jobs 4 --retry 3
58
+ bundle exec rake
@@ -0,0 +1,57 @@
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.5', '2.6', '2.7']
20
+ rails: ['5.2', '6.0.0', '6.1.0']
21
+ env:
22
+ SQLITE3_VERSION: 1.4.1
23
+ REDIS_URL: redis://localhost:6379/0
24
+ CI: true
25
+ steps:
26
+ - name: Setup memcached
27
+ uses: KeisukeYamashita/memcached-actions@v1
28
+ - name: Start MongoDB
29
+ uses: supercharge/mongodb-github-action@1.3.0
30
+ with:
31
+ mongodb-version: 4.0
32
+ - name: Check out repository code
33
+ uses: actions/checkout@v2
34
+ - name: Do some action caching
35
+ uses: actions/cache@v1
36
+ with:
37
+ path: vendor/bundle
38
+ key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-${{ hashFiles('**/Gemfile.lock') }}
39
+ restore-keys: |
40
+ ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-
41
+ - name: Set up Ruby ${{ matrix.ruby }}
42
+ uses: actions/setup-ruby@v1
43
+ with:
44
+ ruby-version: ${{ matrix.ruby }}
45
+ - name: Install libpq-dev
46
+ run: sudo apt-get -yqq install libpq-dev
47
+ - name: Install bundler
48
+ run: gem install bundler
49
+ - name: Bundle install with Rails ${{ matrix.rails }}
50
+ env:
51
+ RAILS_VERSION: ${{ matrix.rails }}
52
+ run: bundle install --jobs 4 --retry 3
53
+ - name: Run Examples with Rails ${{ matrix.rails }}
54
+ env:
55
+ FLIPPER_CLOUD_TOKEN: ${{ secrets.FLIPPER_CLOUD_TOKEN }}
56
+ RAILS_VERSION: ${{ matrix.rails }}
57
+ run: script/examples
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Changelog.md CHANGED
@@ -1,3 +1,44 @@
1
+ ## 0.23.0
2
+
3
+ ### Additions/Changes
4
+
5
+ * Allow some HTML in banner and descriptions (https://github.com/jnunemaker/flipper/pull/570).
6
+ * Moved some cloud headers to http client (https://github.com/jnunemaker/flipper/pull/567).
7
+ * Update flipper-ui jquery and bootstrap versions (https://github.com/jnunemaker/flipper/issues/565 and https://github.com/jnunemaker/flipper/pull/566).
8
+ * Moved docs to www.flippercloud.io/docs (https://github.com/jnunemaker/flipper/pull/574).
9
+ * PStore adapter now defaults to thread safe and no longer supports `.thread_safe` (https://github.com/jnunemaker/flipper/commit/4048704fefe41b716015294a19a0b94546637630).
10
+ * Add failover adapter (https://github.com/jnunemaker/flipper/pull/584).
11
+ * Improve http adapter error message (https://github.com/jnunemaker/flipper/pull/587).
12
+ * Rails 7 support (mostly in https://github.com/jnunemaker/flipper/pull/592).
13
+
14
+ ## 0.22.2
15
+
16
+ ### Additions/Changes
17
+
18
+ * 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)
19
+
20
+ ### Bug Fixes
21
+
22
+ * Fix railtie initialization to avoid altering middleware order (https://github.com/jnunemaker/flipper/pull/563)
23
+
24
+ ## 0.22.1
25
+
26
+ ### Additions/Changes
27
+
28
+ * Remove Octicons and replace with a pure CSS status circle (https://github.com/jnunemaker/flipper/pull/547)
29
+ * Rescue unique errors in AR and Sequel when setting value (https://github.com/jnunemaker/flipper/commit/87f5a98bce7baad7a27b75b5bce3256967769f27)
30
+ * Add a Content-Security-Policy to flipper-ui (https://github.com/jnunemaker/flipper/pull/552)
31
+ * Fix Synchronizer issue that occurs for ActiveRecord adapter (https://github.com/jnunemaker/flipper/pull/554)
32
+
33
+ ## 0.22.0
34
+
35
+ ### Additions/Changes
36
+
37
+ * Enable log subscriber by default in Rails (https://github.com/jnunemaker/flipper/pull/525)
38
+ * 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.
39
+ * Fix SQL reserved word use in get_all for ActiveRecord and Sequel (https://github.com/jnunemaker/flipper/pull/536).
40
+ * Handle spaces in names gracefully in UI (https://github.com/jnunemaker/flipper/pull/541).
41
+
1
42
  ## 0.21.0
2
43
 
3
44
  ### Additions/Changes
@@ -7,7 +48,7 @@
7
48
  * 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
49
  * 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
50
  * 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/Optimization.md#memoization). (https://github.com/jnunemaker/flipper/pull/506)
51
+ * 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
52
 
12
53
  ### Upgrading
13
54
 
@@ -22,7 +63,7 @@ You should be able to upgrade to 0.21 without any breaking changes. However, if
22
63
  - end
23
64
  ```
24
65
 
25
- 2. `Flipper::Middleware::Memoizer` will be enabled by default.
66
+ 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
67
 
27
68
  ```diff
28
69
  # config/initializers/flipper.rb
@@ -31,6 +72,9 @@ You should be able to upgrade to 0.21 without any breaking changes. However, if
31
72
  + Rails.application.configure do
32
73
  + # Uncomment to configure which features to preload on all requests
33
74
  + # config.flipper.preload = [:stats, :search, :some_feature]
75
+ + #
76
+ + # Or, you may want to disable preloading entirely:
77
+ + # config.flipper.preload = false
34
78
  + end
35
79
  ```
36
80
 
data/Gemfile CHANGED
@@ -13,12 +13,13 @@ 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'] || '6.0.0'}"
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 'climate_control'
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](#adapters), for example:
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
- #### Enable a feature for a specific actor
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
- First tell Flipper about your groups:
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
- ```ruby
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
- Or, (even better than OSS + UI) use [Flipper Cloud](https://www.flippercloud.io) which comes with:
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
- # postgres:
2
- # container_name: flipper_postgres
3
- # image: postgres:9.4
4
- redis:
5
- container_name: flipper_redis
6
- image: redis:2.8
7
- mongo:
8
- container_name: flipper_mongo
9
- image: mongo:3.3
10
- memcached:
11
- container_name: flipper_memcached
12
- image: memcached:1.4.33
13
- app:
14
- container_name: flipper_app
15
- build: .
16
- dockerfile: Dockerfile
17
- volumes:
18
- - .:/srv/app
19
- volumes_from:
20
- - bundle_cache
21
- links:
22
- # - postgres
23
- - redis
24
- - mongo
25
- - memcached
26
- environment:
27
- - REDIS_URL=redis://redis:6379
28
- - MONGODB_HOST=mongo
29
- - MEMCACHED_URL=memcached:11211
30
- bundle_cache:
31
- container_name: flipper_bundle_cache
32
- image: busybox
33
- volumes:
34
- - /bundle_cache
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.
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
@@ -34,33 +34,27 @@ module Flipper
34
34
  end
35
35
 
36
36
  def add(feature)
37
- result = @remote.add(feature)
38
- @local.add(feature)
39
- result
37
+ @remote.add(feature).tap { @local.add(feature) }
40
38
  end
41
39
 
42
40
  def remove(feature)
43
- result = @remote.remove(feature)
44
- @local.remove(feature)
45
- result
41
+ @remote.remove(feature).tap { @local.remove(feature) }
46
42
  end
47
43
 
48
44
  def clear(feature)
49
- result = @remote.clear(feature)
50
- @local.clear(feature)
51
- result
45
+ @remote.clear(feature).tap { @local.clear(feature) }
52
46
  end
53
47
 
54
48
  def enable(feature, gate, thing)
55
- result = @remote.enable(feature, gate, thing)
56
- @local.enable(feature, gate, thing)
57
- result
49
+ @remote.enable(feature, gate, thing).tap do
50
+ @local.enable(feature, gate, thing)
51
+ end
58
52
  end
59
53
 
60
54
  def disable(feature, gate, thing)
61
- result = @remote.disable(feature, gate, thing)
62
- @local.disable(feature, gate, thing)
63
- result
55
+ @remote.disable(feature, gate, thing).tap do
56
+ @local.disable(feature, gate, thing)
57
+ end
64
58
  end
65
59
  end
66
60
  end