flipper 0.22.1 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +1 -0
  3. data/.github/dependabot.yml +6 -0
  4. data/.github/workflows/ci.yml +26 -15
  5. data/.github/workflows/examples.yml +21 -15
  6. data/.rspec +1 -0
  7. data/.tool-versions +1 -0
  8. data/Changelog.md +144 -4
  9. data/Dockerfile +1 -1
  10. data/Gemfile +9 -6
  11. data/README.md +15 -67
  12. data/Rakefile +4 -2
  13. data/benchmark/enabled_ips.rb +10 -0
  14. data/benchmark/enabled_multiple_actors_ips.rb +20 -0
  15. data/benchmark/enabled_profile.rb +20 -0
  16. data/benchmark/instrumentation_ips.rb +21 -0
  17. data/benchmark/typecast_ips.rb +19 -0
  18. data/docs/README.md +1 -0
  19. data/docs/images/banner.jpg +0 -0
  20. data/examples/api/basic.ru +3 -4
  21. data/examples/api/custom_memoized.ru +3 -4
  22. data/examples/api/memoized.ru +3 -4
  23. data/examples/dsl.rb +3 -3
  24. data/examples/enabled_for_actor.rb +4 -2
  25. data/examples/instrumentation.rb +1 -0
  26. data/examples/instrumentation_last_accessed_at.rb +1 -0
  27. data/flipper.gemspec +2 -2
  28. data/lib/flipper/actor.rb +4 -0
  29. data/lib/flipper/adapter.rb +23 -7
  30. data/lib/flipper/adapters/dual_write.rb +10 -16
  31. data/lib/flipper/adapters/failover.rb +83 -0
  32. data/lib/flipper/adapters/failsafe.rb +76 -0
  33. data/lib/flipper/adapters/http/client.rb +18 -12
  34. data/lib/flipper/adapters/http/error.rb +19 -1
  35. data/lib/flipper/adapters/http.rb +14 -4
  36. data/lib/flipper/adapters/instrumented.rb +25 -2
  37. data/lib/flipper/adapters/memoizable.rb +27 -18
  38. data/lib/flipper/adapters/memory.rb +56 -39
  39. data/lib/flipper/adapters/operation_logger.rb +16 -3
  40. data/lib/flipper/adapters/poll/poller.rb +2 -0
  41. data/lib/flipper/adapters/poll.rb +39 -0
  42. data/lib/flipper/adapters/pstore.rb +2 -5
  43. data/lib/flipper/adapters/sync/interval_synchronizer.rb +1 -6
  44. data/lib/flipper/adapters/sync.rb +9 -15
  45. data/lib/flipper/dsl.rb +9 -11
  46. data/lib/flipper/errors.rb +3 -20
  47. data/lib/flipper/export.rb +26 -0
  48. data/lib/flipper/exporter.rb +17 -0
  49. data/lib/flipper/exporters/json/export.rb +32 -0
  50. data/lib/flipper/exporters/json/v1.rb +33 -0
  51. data/lib/flipper/feature.rb +32 -26
  52. data/lib/flipper/feature_check_context.rb +10 -6
  53. data/lib/flipper/gate.rb +12 -11
  54. data/lib/flipper/gate_values.rb +0 -16
  55. data/lib/flipper/gates/actor.rb +10 -17
  56. data/lib/flipper/gates/boolean.rb +1 -1
  57. data/lib/flipper/gates/group.rb +5 -7
  58. data/lib/flipper/gates/percentage_of_actors.rb +10 -13
  59. data/lib/flipper/gates/percentage_of_time.rb +1 -2
  60. data/lib/flipper/identifier.rb +2 -2
  61. data/lib/flipper/instrumentation/log_subscriber.rb +7 -3
  62. data/lib/flipper/instrumentation/subscriber.rb +8 -1
  63. data/lib/flipper/instrumenters/memory.rb +6 -2
  64. data/lib/flipper/metadata.rb +1 -1
  65. data/lib/flipper/middleware/memoizer.rb +2 -12
  66. data/lib/flipper/poller.rb +117 -0
  67. data/lib/flipper/railtie.rb +23 -22
  68. data/lib/flipper/spec/shared_adapter_specs.rb +23 -0
  69. data/lib/flipper/test/shared_adapter_test.rb +24 -0
  70. data/lib/flipper/typecast.rb +28 -15
  71. data/lib/flipper/types/actor.rb +19 -13
  72. data/lib/flipper/types/group.rb +12 -5
  73. data/lib/flipper/version.rb +1 -1
  74. data/lib/flipper.rb +6 -4
  75. data/spec/fixtures/flipper_pstore_1679087600.json +46 -0
  76. data/spec/flipper/actor_spec.rb +10 -2
  77. data/spec/flipper/adapter_spec.rb +29 -4
  78. data/spec/flipper/adapters/dual_write_spec.rb +0 -2
  79. data/spec/flipper/adapters/failover_spec.rb +129 -0
  80. data/spec/flipper/adapters/failsafe_spec.rb +58 -0
  81. data/spec/flipper/adapters/http_spec.rb +64 -6
  82. data/spec/flipper/adapters/instrumented_spec.rb +28 -12
  83. data/spec/flipper/adapters/memoizable_spec.rb +30 -12
  84. data/spec/flipper/adapters/memory_spec.rb +3 -4
  85. data/spec/flipper/adapters/operation_logger_spec.rb +29 -12
  86. data/spec/flipper/adapters/pstore_spec.rb +0 -2
  87. data/spec/flipper/adapters/read_only_spec.rb +0 -1
  88. data/spec/flipper/adapters/sync/feature_synchronizer_spec.rb +0 -1
  89. data/spec/flipper/adapters/sync/interval_synchronizer_spec.rb +4 -5
  90. data/spec/flipper/adapters/sync/synchronizer_spec.rb +0 -1
  91. data/spec/flipper/adapters/sync_spec.rb +0 -2
  92. data/spec/flipper/configuration_spec.rb +0 -1
  93. data/spec/flipper/dsl_spec.rb +38 -12
  94. data/spec/flipper/export_spec.rb +13 -0
  95. data/spec/flipper/exporter_spec.rb +16 -0
  96. data/spec/flipper/exporters/json/export_spec.rb +60 -0
  97. data/spec/flipper/exporters/json/v1_spec.rb +33 -0
  98. data/spec/flipper/feature_check_context_spec.rb +17 -19
  99. data/spec/flipper/feature_spec.rb +76 -33
  100. data/spec/flipper/gate_spec.rb +0 -2
  101. data/spec/flipper/gate_values_spec.rb +2 -34
  102. data/spec/flipper/gates/actor_spec.rb +0 -2
  103. data/spec/flipper/gates/boolean_spec.rb +1 -3
  104. data/spec/flipper/gates/group_spec.rb +2 -5
  105. data/spec/flipper/gates/percentage_of_actors_spec.rb +61 -7
  106. data/spec/flipper/gates/percentage_of_time_spec.rb +2 -4
  107. data/spec/flipper/identifier_spec.rb +0 -1
  108. data/spec/flipper/instrumentation/log_subscriber_spec.rb +15 -6
  109. data/spec/flipper/instrumentation/statsd_subscriber_spec.rb +10 -1
  110. data/spec/flipper/instrumenters/memory_spec.rb +18 -1
  111. data/spec/flipper/instrumenters/noop_spec.rb +14 -8
  112. data/spec/flipper/middleware/memoizer_spec.rb +0 -23
  113. data/spec/flipper/middleware/setup_env_spec.rb +0 -2
  114. data/spec/flipper/poller_spec.rb +47 -0
  115. data/spec/flipper/railtie_spec.rb +73 -33
  116. data/spec/flipper/registry_spec.rb +0 -1
  117. data/spec/flipper/typecast_spec.rb +82 -4
  118. data/spec/flipper/types/actor_spec.rb +45 -46
  119. data/spec/flipper/types/boolean_spec.rb +0 -1
  120. data/spec/flipper/types/group_spec.rb +2 -3
  121. data/spec/flipper/types/percentage_of_actors_spec.rb +0 -1
  122. data/spec/flipper/types/percentage_of_time_spec.rb +0 -1
  123. data/spec/flipper/types/percentage_spec.rb +0 -1
  124. data/spec/flipper_integration_spec.rb +62 -51
  125. data/spec/flipper_spec.rb +7 -2
  126. data/spec/{helper.rb → spec_helper.rb} +4 -2
  127. data/spec/support/skippable.rb +18 -0
  128. data/spec/support/spec_helpers.rb +2 -6
  129. metadata +61 -19
  130. data/docs/Adapters.md +0 -124
  131. data/docs/Caveats.md +0 -4
  132. data/docs/Gates.md +0 -167
  133. data/docs/Instrumentation.md +0 -27
  134. data/docs/Optimization.md +0 -137
  135. data/docs/api/README.md +0 -884
  136. data/docs/http/README.md +0 -36
  137. data/docs/read-only/README.md +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14514238ff1ea823df0cefeb2e1048816b86995d582e6c3dda037d36db344078
4
- data.tar.gz: 285650a29a45623ed0468a08736621ccf88a6453eeadd8f42a29740a4a2955bc
3
+ metadata.gz: a581a01f7e6dade34fb261d0b6215f262125e4041a0095081dd54719db303656
4
+ data.tar.gz: 1d3df8718d8a46f88cb33e97e4ef2d193e0eae2dd2cf4eecd23fc87dd977d11a
5
5
  SHA512:
6
- metadata.gz: 3af99a75cafb349025fd03a6c2bab4bb224f76acd2a0ac820bf6306ded28235b615fc0f891ce8d3df7612eca26d631fc7a51fb6ee738fdfdb614a561b121af04
7
- data.tar.gz: bbaa9c0da5be73f4d1ab4ebc284919585878162e2c0151e346d77ad6909fddff7d0da7eff823ad29281d645e521d53e21f1de9184efda072e90e919d465a2c48
6
+ metadata.gz: e56bd86ca42668104197ad8b64596f7639bbf25c04ac48e3da6cff8f3d71736ab62282d9e01a13f2eb85fa7c058a11e2360e1a260fe249972e16f911d83ca2f5
7
+ data.tar.gz: a11b459234c76ac9ab928b26c9e12009736af655f602a04557d776dc72579877cf1b7ab38f4faecd54d49b765186ff0bf754eef174a96ee1f5a584daf2dacd16
data/.codeclimate.yml CHANGED
@@ -1,2 +1,3 @@
1
1
  exclude_patterns:
2
2
  - "lib/flipper/ui/public"
3
+ - "spec/"
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
@@ -15,39 +15,50 @@ jobs:
15
15
  --health-retries 5
16
16
  strategy:
17
17
  matrix:
18
- ruby: ['2.5', '2.6', '2.7']
19
- rails: ['5.2', '6.0.0', '6.1.0']
18
+ ruby: ['2.6', '2.7', '3.0', '3.1', '3.2']
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"
29
+ - ruby: "3.2"
30
+ rails: "5.2"
31
+ - ruby: "3.2"
32
+ rails: "6.0.0"
33
+ - ruby: "3.2"
34
+ rails: "6.1.0"
20
35
  env:
21
36
  SQLITE3_VERSION: 1.4.1
22
37
  REDIS_URL: redis://localhost:6379/0
23
38
  CI: true
39
+ RAILS_VERSION: ${{ matrix.rails }}
24
40
  steps:
25
41
  - name: Setup memcached
26
42
  uses: KeisukeYamashita/memcached-actions@v1
27
43
  - name: Start MongoDB
28
- uses: supercharge/mongodb-github-action@1.3.0
44
+ uses: supercharge/mongodb-github-action@1.9.0
29
45
  with:
30
46
  mongodb-version: 4.0
31
47
  - name: Check out repository code
32
- uses: actions/checkout@v2
48
+ uses: actions/checkout@v3
33
49
  - name: Do some action caching
34
- uses: actions/cache@v1
50
+ uses: actions/cache@v3
35
51
  with:
36
52
  path: vendor/bundle
37
53
  key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-${{ hashFiles('**/Gemfile.lock') }}
38
54
  restore-keys: |
39
55
  ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-
56
+ - name: Install libpq-dev
57
+ run: sudo apt-get -yqq install libpq-dev
40
58
  - name: Set up Ruby ${{ matrix.ruby }}
41
- uses: actions/setup-ruby@v1
59
+ uses: ruby/setup-ruby@v1
42
60
  with:
43
61
  ruby-version: ${{ matrix.ruby }}
44
- - name: Install libpq-dev
45
- run: sudo apt-get -yqq install libpq-dev
46
- - name: Install bundler
47
- run: gem install bundler
62
+ bundler-cache: true # 'bundle install' and cache gems
48
63
  - name: Run Rake with Rails ${{ matrix.rails }}
49
- env:
50
- RAILS_VERSION: ${{ matrix.rails }}
51
- run: |
52
- bundle install --jobs 4 --retry 3
53
- bundle exec rake
64
+ run: bundle exec rake
@@ -2,6 +2,7 @@ name: Examples
2
2
  on: [push, pull_request]
3
3
  jobs:
4
4
  test:
5
+ if: github.repository_owner == 'jnunemaker'
5
6
  name: Test on ruby ${{ matrix.ruby }} and rails ${{ matrix.rails }}
6
7
  runs-on: ubuntu-latest
7
8
  services:
@@ -15,42 +16,47 @@ jobs:
15
16
  --health-retries 5
16
17
  strategy:
17
18
  matrix:
18
- ruby: ['2.5', '2.6', '2.7']
19
- rails: ['5.2', '6.0.0', '6.1.0']
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
+
20
31
  env:
21
32
  SQLITE3_VERSION: 1.4.1
22
33
  REDIS_URL: redis://localhost:6379/0
23
34
  CI: true
35
+ RAILS_VERSION: ${{ matrix.rails }}
24
36
  steps:
25
37
  - name: Setup memcached
26
38
  uses: KeisukeYamashita/memcached-actions@v1
27
39
  - name: Start MongoDB
28
- uses: supercharge/mongodb-github-action@1.3.0
40
+ uses: supercharge/mongodb-github-action@1.9.0
29
41
  with:
30
42
  mongodb-version: 4.0
31
43
  - name: Check out repository code
32
- uses: actions/checkout@v2
44
+ uses: actions/checkout@v3
33
45
  - name: Do some action caching
34
- uses: actions/cache@v1
46
+ uses: actions/cache@v3
35
47
  with:
36
48
  path: vendor/bundle
37
49
  key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-${{ hashFiles('**/Gemfile.lock') }}
38
50
  restore-keys: |
39
51
  ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.rails }}-
52
+ - name: Install libpq-dev
53
+ run: sudo apt-get -yqq install libpq-dev
40
54
  - name: Set up Ruby ${{ matrix.ruby }}
41
- uses: actions/setup-ruby@v1
55
+ uses: ruby/setup-ruby@v1
42
56
  with:
43
57
  ruby-version: ${{ matrix.ruby }}
44
- - name: Install libpq-dev
45
- run: sudo apt-get -yqq install libpq-dev
46
- - name: Install bundler
47
- run: gem install bundler
48
- - name: Bundle install with Rails ${{ matrix.rails }}
49
- env:
50
- RAILS_VERSION: ${{ matrix.rails }}
51
- run: bundle install --jobs 4 --retry 3
58
+ bundler-cache: true # 'bundle install' and cache gems
52
59
  - name: Run Examples with Rails ${{ matrix.rails }}
53
60
  env:
54
61
  FLIPPER_CLOUD_TOKEN: ${{ secrets.FLIPPER_CLOUD_TOKEN }}
55
- RAILS_VERSION: ${{ matrix.rails }}
56
62
  run: script/examples
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.1.2
data/Changelog.md CHANGED
@@ -1,6 +1,143 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## 0.28.0
6
+
7
+ ### Additions/Changes
8
+
9
+ * Allow multiple actors for Flipper.enabled?. Improves performance of feature flags for multiple actors and simplifies code for users of flipper. This likely breaks things for anyone using Flipper internal classes related to actors, but that isn't likely you so you should be fine.
10
+ ```diff
11
+ - [user, user.team, user.org].any? { |actor| Flipper.enabled?(:my_feature, actor) }
12
+ + Flipper.enabled?(:my_feature, user, user.team, user.org)
13
+ ```
14
+
15
+ ### Deprecations
16
+
17
+ * `:thing` in `enabled?` instrumentation payload. Use `:actors` instead.
18
+ ```diff
19
+ ActiveSupport::Notifications.subscribe('enabled?.feature_operation.flipper') do |name, start, finish, id, payload|
20
+ - payload[:thing]
21
+ + payload[:actors]
22
+ end
23
+ ```
24
+
25
+ ## 0.27.1
26
+
27
+ * Quick fix for missing require of "flipper/version" that was causing issues with some flipper-ui people.
28
+
29
+ ## 0.27.0
30
+
31
+ * Easy Import/Export (https://github.com/jnunemaker/flipper/pull/709). This has some breaking changes but only if you are using flipper internals. If you are just using Flipper.* methods, you'll be fine.
32
+
33
+ ## 0.26.2
34
+
35
+ * Improve Active Record Adapter get/get_multi/get_all performance by 5-10x when dealing with thousands of gate values (https://github.com/jnunemaker/flipper/pull/707).
36
+
37
+ ## 0.26.1
38
+
39
+ * Improve `Flipper#enabled?` performance by ~37%-55% (https://github.com/jnunemaker/flipper/pull/706)
40
+ * Make Memory adapter threadsafe (https://github.com/jnunemaker/flipper/pull/702 and https://github.com/jnunemaker/flipper/pull/703)
41
+ * ActiveRecord adapter: wrap all reads/writes in `with_connection` (https://github.com/jnunemaker/flipper/pull/705)
42
+ * Improve performance of background polling (https://github.com/jnunemaker/flipper/pull/699)
43
+ * Remove executables directive from gem (https://github.com/jnunemaker/flipper/pull/693)
44
+
45
+ ## 0.26.0
46
+
47
+ * Cloud Background Polling (https://github.com/jnunemaker/flipper/pull/682)
48
+ * Changed default branch from master to main
49
+ * Allow configuring railtie via ENV vars (https://github.com/jnunemaker/flipper/pull/681)
50
+ * flipper-ui: Fix issue preventing feature flags being enabled when confirm_fully_enable is on and feature_removal_enabled is off (https://github.com/jnunemaker/flipper/pull/680)
51
+
52
+ ## 0.25.4
53
+
54
+ * Added read_only UI config option (https://github.com/jnunemaker/flipper/pull/679)
55
+
56
+ ## 0.25.3
57
+
58
+ * Added configurable confirm warning for fully enabling a feature (https://github.com/jnunemaker/flipper/pull/665)
59
+ * Update rack protection to < 4 (https://github.com/jnunemaker/flipper/pull/675)
60
+ * Check sadd_returns_boolean on the actual client class rather than ::Redis (https://github.com/jnunemaker/flipper/pull/677)
61
+
62
+ ## 0.25.2
63
+
64
+ * Fix deprecation warnings for Redis >= 4.8.0 (https://github.com/jnunemaker/flipper/pull/660)
65
+
66
+ ## 0.25.1
67
+
68
+ ### Additions/Changes
69
+
70
+ * ActiveRecord: use provided `gate_class` option when calling `#get_all` (https://github.com/jnunemaker/flipper/pull/647)
71
+ * Relaxed the rack-protection version to support latest (https://github.com/jnunemaker/flipper/commit/f4a41c541ccf14c535a61c6bc6fe7eeabbfc7e71).
72
+ * Configure ActiveRecord adapter immediately upon require of flipper-active_record (https://github.com/jnunemaker/flipper/pull/652)
73
+
74
+ ## 0.25.0
75
+
76
+ ### Additions/Changes
77
+
78
+ * Added a prompt in Flipper UI for the 'Delete' button to prevent accidental delete of features (https://github.com/jnunemaker/flipper/pull/625)
79
+ * Added failsafe adapter (https://github.com/jnunemaker/flipper/pull/626)
80
+ * 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)
81
+ * ActiveRecord: base class for internal models (https://github.com/jnunemaker/flipper/pull/629)
82
+ * Remove use of `Rack::BodyProxy` in the memoizer middleware (https://github.com/jnunemaker/flipper/pull/631)
83
+
84
+ ## 0.24.1
85
+
86
+ ### Additions/Changes
87
+
88
+ * flipper-api: `exclude_gates` parameter to exclude gate data in GETs (https://github.com/jnunemaker/flipper/pull/572).
89
+ * Make it possible to disable internal memoization (https://github.com/jnunemaker/flipper/pull/612).
90
+ * Add Flipper::Actor#hash so actors can be hash keys (https://github.com/jnunemaker/flipper/pull/616).
91
+ * Pretty Up `rails routes` again and make rack-protection dependency less strict (https://github.com/jnunemaker/flipper/pull/619).
92
+ * Add kwargs for method_missing using ruby 3.0 (https://github.com/jnunemaker/flipper/pull/620).
93
+ * Relax the rack-protection dependency (https://github.com/jnunemaker/flipper/commit/c1cb9cd78140c2b09123687642558101e6e5d37d).
94
+
95
+ ## 0.24.0
96
+
97
+ ### Additions/Changes
98
+
99
+ * 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)
100
+ * Removed support for Ruby 2.5 (which was end of line 9 months ago)
101
+ * Add (alpha) client side instrumentation of events to cloud (https://github.com/jnunemaker/flipper/pull/602)
102
+ * Fix deprecated uses of Redis#pipelined (https://github.com/jnunemaker/flipper/pull/603). redis-rb >= 3 now required.
103
+ * Fix Flipper UI Rack application when `Rack::Session::Pool` is used to build it (https://github.com/jnunemaker/flipper/pull/606).
104
+
105
+ ## 0.23.1
106
+
107
+ ### Additions/Changes
108
+
109
+ * Relax dalli version constraint (https://github.com/jnunemaker/flipper/pull/596)
110
+
111
+ ### Bug Fixes
112
+
113
+ * Fix railtie initialization to mount middleware after config/intializers/* (https://github.com/jnunemaker/flipper/pull/586)
114
+
115
+ ## 0.23.0
116
+
117
+ ### Additions/Changes
118
+
119
+ * Allow some HTML in banner and descriptions (https://github.com/jnunemaker/flipper/pull/570).
120
+ * Moved some cloud headers to http client (https://github.com/jnunemaker/flipper/pull/567).
121
+ * Update flipper-ui jquery and bootstrap versions (https://github.com/jnunemaker/flipper/issues/565 and https://github.com/jnunemaker/flipper/pull/566).
122
+ * Moved docs to www.flippercloud.io/docs (https://github.com/jnunemaker/flipper/pull/574).
123
+ * PStore adapter now defaults to thread safe and no longer supports `.thread_safe` (https://github.com/jnunemaker/flipper/commit/4048704fefe41b716015294a19a0b94546637630).
124
+ * Add failover adapter (https://github.com/jnunemaker/flipper/pull/584).
125
+ * Improve http adapter error message (https://github.com/jnunemaker/flipper/pull/587).
126
+ * Rails 7 support (mostly in https://github.com/jnunemaker/flipper/pull/592).
127
+
128
+ ## 0.22.2
129
+
130
+ ### Additions/Changes
131
+
132
+ * 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)
133
+
134
+ ### Bug Fixes
135
+
136
+ * Fix railtie initialization to avoid altering middleware order (https://github.com/jnunemaker/flipper/pull/563)
137
+
1
138
  ## 0.22.1
2
139
 
3
- ## Additions/Changes
140
+ ### Additions/Changes
4
141
 
5
142
  * Remove Octicons and replace with a pure CSS status circle (https://github.com/jnunemaker/flipper/pull/547)
6
143
  * Rescue unique errors in AR and Sequel when setting value (https://github.com/jnunemaker/flipper/commit/87f5a98bce7baad7a27b75b5bce3256967769f27)
@@ -9,7 +146,7 @@
9
146
 
10
147
  ## 0.22.0
11
148
 
12
- ## Additions/Changes
149
+ ### Additions/Changes
13
150
 
14
151
  * Enable log subscriber by default in Rails (https://github.com/jnunemaker/flipper/pull/525)
15
152
  * 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.
@@ -25,7 +162,7 @@
25
162
  * 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)
26
163
  * Added default `flipper_id` implementation via `Flipper::Identifier` and automatically included it in ActiveRecord and Sequel models (https://github.com/jnunemaker/flipper/pull/505)
27
164
  * Deprecate superflous sync_method setting (https://github.com/jnunemaker/flipper/pull/511)
28
- * 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)
165
+ * 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)
29
166
 
30
167
  ### Upgrading
31
168
 
@@ -40,7 +177,7 @@ You should be able to upgrade to 0.21 without any breaking changes. However, if
40
177
  - end
41
178
  ```
42
179
 
43
- 2. `Flipper::Middleware::Memoizer` will be enabled by default.
180
+ 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.
44
181
 
45
182
  ```diff
46
183
  # config/initializers/flipper.rb
@@ -49,6 +186,9 @@ You should be able to upgrade to 0.21 without any breaking changes. However, if
49
186
  + Rails.application.configure do
50
187
  + # Uncomment to configure which features to preload on all requests
51
188
  + # config.flipper.preload = [:stats, :search, :some_feature]
189
+ + #
190
+ + # Or, you may want to disable preloading entirely:
191
+ + # config.flipper.preload = false
52
192
  + end
53
193
  ```
54
194
 
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.5
1
+ FROM ruby:3.0
2
2
 
3
3
  RUN apt-get update && apt-get install -y \
4
4
  # build-essential \
data/Gemfile CHANGED
@@ -6,20 +6,23 @@ Dir['flipper-*.gemspec'].each do |gemspec|
6
6
  gemspec(name: "flipper-#{plugin}", development_group: plugin)
7
7
  end
8
8
 
9
- gem 'pry'
9
+ gem 'debug'
10
10
  gem 'rake', '~> 12.3.3'
11
- gem 'shotgun', '~> 0.9'
12
11
  gem 'statsd-ruby', '~> 1.2.1'
13
12
  gem 'rspec', '~> 3.0'
14
- gem 'rack-test', '~> 0.6.3'
13
+ gem 'rack-test'
15
14
  gem 'sqlite3', "~> #{ENV['SQLITE3_VERSION'] || '1.4.1'}"
16
- gem 'rails', "~> #{ENV['RAILS_VERSION'] || '6.0.0'}"
17
- gem 'minitest', '~> 5.8'
15
+ gem 'rails', "~> #{ENV['RAILS_VERSION'] || '7.0.0'}"
16
+ gem 'minitest', '~> 5.18'
18
17
  gem 'minitest-documentation'
19
18
  gem 'webmock', '~> 3.0'
20
- gem 'climate_control'
19
+ gem 'ice_age'
21
20
  gem 'redis-namespace'
22
21
  gem 'webrick'
22
+ gem 'stackprof'
23
+ gem 'benchmark-ips'
24
+ gem 'stackprof-webnav'
25
+ gem 'flamegraph'
23
26
 
24
27
  group(:guard) do
25
28
  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 &amp; Ship
37
+
38
+ [💌 &nbsp;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** &mdash; no need to bounce around from different application UIs or IRB consoles.
119
76
  * **permissions** &mdash; 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
@@ -158,6 +105,7 @@ A few miscellaneous docs with more info for the hungry.
158
105
  |---|---|---|
159
106
  | ![@jnunemaker](https://avatars3.githubusercontent.com/u/235?s=64) | [@jnunemaker](https://github.com/jnunemaker) | most things |
160
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 |
161
109
  | ![@alexwheeler](https://avatars3.githubusercontent.com/u/3260042?s=64) | [@alexwheeler](https://github.com/alexwheeler) | api |
162
110
  | ![@thetimbanks](https://avatars1.githubusercontent.com/u/471801?s=64) | [@thetimbanks](https://github.com/thetimbanks) | ui |
163
111
  | ![@lazebny](https://avatars1.githubusercontent.com/u/6276766?s=64) | [@lazebny](https://github.com/lazebny) | docker |
data/Rakefile CHANGED
@@ -18,9 +18,11 @@ end
18
18
  desc 'Tags version, pushes to remote, and pushes gem'
19
19
  task release: :build do
20
20
  sh 'git', 'tag', "v#{Flipper::VERSION}"
21
- sh 'git push origin master'
21
+ sh 'git push origin main'
22
22
  sh "git push origin v#{Flipper::VERSION}"
23
- sh 'ls pkg/*.gem | xargs -n 1 gem push'
23
+ puts "\nWhat OTP code should be used?"
24
+ otp_code = STDIN.gets.chomp
25
+ sh "ls pkg/*.gem | xargs -n 1 gem push --otp #{otp_code}"
24
26
  end
25
27
 
26
28
  require 'rspec/core/rake_task'
@@ -0,0 +1,10 @@
1
+ require 'bundler/setup'
2
+ require 'flipper'
3
+ require 'benchmark/ips'
4
+
5
+ actor = Flipper::Actor.new("User;1")
6
+
7
+ Benchmark.ips do |x|
8
+ x.report("with actor") { Flipper.enabled?(:foo, actor) }
9
+ x.report("without actor") { Flipper.enabled?(:foo) }
10
+ end
@@ -0,0 +1,20 @@
1
+ require 'bundler/setup'
2
+ require 'flipper'
3
+ require 'benchmark/ips'
4
+
5
+ actor1 = Flipper::Actor.new("User;1")
6
+ actor2 = Flipper::Actor.new("User;2")
7
+ actor3 = Flipper::Actor.new("User;3")
8
+ actor4 = Flipper::Actor.new("User;4")
9
+ actor5 = Flipper::Actor.new("User;5")
10
+ actor6 = Flipper::Actor.new("User;6")
11
+ actor7 = Flipper::Actor.new("User;7")
12
+ actor8 = Flipper::Actor.new("User;8")
13
+
14
+ actors = [actor1, actor2, actor3, actor4, actor5, actor6, actor7, actor8]
15
+
16
+ Benchmark.ips do |x|
17
+ x.report("with array of actors") { Flipper.enabled?(:foo, actors) }
18
+ x.report("with multiple enabled? checks") { actors.each { |actor| Flipper.enabled?(:foo, actor) } }
19
+ x.compare!
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'bundler/setup'
2
+ require 'flipper'
3
+ require 'stackprof'
4
+ require 'benchmark/ips'
5
+
6
+ flipper = Flipper.new(Flipper::Adapters::Memory.new)
7
+ feature = flipper.feature(:foo)
8
+ actor = Flipper::Actor.new("User;1")
9
+
10
+ profile = StackProf.run(mode: :wall, interval: 1_000) do
11
+ 2_000_000.times do
12
+ feature.enabled?(actor)
13
+ end
14
+ end
15
+
16
+ result = StackProf::Report.new(profile)
17
+ puts
18
+ result.print_text
19
+ puts "\n\n\n"
20
+ result.print_method(/Flipper::Feature#enabled?/)
@@ -0,0 +1,21 @@
1
+ require 'bundler/setup'
2
+ require 'flipper'
3
+ require 'active_support/notifications'
4
+ require 'active_support/isolated_execution_state'
5
+ require 'benchmark/ips'
6
+
7
+ class FlipperSubscriber
8
+ def call(name, start, finish, id, payload)
9
+ end
10
+
11
+ ActiveSupport::Notifications.subscribe(/flipper/, new)
12
+ end
13
+
14
+ actor = Flipper::Actor.new("User;1")
15
+ bare = Flipper.new(Flipper::Adapters::Memory.new)
16
+ instrumented = Flipper.new(Flipper::Adapters::Memory.new, instrumenter: ActiveSupport::Notifications)
17
+
18
+ Benchmark.ips do |x|
19
+ x.report("with instrumentation") { instrumented.enabled?(:foo, actor) }
20
+ x.report("without instrumentation") { bare.enabled?(:foo, actor) }
21
+ end
@@ -0,0 +1,19 @@
1
+ require 'bundler/setup'
2
+ require 'flipper'
3
+ require 'benchmark/ips'
4
+
5
+ Benchmark.ips do |x|
6
+ x.report("Typecast.to_boolean true") { Flipper::Typecast.to_boolean(true) }
7
+ x.report("Typecast.to_boolean 1") { Flipper::Typecast.to_boolean(1) }
8
+ x.report("Typecast.to_boolean 'true'") { Flipper::Typecast.to_boolean('true'.freeze) }
9
+ x.report("Typecast.to_boolean '1'") { Flipper::Typecast.to_boolean('1'.freeze) }
10
+ x.report("Typecast.to_boolean false") { Flipper::Typecast.to_boolean(false) }
11
+
12
+ x.report("Typecast.to_integer 1") { Flipper::Typecast.to_integer(1) }
13
+ x.report("Typecast.to_integer '1'") { Flipper::Typecast.to_integer('1') }
14
+
15
+ x.report("Typecast.to_float 1") { Flipper::Typecast.to_float(1) }
16
+ x.report("Typecast.to_float '1'") { Flipper::Typecast.to_float('1'.freeze) }
17
+ x.report("Typecast.to_float 1.01") { Flipper::Typecast.to_float(1) }
18
+ x.report("Typecast.to_float '1.01'") { Flipper::Typecast.to_float('1'.freeze) }
19
+ end
data/docs/README.md ADDED
@@ -0,0 +1 @@
1
+ See [flippercloud.io](https://flippercloud.io/docs) for extensive docs.
Binary file