flipper 1.4.2 → 1.5.0.rc1
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 +138 -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 +84 -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
data/CLAUDE.md
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
-
|
|
5
|
-
## Development Commands
|
|
6
|
-
|
|
7
|
-
### Testing
|
|
8
|
-
- `bundle exec rake` - Run all tests (RSpec, Minitest, and Rails tests)
|
|
9
|
-
- `bundle exec rspec` - Run RSpec tests only
|
|
10
|
-
- `bundle exec rake spec:ui` - Run UI-specific specs
|
|
11
|
-
- `bundle exec rake test` - Run Minitest tests only
|
|
12
|
-
- `bundle exec rake test_rails` - Run Rails generator tests
|
|
13
|
-
- `script/test` - Bootstrap and run tests across multiple Rails versions (5.0-8.0)
|
|
14
|
-
|
|
15
|
-
### Development Setup
|
|
16
|
-
- `script/bootstrap` - Bundle install dependencies and setup binstubs
|
|
17
|
-
- `script/console` - Start interactive console with Flipper loaded (uses Pry)
|
|
18
|
-
- `script/server` - Start local UI server on port 9999 for testing web interface
|
|
19
|
-
|
|
20
|
-
### Releasing
|
|
21
|
-
1. Bump version in `lib/flipper/version.rb`, commit, and push to main
|
|
22
|
-
2. Tag and push: `git tag v1.x.x && git push origin v1.x.x`
|
|
23
|
-
3. GitHub Actions (`.github/workflows/release.yml`) builds and publishes all 12 gems via RubyGems trusted publishing, then creates a draft GitHub Release
|
|
24
|
-
4. Edit and publish the draft release at https://github.com/flippercloud/flipper/releases
|
|
25
|
-
|
|
26
|
-
- `bundle exec rake build` - Build all gems locally into pkg/ directory
|
|
27
|
-
- `script/release` - Manual fallback for local releases (prompts for OTP)
|
|
28
|
-
|
|
29
|
-
**After releasing**, purge the cached release URLs on flippercloud.io:
|
|
30
|
-
- `/release`
|
|
31
|
-
- `/release.json`
|
|
32
|
-
|
|
33
|
-
## Architecture Overview
|
|
34
|
-
|
|
35
|
-
Flipper is a feature flag library for Ruby with a modular adapter-based architecture:
|
|
36
|
-
|
|
37
|
-
### Core Components
|
|
38
|
-
|
|
39
|
-
**DSL Layer** (`lib/flipper/dsl.rb`):
|
|
40
|
-
- Main interface for feature flag operations
|
|
41
|
-
- Delegates to Feature instances
|
|
42
|
-
- Handles memoization and instrumentation
|
|
43
|
-
- Thread-safe instance management
|
|
44
|
-
|
|
45
|
-
**Feature** (`lib/flipper/feature.rb`):
|
|
46
|
-
- Represents individual feature flags
|
|
47
|
-
- Manages enable/disable operations through gates
|
|
48
|
-
- Handles instrumentation events
|
|
49
|
-
- Works with adapters for persistence
|
|
50
|
-
|
|
51
|
-
**Adapters** (`lib/flipper/adapters/`):
|
|
52
|
-
- Pluggable storage backends (Redis, ActiveRecord, Memory, etc.)
|
|
53
|
-
- Common interface for all storage implementations
|
|
54
|
-
- Support for caching, failover, and synchronization patterns
|
|
55
|
-
|
|
56
|
-
**Gates** (`lib/flipper/gates/`):
|
|
57
|
-
- Different targeting mechanisms:
|
|
58
|
-
- Boolean (on/off for everyone)
|
|
59
|
-
- Actor (specific users/entities)
|
|
60
|
-
- Group (predefined user groups)
|
|
61
|
-
- Percentage of Actors (rollout to X% of users)
|
|
62
|
-
- Percentage of Time (probabilistic enabling)
|
|
63
|
-
- Expression (complex conditional logic)
|
|
64
|
-
|
|
65
|
-
### Multi-Gem Structure
|
|
66
|
-
|
|
67
|
-
The project is structured as multiple gems:
|
|
68
|
-
- `flipper` - Core library
|
|
69
|
-
- `flipper-ui` - Web interface
|
|
70
|
-
- `flipper-api` - REST API
|
|
71
|
-
- `flipper-cloud` - Cloud service integration
|
|
72
|
-
- `flipper-*` - Various adapter gems (redis, active_record, mongo, etc.)
|
|
73
|
-
|
|
74
|
-
### Key Patterns
|
|
75
|
-
|
|
76
|
-
**Configuration**: Global configuration through `Flipper.configure` with per-thread instances
|
|
77
|
-
**Instrumentation**: Built-in event system for monitoring and debugging
|
|
78
|
-
**Memoization**: Automatic caching of feature checks within request/thread scope
|
|
79
|
-
**Type Safety**: Strong typing system for actors, percentages, and other values
|
|
80
|
-
|
|
81
|
-
### Serialization and HTTP
|
|
82
|
-
|
|
83
|
-
Use `Flipper::Typecast` for JSON and gzip serialization instead of calling `JSON.generate`/`JSON.parse` or `Zlib` directly:
|
|
84
|
-
- `Typecast.to_json(hash)` / `Typecast.from_json(string)` for JSON serialization
|
|
85
|
-
- `Typecast.to_gzip(string)` / `Typecast.from_gzip(string)` for gzip compression
|
|
86
|
-
|
|
87
|
-
For outbound HTTP requests, use `Flipper::Adapters::Http::Client` instead of raw `Net::HTTP`. It provides timeouts, retries (`max_retries`), SSL verification, and diagnostic headers (user-agent, client-language, client-platform, etc.). See `lib/flipper/cloud/migrate.rb` for an example.
|
|
88
|
-
|
|
89
|
-
### Testing
|
|
90
|
-
|
|
91
|
-
Uses both RSpec (currently preferred for new tests) and Minitest. Shared adapter specs ensure consistency across all storage backends. Extensive testing across multiple Rails versions (5.0-8.0).
|
|
92
|
-
|
|
93
|
-
`Flipper.configuration` is reset to nil before each spec (in `spec/spec_helper.rb`), but `Flipper::UI.configuration` is **not** globally reset. When modifying UI config in tests, set the value in `before` and reset it in `after` to match the existing pattern throughout the spec suite.
|
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
-
|
|
7
|
-
## Our Standards
|
|
8
|
-
|
|
9
|
-
Examples of behavior that contributes to creating a positive environment include:
|
|
10
|
-
|
|
11
|
-
* Using welcoming and inclusive language
|
|
12
|
-
* Being respectful of differing viewpoints and experiences
|
|
13
|
-
* Gracefully accepting constructive criticism
|
|
14
|
-
* Focusing on what is best for the community
|
|
15
|
-
* Showing empathy towards other community members
|
|
16
|
-
|
|
17
|
-
Examples of unacceptable behavior by participants include:
|
|
18
|
-
|
|
19
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
|
20
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
21
|
-
* Public or private harassment
|
|
22
|
-
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
|
23
|
-
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
24
|
-
|
|
25
|
-
## Our Responsibilities
|
|
26
|
-
|
|
27
|
-
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
|
28
|
-
|
|
29
|
-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
|
30
|
-
|
|
31
|
-
## Scope
|
|
32
|
-
|
|
33
|
-
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
|
34
|
-
|
|
35
|
-
## Enforcement
|
|
36
|
-
|
|
37
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at nunemaker@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
|
38
|
-
|
|
39
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
|
40
|
-
|
|
41
|
-
## Attribution
|
|
42
|
-
|
|
43
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
|
44
|
-
|
|
45
|
-
[homepage]: http://contributor-covenant.org
|
|
46
|
-
[version]: http://contributor-covenant.org/version/1/4/
|
data/Dockerfile
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
FROM ruby:3.0
|
|
2
|
-
|
|
3
|
-
RUN apt-get update && apt-get install -y \
|
|
4
|
-
# build-essential \
|
|
5
|
-
|
|
6
|
-
# for postgres
|
|
7
|
-
# libpq-dev \
|
|
8
|
-
# postgresql-client-9.4 \
|
|
9
|
-
|
|
10
|
-
# for nokogiri
|
|
11
|
-
# libxml2-dev \
|
|
12
|
-
# libxslt1-dev \
|
|
13
|
-
|
|
14
|
-
# for a JS runtime
|
|
15
|
-
# imagemagick \
|
|
16
|
-
# ghostscript \
|
|
17
|
-
|
|
18
|
-
# debug tools
|
|
19
|
-
vim
|
|
20
|
-
|
|
21
|
-
ENV APP_HOME /srv/app
|
|
22
|
-
|
|
23
|
-
ENV BUNDLE_GEMFILE=$APP_HOME/Gemfile \
|
|
24
|
-
BUNDLE_JOBS=8 \
|
|
25
|
-
BUNDLE_PATH=/bundle_cache
|
|
26
|
-
|
|
27
|
-
WORKDIR $APP_HOME
|
data/Gemfile
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
gemspec name: 'flipper'
|
|
3
|
-
|
|
4
|
-
Dir['flipper-*.gemspec'].each do |gemspec|
|
|
5
|
-
plugin = gemspec.scan(/flipper-(.*)\.gemspec/).flatten.first
|
|
6
|
-
gemspec(name: "flipper-#{plugin}", development_group: plugin)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
gem 'concurrent-ruby', '1.3.4'
|
|
10
|
-
gem 'connection_pool'
|
|
11
|
-
gem 'debug'
|
|
12
|
-
gem 'rake'
|
|
13
|
-
gem 'statsd-ruby', '~> 1.2.1'
|
|
14
|
-
gem 'rspec', '~> 3.0'
|
|
15
|
-
gem 'rack-test'
|
|
16
|
-
gem 'rackup', '= 1.0.0'
|
|
17
|
-
gem 'sqlite3', "~> #{ENV['SQLITE3_VERSION'] || '2.1.0'}"
|
|
18
|
-
gem 'rails', "~> #{ENV['RAILS_VERSION'] || '8.0'}"
|
|
19
|
-
gem 'minitest', '~> 5.18'
|
|
20
|
-
gem 'minitest-documentation'
|
|
21
|
-
gem 'pstore'
|
|
22
|
-
gem 'webmock'
|
|
23
|
-
gem 'ice_age'
|
|
24
|
-
gem 'redis-namespace'
|
|
25
|
-
gem 'webrick'
|
|
26
|
-
gem 'stackprof'
|
|
27
|
-
gem 'benchmark-ips'
|
|
28
|
-
gem 'stackprof-webnav'
|
|
29
|
-
gem 'flamegraph'
|
|
30
|
-
gem 'mysql2'
|
|
31
|
-
gem 'pg'
|
|
32
|
-
gem 'cuprite'
|
|
33
|
-
gem 'puma'
|
|
34
|
-
gem 'warning'
|
|
35
|
-
|
|
36
|
-
group(:guard) do
|
|
37
|
-
gem 'guard'
|
|
38
|
-
gem 'guard-rspec'
|
|
39
|
-
gem 'guard-bundler'
|
|
40
|
-
gem 'rb-fsevent'
|
|
41
|
-
end
|
data/Rakefile
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env rake
|
|
2
|
-
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
|
3
|
-
require 'rake/testtask'
|
|
4
|
-
require 'flipper/version'
|
|
5
|
-
|
|
6
|
-
# gem install pkg/*.gem
|
|
7
|
-
# gem uninstall flipper flipper-ui flipper-redis
|
|
8
|
-
desc 'Build gem into the pkg directory'
|
|
9
|
-
task :build do
|
|
10
|
-
FileUtils.rm_rf('pkg')
|
|
11
|
-
Dir['*.gemspec'].each do |gemspec|
|
|
12
|
-
system "gem build #{gemspec}"
|
|
13
|
-
end
|
|
14
|
-
FileUtils.mkdir_p('pkg')
|
|
15
|
-
FileUtils.mv(Dir['*.gem'], 'pkg')
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
desc 'Tags version, pushes to remote, and pushes gem'
|
|
19
|
-
task release: :build do
|
|
20
|
-
sh 'git', 'tag', "v#{Flipper::VERSION}"
|
|
21
|
-
sh 'git push origin main'
|
|
22
|
-
sh "git push origin v#{Flipper::VERSION}"
|
|
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}"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
require 'rspec/core/rake_task'
|
|
29
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
30
|
-
t.rspec_opts = %w(--color)
|
|
31
|
-
t.verbose = false
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
namespace :spec do
|
|
35
|
-
desc 'Run specs for UI queue'
|
|
36
|
-
RSpec::Core::RakeTask.new(:ui) do |t|
|
|
37
|
-
t.rspec_opts = %w(--color)
|
|
38
|
-
t.pattern = ['spec/flipper/ui/**/*_spec.rb', 'spec/flipper/ui_spec.rb']
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
Rake::TestTask.new do |t|
|
|
43
|
-
t.libs = %w(lib test)
|
|
44
|
-
t.pattern = 'test/**/*_test.rb'
|
|
45
|
-
t.warning = false
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
Rake::TestTask.new(:test_rails) do |t|
|
|
49
|
-
t.libs = %w(lib test_rails)
|
|
50
|
-
t.pattern = 'test_rails/**/*_test.rb'
|
|
51
|
-
t.warning = false
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
task default: [:spec, :test, :test_rails]
|
data/benchmark/enabled_ips.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
|
@@ -1,20 +0,0 @@
|
|
|
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?/)
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
data/benchmark/typecast_ips.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
|
|
20
|
-
x.report("Typecast.to_number 1") { Flipper::Typecast.to_number(1) }
|
|
21
|
-
x.report("Typecast.to_number 1.1") { Flipper::Typecast.to_number(1.1) }
|
|
22
|
-
x.report("Typecast.to_number '1'") { Flipper::Typecast.to_number('1'.freeze) }
|
|
23
|
-
x.report("Typecast.to_number '1.1'") { Flipper::Typecast.to_number('1.1'.freeze) }
|
|
24
|
-
x.report("Typecast.to_number nil") { Flipper::Typecast.to_number(nil) }
|
|
25
|
-
time = Time.now
|
|
26
|
-
x.report("Typecast.to_number Time.now") { Flipper::Typecast.to_number(time) }
|
|
27
|
-
end
|
data/docker-compose.yml
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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/DockerCompose.md
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# Docker Compose for contributors
|
|
2
|
-
|
|
3
|
-
This gem includes different adapters which require specific tools instaled
|
|
4
|
-
on local machine. With docker this could be achieved inside container and
|
|
5
|
-
new contributor could start working on code with a minumum efforts.
|
|
6
|
-
|
|
7
|
-
## Steps:
|
|
8
|
-
|
|
9
|
-
1. Install Docker Compose https://docs.docker.com/compose/install
|
|
10
|
-
1. Build the app container `docker-compose build`
|
|
11
|
-
1. Install gems `docker-compose run --rm app bundle install`
|
|
12
|
-
1. Run specs `docker-compose run --rm app bundle exec rspec`
|
|
13
|
-
1. Run tests `docker-compose run --rm app bundle exec rake test`
|
|
14
|
-
1. Optional: log in to container an using a `bash` shell for running specs
|
|
15
|
-
```sh
|
|
16
|
-
docker-compose run --rm app bash
|
|
17
|
-
bundle exec rspec
|
|
18
|
-
```
|
data/docs/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
See [flippercloud.io](https://flippercloud.io/docs) for extensive docs.
|
data/docs/images/banner.jpg
DELETED
|
Binary file
|
|
Binary file
|
data/examples/api/basic.ru
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Usage:
|
|
3
|
-
# bin/rackup examples/api/basic.ru -p 9999
|
|
4
|
-
#
|
|
5
|
-
# http://localhost:9999/
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
require 'bundler/setup'
|
|
9
|
-
require 'rack/reloader'
|
|
10
|
-
require "flipper/api"
|
|
11
|
-
require "flipper/adapters/pstore"
|
|
12
|
-
|
|
13
|
-
# You can uncomment this to get some default data:
|
|
14
|
-
# Flipper.enable :logging
|
|
15
|
-
|
|
16
|
-
use Rack::Reloader
|
|
17
|
-
|
|
18
|
-
run Flipper::Api.app
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Usage:
|
|
3
|
-
# bin/rackup examples/api/custom_memoized.ru -p 9999
|
|
4
|
-
#
|
|
5
|
-
# http://localhost:9999/
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
require 'bundler/setup'
|
|
9
|
-
require 'rack/reloader'
|
|
10
|
-
require "active_support/notifications"
|
|
11
|
-
require "flipper/api"
|
|
12
|
-
require "flipper/adapters/pstore"
|
|
13
|
-
|
|
14
|
-
adapter = Flipper::Adapters::Instrumented.new(
|
|
15
|
-
Flipper::Adapters::PStore.new,
|
|
16
|
-
instrumenter: ActiveSupport::Notifications,
|
|
17
|
-
)
|
|
18
|
-
flipper = Flipper.new(adapter)
|
|
19
|
-
|
|
20
|
-
ActiveSupport::Notifications.subscribe(/.*/, ->(*args) {
|
|
21
|
-
name, start, finish, id, data = args
|
|
22
|
-
case name
|
|
23
|
-
when "adapter_operation.flipper"
|
|
24
|
-
p data[:adapter_name] => data[:operation]
|
|
25
|
-
end
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
# You can uncomment this to get some default data:
|
|
29
|
-
# flipper[:logging].enable_percentage_of_time 5
|
|
30
|
-
|
|
31
|
-
use Rack::Reloader
|
|
32
|
-
|
|
33
|
-
run Flipper::Api.app(flipper) { |builder|
|
|
34
|
-
builder.use Flipper::Middleware::SetupEnv, flipper
|
|
35
|
-
builder.use Flipper::Middleware::Memoizer, preload: true
|
|
36
|
-
}
|
data/examples/api/memoized.ru
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Usage:
|
|
3
|
-
# bin/rackup examples/api/memoized.ru -p 9999
|
|
4
|
-
#
|
|
5
|
-
# http://localhost:9999/
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
require 'bundler/setup'
|
|
9
|
-
require 'rack/reloader'
|
|
10
|
-
require "active_support/notifications"
|
|
11
|
-
require "flipper/api"
|
|
12
|
-
require "flipper/adapters/pstore"
|
|
13
|
-
|
|
14
|
-
Flipper.configure do |config|
|
|
15
|
-
config.adapter {
|
|
16
|
-
Flipper::Adapters::Instrumented.new(
|
|
17
|
-
Flipper::Adapters::PStore.new,
|
|
18
|
-
instrumenter: ActiveSupport::Notifications,
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
end
|
|
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
|
-
Flipper.register(:admins) { |actor|
|
|
32
|
-
actor.respond_to?(:admin?) && actor.admin?
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
# You can uncomment this to get some default data:
|
|
36
|
-
# Flipper.enable :logging
|
|
37
|
-
|
|
38
|
-
use Rack::Reloader
|
|
39
|
-
|
|
40
|
-
run Flipper::Api.app { |builder|
|
|
41
|
-
builder.use Flipper::Middleware::Memoizer, preload: true
|
|
42
|
-
}
|
data/examples/basic.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require 'bundler/setup'
|
|
2
|
-
require 'flipper'
|
|
3
|
-
|
|
4
|
-
# check if search is enabled
|
|
5
|
-
if Flipper.enabled?(:search)
|
|
6
|
-
puts 'Search away!'
|
|
7
|
-
else
|
|
8
|
-
puts 'No search for you!'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
puts 'Enabling Search...'
|
|
12
|
-
Flipper.enable(:search)
|
|
13
|
-
|
|
14
|
-
# check if search is enabled
|
|
15
|
-
if Flipper.enabled?(:search)
|
|
16
|
-
puts 'Search away!'
|
|
17
|
-
else
|
|
18
|
-
puts 'No search for you!'
|
|
19
|
-
end
|
data/examples/cloud/app.ru
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# Usage (from the repo root):
|
|
2
|
-
# env FLIPPER_CLOUD_TOKEN=<token> FLIPPER_CLOUD_SYNC_SECRET=<secret> bundle exec rackup examples/cloud/app.ru -p 9999
|
|
3
|
-
# http://localhost:9999/
|
|
4
|
-
|
|
5
|
-
require 'bundler/setup'
|
|
6
|
-
require 'flipper/cloud'
|
|
7
|
-
|
|
8
|
-
Flipper.configure do |config|
|
|
9
|
-
config.default { Flipper::Cloud.new }
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
run Flipper::Cloud.app
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# Just a simple example that shows how the backoff policy works.
|
|
2
|
-
require 'bundler/setup'
|
|
3
|
-
require 'flipper/cloud/telemetry/backoff_policy'
|
|
4
|
-
|
|
5
|
-
intervals = []
|
|
6
|
-
policy = Flipper::Cloud::Telemetry::BackoffPolicy.new
|
|
7
|
-
|
|
8
|
-
5.times do |n|
|
|
9
|
-
intervals << policy.next_interval
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
pp intervals.map { |i| i.round(2) }
|
|
13
|
-
puts "Total: #{intervals.sum.round(2)}ms (#{(intervals.sum/1_000.0).round(2)} sec)"
|
data/examples/cloud/basic.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# Usage (from the repo root):
|
|
2
|
-
# env FLIPPER_CLOUD_TOKEN=<token> bundle exec ruby examples/cloud/basic.rb
|
|
3
|
-
|
|
4
|
-
require_relative "./cloud_setup"
|
|
5
|
-
require 'bundler/setup'
|
|
6
|
-
require 'flipper/cloud'
|
|
7
|
-
|
|
8
|
-
Flipper[:stats].enable
|
|
9
|
-
|
|
10
|
-
if Flipper[:stats].enabled?
|
|
11
|
-
puts 'Enabled!'
|
|
12
|
-
else
|
|
13
|
-
puts 'Disabled!'
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
Flipper[:stats].disable
|
|
17
|
-
|
|
18
|
-
if Flipper[:stats].enabled?
|
|
19
|
-
puts 'Enabled!'
|
|
20
|
-
else
|
|
21
|
-
puts 'Disabled!'
|
|
22
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
if ENV["FLIPPER_CLOUD_TOKEN"].nil? || ENV["FLIPPER_CLOUD_TOKEN"].empty?
|
|
2
|
-
warn "FLIPPER_CLOUD_TOKEN missing so skipping cloud example."
|
|
3
|
-
exit
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
matrix_key = if ENV["CI"]
|
|
7
|
-
suffix_rails = ENV["RAILS_VERSION"].split(".").take(2).join
|
|
8
|
-
suffix_ruby = RUBY_VERSION.split(".").take(2).join
|
|
9
|
-
"FLIPPER_CLOUD_TOKEN_#{suffix_ruby}_#{suffix_rails}"
|
|
10
|
-
else
|
|
11
|
-
"FLIPPER_CLOUD_TOKEN"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
if matrix_token = ENV[matrix_key]
|
|
15
|
-
puts "Using #{matrix_key} for FLIPPER_CLOUD_TOKEN"
|
|
16
|
-
ENV["FLIPPER_CLOUD_TOKEN"] = matrix_token
|
|
17
|
-
else
|
|
18
|
-
warn "Missing #{matrix_key}. Go create an environment in flipper cloud and set #{matrix_key} to the adapter token for that environment in github actions secrets."
|
|
19
|
-
exit 1
|
|
20
|
-
end
|
data/examples/cloud/forked.rb
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# Usage (from the repo root):
|
|
2
|
-
# env FLIPPER_CLOUD_TOKEN=<token> bundle exec ruby examples/cloud/threaded.rb
|
|
3
|
-
|
|
4
|
-
require_relative "./cloud_setup"
|
|
5
|
-
require 'bundler/setup'
|
|
6
|
-
require 'flipper/cloud'
|
|
7
|
-
|
|
8
|
-
puts Process.pid
|
|
9
|
-
|
|
10
|
-
# Make a call in the parent process so we can detect forking.
|
|
11
|
-
Flipper.enabled?(:stats)
|
|
12
|
-
|
|
13
|
-
pids = 2.times.map do |n|
|
|
14
|
-
fork {
|
|
15
|
-
# Check every second to see if the feature is enabled
|
|
16
|
-
threads = []
|
|
17
|
-
2.times do
|
|
18
|
-
threads << Thread.new do
|
|
19
|
-
loop do
|
|
20
|
-
sleep rand
|
|
21
|
-
|
|
22
|
-
if Flipper[:stats].enabled?
|
|
23
|
-
puts "#{Process.pid} #{Time.now.to_i} Enabled!"
|
|
24
|
-
else
|
|
25
|
-
puts "#{Process.pid} #{Time.now.to_i} Disabled!"
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
threads.map(&:join)
|
|
31
|
-
}
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
pids.each do |pid|
|
|
35
|
-
Process.waitpid pid, 0
|
|
36
|
-
end
|