flipper 1.4.2 → 1.5.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +70 -10
- data/lib/flipper/adapter.rb +24 -0
- data/lib/flipper/adapter_builder.rb +12 -1
- data/lib/flipper/adapters/actor_limit.rb +4 -3
- data/lib/flipper/adapters/cache_base.rb +17 -0
- data/lib/flipper/adapters/dual_write.rb +12 -0
- data/lib/flipper/adapters/failover.rb +15 -0
- data/lib/flipper/adapters/failsafe.rb +16 -0
- data/lib/flipper/adapters/http/client.rb +7 -3
- data/lib/flipper/adapters/http/redacted_debug_output.rb +70 -0
- data/lib/flipper/adapters/http.rb +42 -8
- data/lib/flipper/adapters/instrumented.rb +28 -0
- data/lib/flipper/adapters/memoizable.rb +21 -5
- data/lib/flipper/adapters/memory.rb +63 -31
- data/lib/flipper/adapters/poll.rb +51 -6
- data/lib/flipper/adapters/pstore.rb +15 -0
- data/lib/flipper/adapters/read_only.rb +1 -1
- data/lib/flipper/adapters/strict.rb +17 -1
- data/lib/flipper/adapters/sync/feature_synchronizer.rb +3 -1
- data/lib/flipper/adapters/sync/synchronizer.rb +20 -1
- data/lib/flipper/adapters/sync.rb +8 -0
- data/lib/flipper/adapters/wrapper.rb +7 -0
- data/lib/flipper/cli.rb +87 -22
- data/lib/flipper/cloud/configuration.rb +149 -19
- data/lib/flipper/cloud/dsl.rb +6 -0
- data/lib/flipper/cloud/memory_adapter.rb +43 -0
- data/lib/flipper/cloud/message_verifier.rb +1 -0
- data/lib/flipper/cloud/middleware.rb +8 -3
- data/lib/flipper/cloud/migrate.rb +3 -1
- data/lib/flipper/cloud/routes.rb +24 -2
- data/lib/flipper/cloud/shared_memory.rb +111 -0
- data/lib/flipper/cloud/telemetry.rb +56 -28
- data/lib/flipper/cloud/url_validator.rb +26 -0
- data/lib/flipper/cloud.rb +22 -4
- data/lib/flipper/configuration.rb +86 -3
- data/lib/flipper/dsl.rb +47 -3
- data/lib/flipper/engine.rb +64 -8
- data/lib/flipper/errors.rb +18 -0
- data/lib/flipper/export.rb +4 -0
- data/lib/flipper/exporters/json/export.rb +6 -0
- data/lib/flipper/exporters/json/v1.rb +5 -9
- data/lib/flipper/expression/constant.rb +6 -0
- data/lib/flipper/expression.rb +105 -1
- data/lib/flipper/expressions/comparable.rb +5 -0
- data/lib/flipper/expressions/feature_enabled.rb +11 -7
- data/lib/flipper/expressions/number.rb +2 -0
- data/lib/flipper/expressions/percentage.rb +3 -1
- data/lib/flipper/expressions/percentage_of_actors.rb +9 -0
- data/lib/flipper/expressions/random.rb +2 -0
- data/lib/flipper/expressions/sem_ver.rb +24 -0
- data/lib/flipper/expressions/time.rb +9 -1
- data/lib/flipper/feature.rb +153 -43
- data/lib/flipper/feature_check_context.rb +19 -1
- data/lib/flipper/gates/actor.rb +4 -1
- data/lib/flipper/gates/expression.rb +17 -2
- data/lib/flipper/gates/group.rb +1 -1
- data/lib/flipper/gates/percentage_of_actors.rb +19 -2
- data/lib/flipper/gates/percentage_of_time.rb +4 -1
- data/lib/flipper/groups.rb +66 -0
- data/lib/flipper/instrumentation/log_subscriber.rb +6 -1
- data/lib/flipper/instrumentation/subscriber.rb +21 -2
- data/lib/flipper/middleware/memoizer.rb +5 -2
- data/lib/flipper/named_configuration.rb +194 -0
- data/lib/flipper/named_proxy.rb +46 -0
- data/lib/flipper/poller.rb +39 -17
- data/lib/flipper/sem_ver.rb +84 -0
- data/lib/flipper/spec/shared_adapter_specs.rb +40 -0
- data/lib/flipper/sync_version.rb +61 -0
- data/lib/flipper/test_help.rb +50 -0
- data/lib/flipper/typecast.rb +15 -0
- data/lib/flipper/types/group.rb +2 -2
- data/lib/flipper/version.rb +1 -1
- data/lib/flipper.rb +183 -65
- data/lib/generators/flipper/setup_generator.rb +18 -0
- data/lib/generators/flipper/table_prefix.rb +44 -0
- data/lib/generators/flipper/templates/initializer.rb +7 -0
- data/lib/generators/flipper/templates/update/migrations/01_create_flipper_tables.rb.erb +13 -7
- data/lib/generators/flipper/templates/update/migrations/02_change_flipper_gates_value_to_text.rb.erb +12 -7
- data/lib/generators/flipper/update_generator.rb +3 -0
- metadata +42 -171
- data/.codeclimate.yml +0 -3
- data/.github/FUNDING.yml +0 -1
- data/.github/dependabot.yml +0 -6
- data/.github/workflows/ci.yml +0 -110
- data/.github/workflows/examples.yml +0 -105
- data/.github/workflows/release.yml +0 -54
- data/.rspec +0 -1
- data/.superset/config.json +0 -4
- data/CLAUDE.md +0 -93
- data/CODE_OF_CONDUCT.md +0 -46
- data/Dockerfile +0 -27
- data/Gemfile +0 -41
- data/Rakefile +0 -54
- data/benchmark/enabled_ips.rb +0 -10
- data/benchmark/enabled_multiple_actors_ips.rb +0 -20
- data/benchmark/enabled_profile.rb +0 -20
- data/benchmark/instrumentation_ips.rb +0 -21
- data/benchmark/typecast_ips.rb +0 -27
- data/docker-compose.yml +0 -37
- data/docs/DockerCompose.md +0 -18
- data/docs/README.md +0 -1
- data/docs/images/banner.jpg +0 -0
- data/docs/images/flipper_cloud.png +0 -0
- data/examples/api/basic.ru +0 -18
- data/examples/api/custom_memoized.ru +0 -36
- data/examples/api/memoized.ru +0 -42
- data/examples/basic.rb +0 -19
- data/examples/cloud/app.ru +0 -12
- data/examples/cloud/backoff_policy.rb +0 -13
- data/examples/cloud/basic.rb +0 -22
- data/examples/cloud/cloud_setup.rb +0 -20
- data/examples/cloud/forked.rb +0 -36
- data/examples/cloud/import.rb +0 -17
- data/examples/cloud/poll_interval/README.md +0 -111
- data/examples/cloud/poll_interval/client.rb +0 -108
- data/examples/cloud/poll_interval/server.rb +0 -98
- data/examples/cloud/threaded.rb +0 -33
- data/examples/configuring_default.rb +0 -19
- data/examples/dsl.rb +0 -57
- data/examples/enabled_for_actor.rb +0 -37
- data/examples/expressions.rb +0 -237
- data/examples/group.rb +0 -38
- data/examples/group_dynamic_lookup.rb +0 -75
- data/examples/group_with_members.rb +0 -83
- data/examples/importing.rb +0 -29
- data/examples/individual_actor.rb +0 -28
- data/examples/instrumentation.rb +0 -42
- data/examples/instrumentation_last_accessed_at.rb +0 -38
- data/examples/memoizing.rb +0 -35
- data/examples/mirroring.rb +0 -59
- data/examples/percentage_of_actors.rb +0 -31
- data/examples/percentage_of_actors_enabled_check.rb +0 -35
- data/examples/percentage_of_actors_group.rb +0 -35
- data/examples/percentage_of_time.rb +0 -27
- data/examples/strict.rb +0 -18
- data/flipper-cloud.gemspec +0 -19
- data/flipper.gemspec +0 -42
- data/package-lock.json +0 -41
- data/package.json +0 -10
- data/spec/fixtures/environment.rb +0 -1
- data/spec/fixtures/feature.json +0 -31
- data/spec/fixtures/flipper_pstore_1679087600.json +0 -46
- data/spec/flipper/actor_spec.rb +0 -56
- data/spec/flipper/adapter_builder_spec.rb +0 -72
- data/spec/flipper/adapter_spec.rb +0 -166
- data/spec/flipper/adapters/actor_limit_spec.rb +0 -75
- data/spec/flipper/adapters/dual_write_spec.rb +0 -82
- data/spec/flipper/adapters/failover_spec.rb +0 -141
- data/spec/flipper/adapters/failsafe_spec.rb +0 -58
- data/spec/flipper/adapters/http/client_spec.rb +0 -61
- data/spec/flipper/adapters/http_spec.rb +0 -596
- data/spec/flipper/adapters/instrumented_spec.rb +0 -167
- data/spec/flipper/adapters/memoizable_spec.rb +0 -377
- data/spec/flipper/adapters/memory_spec.rb +0 -36
- data/spec/flipper/adapters/operation_logger_spec.rb +0 -128
- data/spec/flipper/adapters/poll_spec.rb +0 -41
- data/spec/flipper/adapters/pstore_spec.rb +0 -16
- data/spec/flipper/adapters/read_only_spec.rb +0 -100
- data/spec/flipper/adapters/strict_spec.rb +0 -122
- data/spec/flipper/adapters/sync/feature_synchronizer_spec.rb +0 -247
- data/spec/flipper/adapters/sync/interval_synchronizer_spec.rb +0 -33
- data/spec/flipper/adapters/sync/synchronizer_spec.rb +0 -175
- data/spec/flipper/adapters/sync_spec.rb +0 -213
- data/spec/flipper/cli_spec.rb +0 -217
- data/spec/flipper/cloud/configuration_spec.rb +0 -251
- data/spec/flipper/cloud/dsl_spec.rb +0 -82
- data/spec/flipper/cloud/message_verifier_spec.rb +0 -104
- data/spec/flipper/cloud/middleware_spec.rb +0 -289
- data/spec/flipper/cloud/migrate_spec.rb +0 -160
- data/spec/flipper/cloud/telemetry/backoff_policy_spec.rb +0 -107
- data/spec/flipper/cloud/telemetry/metric_spec.rb +0 -87
- data/spec/flipper/cloud/telemetry/metric_storage_spec.rb +0 -58
- data/spec/flipper/cloud/telemetry/submitter_spec.rb +0 -145
- data/spec/flipper/cloud/telemetry_spec.rb +0 -208
- data/spec/flipper/cloud_spec.rb +0 -186
- data/spec/flipper/configuration_spec.rb +0 -50
- data/spec/flipper/dsl_spec.rb +0 -346
- data/spec/flipper/engine_spec.rb +0 -374
- data/spec/flipper/export_spec.rb +0 -13
- data/spec/flipper/exporter_spec.rb +0 -16
- data/spec/flipper/exporters/json/export_spec.rb +0 -60
- data/spec/flipper/exporters/json/v1_spec.rb +0 -33
- data/spec/flipper/expression/builder_spec.rb +0 -248
- data/spec/flipper/expression_spec.rb +0 -188
- data/spec/flipper/expressions/all_spec.rb +0 -15
- data/spec/flipper/expressions/any_spec.rb +0 -15
- data/spec/flipper/expressions/boolean_spec.rb +0 -15
- data/spec/flipper/expressions/equal_spec.rb +0 -24
- data/spec/flipper/expressions/greater_than_or_equal_to_spec.rb +0 -28
- data/spec/flipper/expressions/greater_than_spec.rb +0 -28
- data/spec/flipper/expressions/less_than_or_equal_to_spec.rb +0 -28
- data/spec/flipper/expressions/less_than_spec.rb +0 -32
- data/spec/flipper/expressions/not_equal_spec.rb +0 -15
- data/spec/flipper/expressions/now_spec.rb +0 -11
- data/spec/flipper/expressions/number_spec.rb +0 -21
- data/spec/flipper/expressions/percentage_of_actors_spec.rb +0 -20
- data/spec/flipper/expressions/percentage_spec.rb +0 -15
- data/spec/flipper/expressions/property_spec.rb +0 -13
- data/spec/flipper/expressions/random_spec.rb +0 -9
- data/spec/flipper/expressions/string_spec.rb +0 -11
- data/spec/flipper/expressions/time_spec.rb +0 -29
- data/spec/flipper/feature_check_context_spec.rb +0 -65
- data/spec/flipper/feature_spec.rb +0 -1227
- data/spec/flipper/gate_spec.rb +0 -39
- data/spec/flipper/gate_values_spec.rb +0 -103
- data/spec/flipper/gates/actor_spec.rb +0 -7
- data/spec/flipper/gates/boolean_spec.rb +0 -74
- data/spec/flipper/gates/expression_spec.rb +0 -190
- data/spec/flipper/gates/group_spec.rb +0 -62
- data/spec/flipper/gates/percentage_of_actors_spec.rb +0 -131
- data/spec/flipper/gates/percentage_of_time_spec.rb +0 -37
- data/spec/flipper/identifier_spec.rb +0 -12
- data/spec/flipper/instrumentation/log_subscriber_spec.rb +0 -122
- data/spec/flipper/instrumentation/statsd_subscriber_spec.rb +0 -95
- data/spec/flipper/instrumenters/memory_spec.rb +0 -43
- data/spec/flipper/instrumenters/noop_spec.rb +0 -27
- data/spec/flipper/middleware/memoizer_spec.rb +0 -518
- data/spec/flipper/middleware/setup_env_spec.rb +0 -94
- data/spec/flipper/model/active_record_spec.rb +0 -72
- data/spec/flipper/poller_spec.rb +0 -390
- data/spec/flipper/registry_spec.rb +0 -140
- data/spec/flipper/serializers/gzip_spec.rb +0 -13
- data/spec/flipper/serializers/json_spec.rb +0 -13
- data/spec/flipper/typecast_spec.rb +0 -232
- data/spec/flipper/types/actor_spec.rb +0 -132
- data/spec/flipper/types/boolean_spec.rb +0 -23
- data/spec/flipper/types/group_spec.rb +0 -112
- data/spec/flipper/types/percentage_of_actors_spec.rb +0 -5
- data/spec/flipper/types/percentage_of_time_spec.rb +0 -5
- data/spec/flipper/types/percentage_spec.rb +0 -46
- data/spec/flipper_integration_spec.rb +0 -783
- data/spec/flipper_spec.rb +0 -422
- data/spec/spec_helper.rb +0 -112
- data/spec/support/actor_names.yml +0 -1
- data/spec/support/descriptions.yml +0 -1
- data/spec/support/fail_on_output.rb +0 -8
- data/spec/support/fake_backoff_policy.rb +0 -15
- data/spec/support/fake_udp_socket.rb +0 -27
- data/spec/support/skippable.rb +0 -18
- data/spec/support/spec_helpers.rb +0 -111
- data/test/adapters/actor_limit_test.rb +0 -20
- data/test/adapters/memory_test.rb +0 -9
- data/test/adapters/pstore_test.rb +0 -17
- data/test/test_helper.rb +0 -7
- data/test_rails/generators/flipper/setup_generator_test.rb +0 -69
- data/test_rails/generators/flipper/update_generator_test.rb +0 -96
- data/test_rails/helper.rb +0 -31
- data/test_rails/system/test_help_test.rb +0 -52
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 28e85c4c99a54920a81f1fb1a1345e0d8e1492d149907636dbbf2d5218bad0eb
|
|
4
|
+
data.tar.gz: 1550707f666c820f6fa225637239b9084b87bddb69f5290755d8d4021e2be351
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e92e10677da51eb7a7da7336bd42aa9b37410f396dfbb04467d87c0ce390096781153f493270d52f8b46f6a0721e04e165416b6ec2968ea743106eb03d81f3f6
|
|
7
|
+
data.tar.gz: 8094d3cdb80b21bb47d7e4ab51886a9efe43e934341c3210513f885244922585cc9db352a546b8abb010cb7a70c563b80de3b4693d9631e437331c45a7551c11
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
[](https://www.flippercloud.io)
|
|
1
|
+
[](https://www.flippercloud.io)
|
|
2
2
|
|
|
3
|
-
[Website](https://flippercloud.io?utm_source=oss&utm_medium=readme&utm_campaign=website_link) | [Documentation](https://flippercloud.io/docs?utm_source=oss&utm_medium=readme&utm_campaign=docs_link) | [Examples](examples) | [Chat](https://chat.flippercloud.io/join/xjHq-aJsA-BeZH) | [Twitter](https://twitter.com/flipper_cloud) | [Ruby.social](https://ruby.social/@flipper)
|
|
3
|
+
[Website](https://flippercloud.io?utm_source=oss&utm_medium=readme&utm_campaign=website_link) | [Documentation](https://flippercloud.io/docs?utm_source=oss&utm_medium=readme&utm_campaign=docs_link) | [Examples](https://github.com/flippercloud/flipper/tree/main/examples) | [Chat](https://chat.flippercloud.io/join/xjHq-aJsA-BeZH) | [Twitter](https://twitter.com/flipper_cloud) | [Ruby.social](https://ruby.social/@flipper)
|
|
4
4
|
|
|
5
5
|
# Flipper
|
|
6
6
|
|
|
@@ -11,19 +11,39 @@ Flipper gives you control over who has access to features in your app.
|
|
|
11
11
|
- Enable or disable features for everyone, specific actors, groups of actors, a percentage of actors, or a percentage of time.
|
|
12
12
|
- Configure your feature flags from the console or a web UI.
|
|
13
13
|
- Regardless of what data store you are using, Flipper can performantly store your feature flags.
|
|
14
|
-
- Use [Flipper Cloud](#flipper-cloud) to cascade features from multiple environments, share settings with your team, control permissions, keep an audit history, and
|
|
14
|
+
- Use [Flipper Cloud](#flipper-cloud) to cascade features from multiple environments, share settings with your team, control permissions, keep an audit history, rollback, and let AI assistants find flags ready to remove.
|
|
15
15
|
|
|
16
16
|
Control your software — don't let it control you.
|
|
17
17
|
|
|
18
18
|
## Installation
|
|
19
19
|
|
|
20
|
+
### Rails
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
bundle add flipper-active_record
|
|
24
|
+
bin/rails g flipper:setup
|
|
25
|
+
bin/rails db:migrate
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`flipper-active_record` brings in `flipper` and stores your features in your database. `flipper:setup` creates `config/initializers/flipper.rb` and the migration. Prefer Redis, Sequel, or something else? Pick another [adapter](https://flippercloud.io/docs/adapters). Add [`flipper-ui`](https://flippercloud.io/docs/ui) for a web UI.
|
|
29
|
+
|
|
30
|
+
To move your features to [Flipper Cloud](#flipper-cloud) later (free plan, no token needed to start):
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
bundle exec flipper cloud migrate
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Cloud support is built into the `flipper` gem; the separate `flipper-cloud` gem is deprecated.
|
|
37
|
+
|
|
38
|
+
### Other Ruby apps
|
|
39
|
+
|
|
20
40
|
Add this line to your application's Gemfile:
|
|
21
41
|
|
|
22
42
|
gem 'flipper'
|
|
23
43
|
|
|
24
44
|
You'll also want to pick a storage [adapter](https://flippercloud.io/docs/adapters), for example:
|
|
25
45
|
|
|
26
|
-
gem 'flipper-
|
|
46
|
+
gem 'flipper-redis'
|
|
27
47
|
|
|
28
48
|
And then execute:
|
|
29
49
|
|
|
@@ -35,7 +55,11 @@ Or install it yourself with:
|
|
|
35
55
|
|
|
36
56
|
## Subscribe & Ship
|
|
37
57
|
|
|
38
|
-
[💌 Subscribe](https://
|
|
58
|
+
[💌 Subscribe](https://www.flippercloud.io/newsletter) - we'll send you short and sweet emails when we release new versions ([examples](https://www.flippercloud.io/blog/tag/releases)).
|
|
59
|
+
|
|
60
|
+
## Merch
|
|
61
|
+
|
|
62
|
+
Do you deploy on Fridays? [👕 Get the tee](https://shop.verygoodsoftware.company/product/i-deploy-on-fridays-tee?utm_source=oss&utm_medium=readme&utm_campaign=merch).
|
|
39
63
|
|
|
40
64
|
## Getting Started
|
|
41
65
|
|
|
@@ -68,21 +92,57 @@ Flipper.enable_percentage_of_actors :search, 2
|
|
|
68
92
|
|
|
69
93
|
Read more about [getting started with Flipper](https://flippercloud.io/docs?utm_source=oss&utm_medium=readme&utm_campaign=getting_started) and [enabling features](https://flippercloud.io/docs/features?utm_source=oss&utm_medium=readme&utm_campaign=enabling_features).
|
|
70
94
|
|
|
95
|
+
## Named Instances
|
|
96
|
+
|
|
97
|
+
Need a second, independent set of flags in the same app, such as flags shared across
|
|
98
|
+
several apps? Declare a named instance with its own adapter (and optionally its own
|
|
99
|
+
Flipper Cloud project). The top-level `Flipper` is unchanged.
|
|
100
|
+
|
|
101
|
+
```ruby
|
|
102
|
+
# config/initializers/flipper.rb
|
|
103
|
+
Flipper.configure do |config|
|
|
104
|
+
config.named(:cross_app) do |cross_app|
|
|
105
|
+
cross_app.adapter { Flipper::Adapters::ActiveRecord.new(table_prefix: "cross_app_") }
|
|
106
|
+
cross_app.cloud(path: "_flipper/cross_app") # optional; uses FLIPPER_CLOUD_CROSS_APP_TOKEN
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
CrossAppFlipper = Flipper.named(:cross_app)
|
|
111
|
+
CrossAppFlipper.enabled?(:chat_in_topbar, current_user)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Read the [named instances guide](https://www.flippercloud.io/docs/guides/named-instances?utm_source=oss&utm_medium=readme&utm_campaign=named_instances) for Active Record tables, groups, Cloud credentials, the UI, instrumentation and testing.
|
|
115
|
+
|
|
71
116
|
## Flipper Cloud
|
|
72
117
|
|
|
73
118
|
Like Flipper and want more? Check out [Flipper Cloud](https://www.flippercloud.io?utm_source=oss&utm_medium=readme&utm_campaign=check_out), which comes with:
|
|
74
119
|
|
|
75
|
-
- **multiple environments** — production, staging, per continent, whatever you need. Every environment inherits from production by default and every project comes with a [project overview page](https://
|
|
120
|
+
- **multiple environments** — production, staging, per continent, whatever you need. Every environment inherits from production by default and every project comes with a [project overview page](https://www.flippercloud.io/blog/project-overview) that shows each feature and its status in each environment.
|
|
76
121
|
- **personal environments** — everyone on your team gets a personal environment (that inherits from production) which they can modify however they want without stepping on anyone else's toes.
|
|
77
122
|
- **permissions** — grant access to everyone in your organization or lockdown each project to particular people. You can even limit access to a particular environment (like production) to specific people.
|
|
78
123
|
- **audit history** — every feature change and who made it.
|
|
79
124
|
- **rollbacks** — enable or disable a feature accidentally? No problem. You can roll back to any point in the audit history with a single click.
|
|
80
|
-
- **
|
|
125
|
+
- **MCP server** — connect Claude Code, Codex, Cursor, or any other AI assistant to your flags with our [MCP server](https://www.flippercloud.io/docs/cloud/mcp?utm_source=oss&utm_medium=readme&utm_campaign=mcp). Ask "Which Flipper flags can we remove?" and it checks every environment, your telemetry, and your audit history, then tells you which flags are done and why.
|
|
126
|
+
- **maintenance** — we'll keep the lights on for you. We also have handy webhooks and background polling for keeping your app in sync with Cloud, so **our availability won't affect yours**. All your feature flag reads are served from memory in your app.
|
|
81
127
|
- **everything in one place** — no need to bounce around from different application UIs or IRB consoles.
|
|
82
128
|
|
|
83
|
-
[](https://www.flippercloud.io?utm_source=oss&utm_medium=readme&utm_campaign=screenshot)
|
|
129
|
+
[](https://www.flippercloud.io?utm_source=oss&utm_medium=readme&utm_campaign=screenshot)
|
|
130
|
+
|
|
131
|
+
Cloud is super simple to integrate with Rails ([demo app](https://github.com/flippercloud/flipper-rails-demo)), Sinatra or any other framework.
|
|
132
|
+
|
|
133
|
+
### How Cloud reads work
|
|
134
|
+
|
|
135
|
+
When Cloud is your default (`FLIPPER_CLOUD_TOKEN` is set, with Rails or `Flipper::Cloud.set_default`), feature checks are served from one Memory adapter that every thread in the process shares. Checking a feature doesn't query your adapter (ActiveRecord, Redis, etc.).
|
|
84
136
|
|
|
85
|
-
|
|
137
|
+
- Memory is filled from your adapter when the process boots, so flags are there even if Cloud isn't reachable.
|
|
138
|
+
- Changes you make in your app go to Cloud, your adapter, and that process's Memory. Other processes get them from Cloud like any other change, as described below.
|
|
139
|
+
- **Polling** (the default): every process polls Cloud every 10 seconds, and each change is written to your adapter and Memory on the next feature check.
|
|
140
|
+
- **Webhooks** (`FLIPPER_CLOUD_SYNC_SECRET` set): the process that gets the webhook updates your adapter and its Memory right away. Other processes reload Memory from your adapter every 10 seconds, and every process polls Cloud every 5 minutes in case a webhook is missed.
|
|
141
|
+
- If your adapter is down, feature checks keep working from Memory. A sync that can't be written to your adapter is written again on the next sync.
|
|
142
|
+
- Adapters added with `config.use` (like `Strict` and `ActorLimit`) still wrap reads and writes.
|
|
143
|
+
- [Named instances](#named-instances) that call `cloud` read the same way, each from its own Memory.
|
|
144
|
+
- `Flipper::Middleware::Memoizer` still memoizes each request but skips its `preload` option, since there are no adapter reads left to save.
|
|
145
|
+
- To read from your adapter on every check instead, as before, set `FLIPPER_CLOUD_MEMORY_READS=false` and restart.
|
|
86
146
|
|
|
87
147
|
We also have a [free plan](https://www.flippercloud.io?utm_source=oss&utm_medium=readme&utm_campaign=free_plan) that you can use forever.
|
|
88
148
|
|
|
@@ -90,7 +150,7 @@ We also have a [free plan](https://www.flippercloud.io?utm_source=oss&utm_medium
|
|
|
90
150
|
|
|
91
151
|
1. Fork it
|
|
92
152
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
93
|
-
3. Run the tests (`bundle exec rake`). Check out [Docker-Compose](docs/DockerCompose.md) if you need help getting all the adapters running.
|
|
153
|
+
3. Run the tests (`bundle exec rake`). Check out [Docker-Compose](https://github.com/flippercloud/flipper/blob/main/docs/DockerCompose.md) if you need help getting all the adapters running.
|
|
94
154
|
4. Commit your changes (`git commit -am 'Added some feature'`)
|
|
95
155
|
5. Push to the branch (`git push origin my-new-feature`)
|
|
96
156
|
6. Create new Pull Request
|
data/lib/flipper/adapter.rb
CHANGED
|
@@ -69,6 +69,22 @@ module Flipper
|
|
|
69
69
|
self.class.default_config
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
# Public: The Flipper::SyncVersion of the synced flags this adapter holds,
|
|
73
|
+
# or nil if it doesn't know. Syncs use it to never replace newer flags with
|
|
74
|
+
# older ones. Adapters that wrap another adapter delegate to it. Storage
|
|
75
|
+
# adapters that can keep it override this and #sync_version=.
|
|
76
|
+
def sync_version
|
|
77
|
+
wrapped = respond_to?(:adapter) ? adapter : nil
|
|
78
|
+
wrapped.sync_version if wrapped.respond_to?(:sync_version)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Public: Records the Flipper::SyncVersion of the flags just synced into
|
|
82
|
+
# this adapter. Does nothing for adapters that can't keep it.
|
|
83
|
+
def sync_version=(version)
|
|
84
|
+
wrapped = respond_to?(:adapter) ? adapter : nil
|
|
85
|
+
wrapped.sync_version = version if wrapped.respond_to?(:sync_version=)
|
|
86
|
+
end
|
|
87
|
+
|
|
72
88
|
# Public: default name of the adapter
|
|
73
89
|
def name
|
|
74
90
|
@name ||= self.class.name.split('::').last.split(/(?=[A-Z])/).join('_').downcase.to_sym
|
|
@@ -89,6 +105,14 @@ module Flipper
|
|
|
89
105
|
name.to_s
|
|
90
106
|
end
|
|
91
107
|
end
|
|
108
|
+
|
|
109
|
+
private
|
|
110
|
+
|
|
111
|
+
# Internal: Raises for feature names reserved for Flipper's own data. Adapters
|
|
112
|
+
# that store that data next to features call it before every write.
|
|
113
|
+
def ensure_not_reserved_key!(feature)
|
|
114
|
+
raise ReservedKeyError.new(feature.key) if Flipper.reserved_key?(feature.key)
|
|
115
|
+
end
|
|
92
116
|
end
|
|
93
117
|
end
|
|
94
118
|
|
|
@@ -37,8 +37,19 @@ module Flipper
|
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
# Public: Builds the adapter.
|
|
40
41
|
def to_adapter
|
|
41
|
-
|
|
42
|
+
wrap(build_store)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Internal: Builds a new storage adapter.
|
|
46
|
+
def build_store
|
|
47
|
+
@store.call
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Internal: Wraps adapter with the adapters added with #use.
|
|
51
|
+
def wrap(adapter)
|
|
52
|
+
@stack.reverse.inject(adapter) { |wrapped, wrapper| wrapper.call(wrapped) }
|
|
42
53
|
end
|
|
43
54
|
end
|
|
44
55
|
end
|
|
@@ -37,7 +37,7 @@ module Flipper
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def enable(feature, gate, resource)
|
|
40
|
-
if gate.is_a?(Flipper::Gates::Actor) && !self.class.sync_mode && over_limit?(feature)
|
|
40
|
+
if gate.is_a?(Flipper::Gates::Actor) && !self.class.sync_mode && over_limit?(feature, resource)
|
|
41
41
|
raise LimitExceeded, "Actor limit of #{@limit} exceeded for feature #{feature.key}. See https://www.flippercloud.io/docs/features/actors#limitations"
|
|
42
42
|
else
|
|
43
43
|
super
|
|
@@ -46,8 +46,9 @@ module Flipper
|
|
|
46
46
|
|
|
47
47
|
private
|
|
48
48
|
|
|
49
|
-
def over_limit?(feature)
|
|
50
|
-
feature.actors_value
|
|
49
|
+
def over_limit?(feature, resource)
|
|
50
|
+
actors = feature.actors_value
|
|
51
|
+
actors.size >= @limit && !actors.include?(resource.value)
|
|
51
52
|
end
|
|
52
53
|
end
|
|
53
54
|
end
|
|
@@ -35,6 +35,10 @@ module Flipper
|
|
|
35
35
|
@get_all_cache_key = "#{@namespace}/get_all"
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
def read_only?
|
|
39
|
+
@adapter.read_only?
|
|
40
|
+
end
|
|
41
|
+
|
|
38
42
|
# Public: Expire the cache for the set of all features with gates.
|
|
39
43
|
def expire_get_all_cache
|
|
40
44
|
cache_delete @get_all_cache_key
|
|
@@ -98,6 +102,19 @@ module Flipper
|
|
|
98
102
|
}
|
|
99
103
|
end
|
|
100
104
|
|
|
105
|
+
# Public
|
|
106
|
+
def import(source)
|
|
107
|
+
feature_keys = @adapter.features
|
|
108
|
+
result = @adapter.import(source)
|
|
109
|
+
return result unless result
|
|
110
|
+
|
|
111
|
+
feature_keys |= @adapter.features
|
|
112
|
+
|
|
113
|
+
feature_keys.each { |key| cache_delete feature_cache_key(key) }
|
|
114
|
+
expire_features_cache
|
|
115
|
+
result
|
|
116
|
+
end
|
|
117
|
+
|
|
101
118
|
# Public
|
|
102
119
|
def enable(feature, gate, thing)
|
|
103
120
|
result = @adapter.enable(feature, gate, thing)
|
|
@@ -19,6 +19,10 @@ module Flipper
|
|
|
19
19
|
"#{name}(local: #{@local.adapter_stack}, remote: #{@remote.adapter_stack})"
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def read_only?
|
|
23
|
+
@remote.read_only? || @local.read_only?
|
|
24
|
+
end
|
|
25
|
+
|
|
22
26
|
def features
|
|
23
27
|
@local.features
|
|
24
28
|
end
|
|
@@ -35,6 +39,14 @@ module Flipper
|
|
|
35
39
|
@local.get_all(**kwargs)
|
|
36
40
|
end
|
|
37
41
|
|
|
42
|
+
def sync_version
|
|
43
|
+
@local.sync_version
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def sync_version=(version)
|
|
47
|
+
@local.sync_version = version
|
|
48
|
+
end
|
|
49
|
+
|
|
38
50
|
def add(feature)
|
|
39
51
|
@remote.add(feature).tap { @local.add(feature) }
|
|
40
52
|
end
|
|
@@ -27,6 +27,10 @@ module Flipper
|
|
|
27
27
|
"#{name}(primary: #{@primary.adapter_stack}, secondary: #{@secondary.adapter_stack})"
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
def read_only?
|
|
31
|
+
@primary.read_only? || (@dual_write && @secondary.read_only?)
|
|
32
|
+
end
|
|
33
|
+
|
|
30
34
|
def features
|
|
31
35
|
@primary.features
|
|
32
36
|
rescue *@errors
|
|
@@ -51,6 +55,17 @@ module Flipper
|
|
|
51
55
|
@secondary.get_all(**kwargs)
|
|
52
56
|
end
|
|
53
57
|
|
|
58
|
+
def sync_version
|
|
59
|
+
@primary.sync_version
|
|
60
|
+
rescue *@errors
|
|
61
|
+
@secondary.sync_version
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def sync_version=(version)
|
|
65
|
+
@primary.sync_version = version
|
|
66
|
+
@secondary.sync_version = version if @dual_write
|
|
67
|
+
end
|
|
68
|
+
|
|
54
69
|
def add(feature)
|
|
55
70
|
@primary.add(feature).tap do
|
|
56
71
|
@secondary.add(feature) if @dual_write
|
|
@@ -14,12 +14,28 @@ module Flipper
|
|
|
14
14
|
@errors = options.fetch(:errors, [StandardError])
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
def read_only?
|
|
18
|
+
@adapter.read_only?
|
|
19
|
+
end
|
|
20
|
+
|
|
17
21
|
def features
|
|
18
22
|
@adapter.features
|
|
19
23
|
rescue *@errors
|
|
20
24
|
Set.new
|
|
21
25
|
end
|
|
22
26
|
|
|
27
|
+
def sync_version
|
|
28
|
+
@adapter.sync_version
|
|
29
|
+
rescue *@errors
|
|
30
|
+
nil
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def sync_version=(version)
|
|
34
|
+
@adapter.sync_version = version
|
|
35
|
+
rescue *@errors
|
|
36
|
+
nil
|
|
37
|
+
end
|
|
38
|
+
|
|
23
39
|
def add(feature)
|
|
24
40
|
@adapter.add(feature)
|
|
25
41
|
rescue *@errors
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require 'uri'
|
|
2
2
|
require 'openssl'
|
|
3
3
|
require 'flipper/version'
|
|
4
|
+
require 'flipper/adapters/http/redacted_debug_output'
|
|
4
5
|
|
|
5
6
|
module Flipper
|
|
6
7
|
module Adapters
|
|
@@ -28,7 +29,10 @@ module Flipper
|
|
|
28
29
|
attr_reader :max_retries, :debug_output
|
|
29
30
|
|
|
30
31
|
def initialize(options = {})
|
|
31
|
-
@uri = URI(options.fetch(:url))
|
|
32
|
+
@uri = URI(options.fetch(:url)).dup
|
|
33
|
+
# Request paths start with "/", so a trailing slash here would
|
|
34
|
+
# turn "/api/" + "/features" into "/api//features".
|
|
35
|
+
@uri.path = @uri.path.sub(%r{/+\z}, "")
|
|
32
36
|
@basic_auth_username = options[:basic_auth_username]
|
|
33
37
|
@basic_auth_password = options[:basic_auth_password]
|
|
34
38
|
@read_timeout = options[:read_timeout]
|
|
@@ -81,7 +85,7 @@ module Flipper
|
|
|
81
85
|
uri = @uri.dup
|
|
82
86
|
path_uri = URI(path)
|
|
83
87
|
uri.path += path_uri.path
|
|
84
|
-
uri.query =
|
|
88
|
+
uri.query = [uri.query, path_uri.query].compact.join('&') if path_uri.query
|
|
85
89
|
uri
|
|
86
90
|
end
|
|
87
91
|
|
|
@@ -91,7 +95,7 @@ module Flipper
|
|
|
91
95
|
http.open_timeout = @open_timeout if @open_timeout
|
|
92
96
|
http.max_retries = @max_retries if @max_retries
|
|
93
97
|
http.write_timeout = @write_timeout if @write_timeout
|
|
94
|
-
http.set_debug_output(@debug_output) if @debug_output
|
|
98
|
+
http.set_debug_output(RedactedDebugOutput.wrap(@debug_output)) if @debug_output
|
|
95
99
|
|
|
96
100
|
if uri.scheme == HTTPS_SCHEME
|
|
97
101
|
http.use_ssl = true
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
module Flipper
|
|
2
|
+
module Adapters
|
|
3
|
+
class Http
|
|
4
|
+
# Wraps the IO-like object passed to Net::HTTP#set_debug_output and
|
|
5
|
+
# redacts the values of sensitive request headers (auth tokens, etc.)
|
|
6
|
+
# before they are written. Without this, enabling debug output dumps the
|
|
7
|
+
# raw request — including the flipper-cloud-token bearer credential — in
|
|
8
|
+
# cleartext to STDOUT/logs.
|
|
9
|
+
class RedactedDebugOutput
|
|
10
|
+
# Header names whose values must never reach debug output.
|
|
11
|
+
SENSITIVE_HEADERS = %w[
|
|
12
|
+
flipper-cloud-token
|
|
13
|
+
authorization
|
|
14
|
+
].freeze
|
|
15
|
+
|
|
16
|
+
REDACTED = "[REDACTED]".freeze
|
|
17
|
+
|
|
18
|
+
# Matches "<sensitive-header>: <value>" up to (but not including) the
|
|
19
|
+
# next line terminator. Net::HTTP writes request headers via
|
|
20
|
+
# String#dump, so the value may itself contain escape sequences (\t,
|
|
21
|
+
# \", \\, ...) and line breaks appear as the escaped "\r\n" sequence. The
|
|
22
|
+
# value alternation consumes escaped chars (other than \r/\n) and plain
|
|
23
|
+
# chars, stopping at the escaped or raw line terminator or the closing
|
|
24
|
+
# quote. Consuming escapes ensures a value that contains one is still
|
|
25
|
+
# fully redacted rather than leaking past the first backslash.
|
|
26
|
+
PATTERN = Regexp.new(
|
|
27
|
+
'((?:' + Regexp.union(SENSITIVE_HEADERS).source + '):[ \t]*)' +
|
|
28
|
+
'(?:\\\\[^rn]|[^\r\n"\\\\])*',
|
|
29
|
+
Regexp::IGNORECASE
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# Wraps output unless it is nil or already wrapped.
|
|
33
|
+
def self.wrap(output)
|
|
34
|
+
return output if output.nil? || output.is_a?(self)
|
|
35
|
+
new(output)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.redact(message)
|
|
39
|
+
return message unless message.is_a?(String)
|
|
40
|
+
message.gsub(PATTERN) { "#{$1}#{REDACTED}" }
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def initialize(output)
|
|
44
|
+
@output = output
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def <<(message)
|
|
48
|
+
@output << self.class.redact(message)
|
|
49
|
+
self
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
# Behave like the wrapped output for anything Net::HTTP doesn't route
|
|
55
|
+
# through <<.
|
|
56
|
+
def method_missing(name, *args, &block)
|
|
57
|
+
if @output.respond_to?(name)
|
|
58
|
+
@output.public_send(name, *args, &block)
|
|
59
|
+
else
|
|
60
|
+
super
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def respond_to_missing?(name, include_private = false)
|
|
65
|
+
@output.respond_to?(name, include_private) || super
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require 'net/http'
|
|
2
|
+
require 'uri'
|
|
2
3
|
require 'json'
|
|
3
4
|
require 'set'
|
|
5
|
+
require 'digest'
|
|
4
6
|
require 'flipper'
|
|
5
7
|
require 'flipper/adapters/http/error'
|
|
6
8
|
require 'flipper/adapters/http/client'
|
|
@@ -25,11 +27,19 @@ module Flipper
|
|
|
25
27
|
@last_get_all_etag = nil
|
|
26
28
|
@last_get_all_result = nil
|
|
27
29
|
@last_get_all_response = nil
|
|
30
|
+
@last_get_all_sync_version = nil
|
|
28
31
|
@get_all_mutex = Mutex.new
|
|
32
|
+
@sync_version_scope = sync_version_scope(options)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Public: The Flipper::SyncVersion of the flags get_all last returned, or
|
|
36
|
+
# nil if the server didn't send one.
|
|
37
|
+
def sync_version
|
|
38
|
+
@get_all_mutex.synchronize { @last_get_all_sync_version }
|
|
29
39
|
end
|
|
30
40
|
|
|
31
41
|
def get(feature)
|
|
32
|
-
response = @client.get("/features/#{feature.key}")
|
|
42
|
+
response = @client.get("/features/#{path_escape(feature.key)}")
|
|
33
43
|
if response.is_a?(Net::HTTPOK)
|
|
34
44
|
parsed_response = Typecast.from_json(response.body)
|
|
35
45
|
result_for_feature(feature, parsed_response.fetch('gates'))
|
|
@@ -41,8 +51,7 @@ module Flipper
|
|
|
41
51
|
end
|
|
42
52
|
|
|
43
53
|
def get_multi(features)
|
|
44
|
-
|
|
45
|
-
response = @client.get("/features?keys=#{csv_keys}&exclude_gate_names=true")
|
|
54
|
+
response = @client.get("/features?#{query_for_features(features)}")
|
|
46
55
|
raise Error, response unless response.is_a?(Net::HTTPOK)
|
|
47
56
|
|
|
48
57
|
parsed_response = Typecast.from_json(response.body)
|
|
@@ -100,6 +109,7 @@ module Flipper
|
|
|
100
109
|
@get_all_mutex.synchronize do
|
|
101
110
|
@last_get_all_etag = response['etag'] if response['etag']
|
|
102
111
|
@last_get_all_result = result
|
|
112
|
+
@last_get_all_sync_version = SyncVersion.from_header(@sync_version_scope, response[SyncVersion::HEADER])
|
|
103
113
|
end
|
|
104
114
|
|
|
105
115
|
result
|
|
@@ -125,7 +135,7 @@ module Flipper
|
|
|
125
135
|
end
|
|
126
136
|
|
|
127
137
|
def remove(feature)
|
|
128
|
-
response = @client.delete("/features/#{feature.key}")
|
|
138
|
+
response = @client.delete("/features/#{path_escape(feature.key)}")
|
|
129
139
|
raise Error, response unless response.is_a?(Net::HTTPNoContent)
|
|
130
140
|
true
|
|
131
141
|
end
|
|
@@ -133,7 +143,7 @@ module Flipper
|
|
|
133
143
|
def enable(feature, gate, thing)
|
|
134
144
|
body = request_body_for_gate(gate, thing.value)
|
|
135
145
|
query_string = gate.key == :groups ? "?allow_unregistered_groups=true" : ""
|
|
136
|
-
response = @client.post("/features/#{feature.key}/#{gate.key}#{query_string}", body)
|
|
146
|
+
response = @client.post("/features/#{path_escape(feature.key)}/#{path_escape(gate.key)}#{query_string}", body)
|
|
137
147
|
raise Error, response unless response.is_a?(Net::HTTPOK)
|
|
138
148
|
true
|
|
139
149
|
end
|
|
@@ -143,16 +153,16 @@ module Flipper
|
|
|
143
153
|
query_string = gate.key == :groups ? "?allow_unregistered_groups=true" : ""
|
|
144
154
|
response = case gate.key
|
|
145
155
|
when :percentage_of_actors, :percentage_of_time
|
|
146
|
-
@client.post("/features/#{feature.key}/#{gate.key}#{query_string}", body)
|
|
156
|
+
@client.post("/features/#{path_escape(feature.key)}/#{path_escape(gate.key)}#{query_string}", body)
|
|
147
157
|
else
|
|
148
|
-
@client.delete("/features/#{feature.key}/#{gate.key}#{query_string}", body)
|
|
158
|
+
@client.delete("/features/#{path_escape(feature.key)}/#{path_escape(gate.key)}#{query_string}", body)
|
|
149
159
|
end
|
|
150
160
|
raise Error, response unless response.is_a?(Net::HTTPOK)
|
|
151
161
|
true
|
|
152
162
|
end
|
|
153
163
|
|
|
154
164
|
def clear(feature)
|
|
155
|
-
response = @client.delete("/features/#{feature.key}/clear")
|
|
165
|
+
response = @client.delete("/features/#{path_escape(feature.key)}/clear")
|
|
156
166
|
raise Error, response unless response.is_a?(Net::HTTPNoContent)
|
|
157
167
|
true
|
|
158
168
|
end
|
|
@@ -167,6 +177,30 @@ module Flipper
|
|
|
167
177
|
|
|
168
178
|
private
|
|
169
179
|
|
|
180
|
+
# Versions only compare between responses from the same server and
|
|
181
|
+
# credentials, such as one Cloud environment's token.
|
|
182
|
+
def sync_version_scope(options)
|
|
183
|
+
headers = (options[:headers] || {}).map { |key, value| [key.to_s.downcase, value.to_s] }.sort
|
|
184
|
+
Digest::SHA256.hexdigest([options.fetch(:url).to_s, headers].inspect)[0, 16]
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def path_escape(key)
|
|
188
|
+
URI::DEFAULT_PARSER.escape(key.to_s, /[^A-Za-z0-9_.~-]/)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def query_escape(key)
|
|
192
|
+
URI.encode_www_form_component(key.to_s)
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def query_for_features(features)
|
|
196
|
+
if features.any? { |feature| feature.key.to_s.include?(',') }
|
|
197
|
+
URI.encode_www_form(features.map { |feature| ["keys[]", feature.key] } + [["exclude_gate_names", "true"]])
|
|
198
|
+
else
|
|
199
|
+
csv_keys = features.map { |feature| query_escape(feature.key) }.join(',')
|
|
200
|
+
"keys=#{csv_keys}&exclude_gate_names=true"
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|
|
170
204
|
def request_body_for_gate(gate, value)
|
|
171
205
|
data = case gate.key
|
|
172
206
|
when :boolean
|
|
@@ -25,6 +25,11 @@ module Flipper
|
|
|
25
25
|
@instrumenter = options.fetch(:instrumenter, Instrumenters::Noop)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
# Public
|
|
29
|
+
def read_only?
|
|
30
|
+
@adapter.read_only?
|
|
31
|
+
end
|
|
32
|
+
|
|
28
33
|
# Public
|
|
29
34
|
def features
|
|
30
35
|
default_payload = {
|
|
@@ -142,6 +147,29 @@ module Flipper
|
|
|
142
147
|
end
|
|
143
148
|
end
|
|
144
149
|
|
|
150
|
+
def sync_version
|
|
151
|
+
default_payload = {
|
|
152
|
+
operation: :sync_version,
|
|
153
|
+
adapter_name: @adapter.name,
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@instrumenter.instrument(InstrumentationName, default_payload) do |payload|
|
|
157
|
+
payload[:result] = @adapter.sync_version
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def sync_version=(version)
|
|
162
|
+
default_payload = {
|
|
163
|
+
operation: :set_sync_version,
|
|
164
|
+
adapter_name: @adapter.name,
|
|
165
|
+
version: version,
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
@instrumenter.instrument(InstrumentationName, default_payload) do |payload|
|
|
169
|
+
payload[:result] = @adapter.sync_version = version
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
145
173
|
def import(source)
|
|
146
174
|
default_payload = {
|
|
147
175
|
operation: :import,
|