splitclient-rb 7.0.0.pre.rc3-java → 7.0.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +10 -0
  3. data/.gitignore +2 -0
  4. data/.travis.yml +9 -0
  5. data/CHANGES.txt +18 -11
  6. data/CONTRIBUTORS-GUIDE.md +49 -0
  7. data/README.md +75 -41
  8. data/lib/splitclient-rb.rb +4 -4
  9. data/lib/splitclient-rb/cache/adapters/memory_adapters/map_adapter.rb +4 -0
  10. data/lib/splitclient-rb/cache/adapters/memory_adapters/queue_adapter.rb +4 -0
  11. data/lib/splitclient-rb/cache/repositories/impressions/memory_repository.rb +4 -0
  12. data/lib/splitclient-rb/cache/repositories/impressions_repository.rb +2 -2
  13. data/lib/splitclient-rb/cache/repositories/metrics/memory_repository.rb +1 -1
  14. data/lib/splitclient-rb/cache/repositories/metrics_repository.rb +2 -2
  15. data/lib/splitclient-rb/cache/senders/impressions_sender.rb +0 -5
  16. data/lib/splitclient-rb/cache/senders/localhost_repo_cleaner.rb +49 -0
  17. data/lib/splitclient-rb/cache/stores/localhost_split_builder.rb +94 -0
  18. data/lib/splitclient-rb/cache/stores/localhost_split_store.rb +112 -0
  19. data/lib/splitclient-rb/cache/stores/segment_store.rb +1 -7
  20. data/lib/splitclient-rb/cache/stores/split_store.rb +1 -7
  21. data/lib/splitclient-rb/cache/stores/store_utils.rb +13 -0
  22. data/lib/splitclient-rb/clients/split_client.rb +16 -13
  23. data/lib/splitclient-rb/engine/api/client.rb +6 -11
  24. data/lib/splitclient-rb/engine/api/events.rb +3 -5
  25. data/lib/splitclient-rb/engine/api/impressions.rb +1 -1
  26. data/lib/splitclient-rb/engine/parser/split_adapter.rb +18 -1
  27. data/lib/splitclient-rb/managers/split_manager.rb +10 -9
  28. data/lib/splitclient-rb/split_config.rb +79 -17
  29. data/lib/splitclient-rb/split_factory.rb +11 -4
  30. data/lib/splitclient-rb/split_factory_builder.rb +1 -21
  31. data/lib/splitclient-rb/version.rb +1 -1
  32. data/sonar-scanner.sh +42 -0
  33. metadata +11 -10
  34. data/Detailed-README.md +0 -576
  35. data/NEWS +0 -144
  36. data/lib/splitclient-rb/clients/localhost_split_client.rb +0 -184
  37. data/lib/splitclient-rb/localhost_split_factory.rb +0 -14
  38. data/lib/splitclient-rb/localhost_utils.rb +0 -59
  39. data/lib/splitclient-rb/managers/localhost_split_manager.rb +0 -60
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5daeec48636b151d045e56802a5f9a13f7f260c
4
- data.tar.gz: 5129f877e3bef50cdb447f9bb5d3faa3e53ae381
3
+ metadata.gz: 0113b5144ddaff19b0231dafd90e0ce6b6173a0e
4
+ data.tar.gz: 62c75ac933beef2d057e8abfe5d2ac3524143e10
5
5
  SHA512:
6
- metadata.gz: 4618d8cf58aec9ec933c07a3aa3af3237a0bc38bde5a120ae7d2c69810f67d86e524529ed2ec040054b97cc3afdec76b5b98430cb34f417d74e10e9e693f36b6
7
- data.tar.gz: 156b3ca7caafef03e7ad1e1c0b9cd4b06a5d5a2b38139a446352f26f85429d6a775b0e2869e41781518c0d5511693630bdd94a88796613d37e70055669e14fe4
6
+ metadata.gz: 9a24e1b12d51669a62d9406e27af33754dc0ac0a1ba4b3dd286d8db94ada7b46e86ee552fe2955966c984b9944d73348e30b5efe2090fd4bd5dc32cf39b8e9ce
7
+ data.tar.gz: 1a788402527b1795d82e04a085bc1d1b9b593bb052120f5ec688b801b45145726e80518741071f86a4b8522a5aced65bcc0970f893ead2df2fe2f18a895f8d1f
@@ -0,0 +1,10 @@
1
+ # Ruby SDK
2
+
3
+ ## What did you accomplish?
4
+
5
+
6
+ ## How to test new changes?
7
+
8
+
9
+ ## Extra Notes
10
+
data/.gitignore CHANGED
@@ -52,3 +52,5 @@ dump.rdb
52
52
 
53
53
  # Ignore Appraisal gemfile.lock files
54
54
  /gemfiles/*.gemfile.lock
55
+
56
+ release.sh
data/.travis.yml CHANGED
@@ -6,6 +6,15 @@ rvm:
6
6
  services:
7
7
  - redis-server
8
8
 
9
+ addons:
10
+ sonarqube: true
11
+
12
+ git:
13
+ depth: false
14
+
9
15
  before_install:
10
16
  - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
11
17
  - gem install bundler -v '< 2'
18
+
19
+ after_success:
20
+ - bash sonar-scanner.sh
data/CHANGES.txt CHANGED
@@ -1,8 +1,24 @@
1
- 7.0.0 (Aug 21, 2019)
1
+ 7.0.1 (Oct 31, 2019)
2
+ - Updated localhost mode so that parsing of test files results in JSON data for splits analogous to that returned by the Split backend.
3
+ - Updated localhost mode to parse the mock data into Split objects to keep differences in operation to a minimum.
4
+ - Removed specific spare code dealing with localhost operations.
5
+ - Removed the disable_impressions configuration param.
6
+ - Fixed an issue about Event properties were not sent to be.
7
+ - Added ip_addresses_enabled to enable/disable sending MachineName and MachineIP headers when data is posted to Split Servers.
8
+ - Fixed an issue about attributes in matchers.
9
+ - Fixed an issue about trying to access a nil property when sending telemetry metrics.
10
+
11
+ 7.0.0 (Aug 23, 2019)
12
+ - BREAKING CHANGE: block_until_ready is now a method in both split_client and split_manager that needs to be explicitly called. The block_until_ready parameter is now ignored if passed in the configuration, and defaults to 15s unless passed as a parameter of the block_until_ready method.
13
+ - Added warning to track calls when traffic type does not belong to an existing split (only issued in the online client and when SDK is ready).
14
+ - Added warning to the get_treatment's method family when split does not exist in the current environment (only issued by online client and when SDK is ready).
15
+ - Added warning to the split_manager's split method when split does not exist in the current environment (only issued by online client and when SDK is ready).
16
+ - Added ability to create multiple split_factory instances. Added factory counts and warnings.
17
+ - Added SDK not ready impressions label.
2
18
  - Changed the splits method implementation in the splits_repository to make use of get_splits, which outperforms the current implementation.
3
19
 
4
20
  6.4.1 (Jul 26, 2019)
5
- - Fixed an issue in the latency metrics format preventing the synchronizer from correctly picking them up (consumer mode only). Old keys will be deleted on SDK startup.
21
+ - Fixed an issue in the latency metrics format preventing the synchronizer from correctly picking them up (consumer mode only). Old keys will be deleted on SDK startup.
6
22
 
7
23
  6.4.0 (Jul 05, 2019)
8
24
  - Added properties to track method.
@@ -171,34 +187,27 @@
171
187
  - Detach implementation for local factory and regular one.
172
188
 
173
189
  3.0.3
174
-
175
190
  - Fix nil ref in manager
176
191
 
177
192
  3.0.2
178
-
179
193
  - add ability to provide different bucketing/matching keys
180
194
 
181
195
  3.0.1
182
-
183
196
  - fix segments not deleting from the cache
184
197
 
185
198
  3.0.0
186
-
187
199
  - add new caching interface
188
200
  - add replaceable adapters to store cache in
189
201
  - add first cache adapter: MemoryAdapter
190
202
  - refactoring
191
203
 
192
204
  2.0.1
193
-
194
205
  - Supress warnings cause by Net::HTTP when it already exists.
195
206
 
196
207
  2.0.0
197
-
198
208
  - Add Factory for creation of Client and Manager interface.
199
209
 
200
210
  1.0.4
201
-
202
211
  - added support for AND combiner on conditions
203
212
  - added events_uri as config param which defines the metrics post url
204
213
  - updated metrics post default endpoint to be https://events.split.io/api/
@@ -214,10 +223,8 @@
214
223
  - added condition to return CONTROL on the deleted features
215
224
 
216
225
  1.0.1
217
-
218
226
  - .splits to .split for local env
219
227
  - isTreatment was removed from the API.
220
228
 
221
229
  1.0.0
222
-
223
230
  - Support multivariate treatment
@@ -0,0 +1,49 @@
1
+ # Contributing to the Split Ruby SDK
2
+
3
+ Split SDK is an open source project and we welcome feedback and contribution. The information below describes how to build the project with your changes, run the tests, and send the Pull Request(PR).
4
+
5
+ ## Development
6
+
7
+ ### Development process
8
+
9
+ 1. Fork the repository and create a topic branch from `development` branch. Please use a descriptive name for your branch.
10
+ 2. While developing, use descriptive messages in your commits. Avoid short or meaningless sentences like "fix bug".
11
+ 3. Make sure to add tests for both positive and negative cases.
12
+ 4. Run the linter script of the project and fix any issues you find.
13
+ 5. Run the build script and make sure it runs with no errors.
14
+ 6. Run all tests and make sure there are no failures.
15
+ 7. `git push` your changes to GitHub within your topic branch.
16
+ 8. Open a Pull Request(PR) from your forked repo and into the `development` branch of the original repository.
17
+ 9. When creating your PR, please fill out all the fields of the PR template, as applicable, for the project.
18
+ 10. Check for conflicts once the pull request is created to make sure your PR can be merged cleanly into `development`.
19
+ 11. Keep an eye out for any feedback or comments from Split's SDK team.
20
+
21
+ ### Building the SDK
22
+ To install this gem dependencies onto your local machine, run `bundle exec rake install`.
23
+
24
+ Then you can build the gem using `gem build splitclient-rb.gemspec` and install on your Ruby version with `gem install splitclient-rb-X.X.X.gem` (_the version number should match what you just built_).
25
+
26
+ ### Running tests
27
+ The gem uses `rspec` for unit testing. You can find the files for the unit tests and the specs helper file (`spec_helper.rb`) under the default `/spec` folder.
28
+
29
+ To run all the specs in the `spec` folder, use the provided rake task (_make sure Redis is running in localhost_):
30
+
31
+ ```bash
32
+ bundle exec rspec
33
+ ```
34
+
35
+ `Simplecov` is used for coverage reporting. Upon executing the rake task it will store the reports in the `/coverage` folder.
36
+
37
+ ### Linting and other useful checks
38
+ To run the static code analysis using Rubocop run:
39
+ ```bash
40
+ bundle exec rubocop
41
+ ```
42
+
43
+ If you want to benchmark the hashing algorithm (MurmurHash) run:
44
+ ```bash
45
+ bundle exec rake compile:murmurhash
46
+ ```
47
+
48
+ # Contact
49
+ If you have any other questions or need to contact us directly in a private manner send us a note at developers@split.io
data/README.md CHANGED
@@ -1,44 +1,78 @@
1
+ # Split SDK for Ruby
1
2
  [![Build Status](https://travis-ci.com/splitio/ruby-client.svg?branch=master)](https://travis-ci.com/splitio/ruby-client)
2
3
 
3
- # Split Ruby SDK
4
-
5
- This SDK is designed to work with [Split](https://www.split.io), the platform for controlled rollouts, serving features to your users via the Split feature flag to manage your complete customer experience.
6
-
7
- ### Quick setup
8
-
9
- For specific instructions on how to set up the Split SDK refer to our [Detailed-README](Detailed-README.md) or our [official SDK documentation](http://docs.split.io/docs/sdk-overview).
10
-
11
- ### Commitment to Quality:
12
-
13
- Split’s SDKs are in active development and are constantly tested for quality. Unit tests are developed for each SDK based on the unique needs of that language, and integration tests, load and performance tests, and behavior consistency tests are running 24/7 via automated bots. In addition, monitoring instrumentation ensures that these SDKs behave under the expected parameters of memory, CPU, and I/O.
14
-
15
- ### About Split:
16
-
17
- Split is the leading platform for feature experimentation, empowering businesses of all sizes to make smarter product decisions. Companies like Vevo, Twilio, and LendingTree rely on Split to securely release new features, target them to customers, and measure the impact of features on their customer experience metrics. Founded in 2015, Split's team comes from some of the most innovative enterprises in Silicon Valley, including Google, LinkedIn, Salesforce and Databricks. Split is based in Redwood City, California and backed by Accel Partners and Lightspeed Venture Partners.
18
-
19
- Our platform is a unified solution for continuous delivery and full-stack experimentation. Split unifies DevOps and product management, helping agile engineering and product teams accelerate the pace of product delivery and make data-driven decisions, through our robust feature flagging and extensive experimentation capabilities. With Split, organizations can now accelerate time to value, mitigate risk, and drive better outcomes, all in a unified platform.
20
-
21
- To learn more about Split, contact hello@split.io, or start a 14-day trial at https://www.split.io/signup/.
22
-
23
- Split has built and maintains a SDKs for:
24
-
25
- * Java [Github](https://github.com/splitio/java-client) [Docs](http://docs.split.io/docs/java-sdk-guide)
26
- * Javascript [Github](https://github.com/splitio/javascript-client) [Docs](http://docs.split.io/docs/javascript-sdk-overview)
27
- * Node [Github](https://github.com/splitio/javascript-client) [Docs](http://docs.split.io/docs/nodejs-sdk-overview)
28
- * .NET [Github](https://github.com/splitio/.net-client) [Docs](http://docs.split.io/docs/net-sdk-overview)
29
- * Ruby [Github](https://github.com/splitio/ruby-client) [Docs](http://docs.split.io/docs/ruby-sdk-overview)
30
- * PHP [Github](https://github.com/splitio/php-client) [Docs](http://docs.split.io/docs/php-sdk-overview)
31
- * Python [Github](https://github.com/splitio/python-client) [Docs](http://docs.split.io/docs/python-sdk-overview)
32
- * GO [Github](https://github.com/splitio/go-client) [Docs](http://docs.split.io/docs/go-sdk-overview)
33
- * Android [Github](https://github.com/splitio/android-client) [Docs](https://docs.split.io/docs/android-sdk-overview)
34
- * IOS [Github](https://github.com/splitio/ios-client) [Docs](https://docs.split.io/docs/ios-sdk-overview)
35
-
36
- For a comprehensive list of opensource projects visit our [Github page](https://github.com/splitio?utf8=%E2%9C%93&query=%20only%3Apublic%20).
37
-
4
+ ## Overview
5
+ This SDK is designed to work with Split, the platform for controlled rollouts, which serves features to your users via a Split feature flag to manage your complete customer experience.
6
+
7
+ [![Twitter Follow](https://img.shields.io/twitter/follow/splitsoftware.svg?style=social&label=Follow&maxAge=1529000)](https://twitter.com/intent/follow?screen_name=splitsoftware)
8
+
9
+ ## Compatibility
10
+ The Ruby SDK support Ruby version 2.3.0 or later and JRuby or 9.1.17 o later.
11
+
12
+ Also the Ruby SDK has been tested as a standalone app as well as using the following web servers:
13
+ - Puma
14
+ - Passenger
15
+ - Unicorn
16
+
17
+ For other setups, please reach out to [support@split.io](mailto:support@split.io).
18
+
19
+ ## Getting started
20
+ Below is a simple example that describes the instantiation and most basic usage of our SDK:
21
+ ```ruby
22
+ require 'splitclient-rb'
23
+
24
+ split_factory = SplitIoClient::SplitFactory.new('SDK_API_KEY')
25
+ split_client = split_factory.client
26
+
27
+ begin
28
+ split_client.block_until_ready
29
+ rescue SplitIoClient::SDKBlockerTimeoutExpiredException
30
+ puts 'SDK is not ready. Decide whether to continue or abort execution'
31
+ end
32
+
33
+ treatment = split_client.get_treatment('CUSTOMER_ID', 'SPLIT_NAME');
34
+
35
+ if treatment == 'on'
36
+ # insert code here to show on treatment
37
+ elsif treatment == 'off'
38
+ # insert code here to show off treatment
39
+ else
40
+ # insert your control treatment code here
41
+ end
42
+ ```
43
+ For multi-process environments you also need to setup Split Synchronizer. See [Sharing state: Redis integration](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK#sharing-state-redis-integration)
44
+
45
+ Please refer to [our official docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK) to learn about all the functionality provided by our SDK and the configuration options available for tailoring it to your current application setup.
46
+
47
+ ## Submitting issues
48
+ The Split team monitors all issues submitted to this [issue tracker](https://github.com/splitio/ruby-client/issues). We encourage you to use this issue tracker to submit any bug reports, feedback, and feature enhancements. We'll do our best to respond in a timely manner.
49
+
50
+ ## Contributing
51
+ Please see [Contributors Guide](CONTRIBUTORS-GUIDE.md) to find all you need to submit a Pull Request (PR).
52
+
53
+ ## License
54
+ Licensed under the Apache License, Version 2.0. See: [Apache License](http://www.apache.org/licenses/).
55
+
56
+ ## About Split
57
+ Split is the leading Feature Delivery Platform for engineering teams that want to confidently deploy features as fast as they can develop them. Split’s fine-grained management, real-time monitoring, and data-driven experimentation ensure that new features will improve the customer experience without breaking or degrading performance. Companies like Twilio, Salesforce, GoDaddy and WePay trust Split to power their feature delivery.
58
+
59
+ To learn more about Split, contact hello@split.io, or get started with feature flags for free at https://www.split.io/signup.
60
+
61
+ Split has built and maintains SDKs for:
62
+
63
+ * Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
64
+ * Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
65
+ * Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
66
+ * .NET [Github](https://github.com/splitio/.net-core-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
67
+ * Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
68
+ * PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
69
+ * Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
70
+ * GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
71
+ * Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
72
+ * iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
73
+
74
+ For a comprehensive list of open source projects visit our [Github page](https://github.com/splitio?utf8=%E2%9C%93&query=%20only%3Apublic%20).
75
+
38
76
  **Learn more about Split:**
39
-
40
- Visit [split.io/product](https://www.split.io/product) for an overview of Split, or visit our documentation at [docs.split.io](http://docs.split.io) for more detailed information.
41
-
42
- **System Status:**
43
-
44
- We use a status page to monitor the availability of Split’s various services. You can check the current status at [status.split.io](http://status.split.io).
77
+
78
+ Visit [split.io/product](https://www.split.io/product) for an overview of Split, or visit our documentation at [help.split.io](http://help.split.io) for more detailed information.
@@ -25,18 +25,18 @@ require 'splitclient-rb/cache/senders/impressions_formatter'
25
25
  require 'splitclient-rb/cache/senders/impressions_sender'
26
26
  require 'splitclient-rb/cache/senders/metrics_sender'
27
27
  require 'splitclient-rb/cache/senders/events_sender'
28
+ require 'splitclient-rb/cache/senders/localhost_repo_cleaner'
29
+ require 'splitclient-rb/cache/stores/store_utils'
30
+ require 'splitclient-rb/cache/stores/localhost_split_builder'
28
31
  require 'splitclient-rb/cache/stores/sdk_blocker'
29
32
  require 'splitclient-rb/cache/stores/segment_store'
30
33
  require 'splitclient-rb/cache/stores/split_store'
34
+ require 'splitclient-rb/cache/stores/localhost_split_store'
31
35
 
32
- require 'splitclient-rb/localhost_utils'
33
- require 'splitclient-rb/clients/localhost_split_client'
34
36
  require 'splitclient-rb/clients/split_client'
35
- require 'splitclient-rb/managers/localhost_split_manager'
36
37
  require 'splitclient-rb/managers/split_manager'
37
38
  require 'splitclient-rb/split_factory'
38
39
  require 'splitclient-rb/split_factory_builder'
39
- require 'splitclient-rb/localhost_split_factory'
40
40
  require 'splitclient-rb/split_config'
41
41
  require 'splitclient-rb/split_logger'
42
42
  require 'splitclient-rb/validators'
@@ -121,6 +121,10 @@ module SplitIoClient
121
121
  end
122
122
  end
123
123
 
124
+ def empty?
125
+ @map.empty?
126
+ end
127
+
124
128
  # This method is used in Redis adapter
125
129
  # "stubbing" it here to keep the interface
126
130
  def pipelined(&block)
@@ -42,6 +42,10 @@ module SplitIoClient
42
42
  def length
43
43
  @current_size.value
44
44
  end
45
+
46
+ def empty?
47
+ @queue.empty?
48
+ end
45
49
  end
46
50
  end
47
51
  end
@@ -46,6 +46,10 @@ module SplitIoClient
46
46
  @adapter.clear
47
47
  end
48
48
 
49
+ def empty?
50
+ @adapter.empty?
51
+ end
52
+
49
53
  private
50
54
 
51
55
  def random_sampler
@@ -6,11 +6,11 @@ module SplitIoClient
6
6
  # Repository which forwards impressions interface to the selected adapter
7
7
  class ImpressionsRepository < Repository
8
8
  extend Forwardable
9
- def_delegators :@adapter, :add, :add_bulk, :batch, :clear, :empty?
9
+ def_delegators :@repository, :add, :add_bulk, :batch, :clear, :empty?
10
10
 
11
11
  def initialize(config)
12
12
  super(config)
13
- @adapter = case @config.impressions_adapter.class.to_s
13
+ @repository = case @config.impressions_adapter.class.to_s
14
14
  when 'SplitIoClient::Cache::Adapters::MemoryAdapter'
15
15
  Repositories::Impressions::MemoryRepository.new(@config)
16
16
  when 'SplitIoClient::Cache::Adapters::RedisAdapter'
@@ -152,7 +152,7 @@ module SplitIoClient
152
152
  end
153
153
 
154
154
  def find_operation_latencies(operation)
155
- @latencies.find { |l| l[:operation] == operation }
155
+ @latencies.find { |l| l[:operation] == operation unless l.nil? }
156
156
  end
157
157
  end
158
158
  end
@@ -4,12 +4,12 @@ module SplitIoClient
4
4
  # Repository which forwards impressions interface to the selected adapter
5
5
  class MetricsRepository < Repository
6
6
  extend Forwardable
7
- def_delegators :@adapter, :add_count, :add_latency, :add_gauge, :counts, :latencies, :gauges,
7
+ def_delegators :@repository, :add_count, :add_latency, :add_gauge, :counts, :latencies, :gauges,
8
8
  :clear_counts, :clear_latencies, :clear_gauges, :clear, :fix_latencies
9
9
 
10
10
  def initialize(config)
11
11
  super(config)
12
- @adapter = case @config.metrics_adapter.class.to_s
12
+ @repository = case @config.metrics_adapter.class.to_s
13
13
  when 'SplitIoClient::Cache::Adapters::MemoryAdapter'
14
14
  Repositories::Metrics::MemoryRepository.new(@config)
15
15
  when 'SplitIoClient::Cache::Adapters::RedisAdapter'
@@ -11,11 +11,6 @@ module SplitIoClient
11
11
  end
12
12
 
13
13
  def call
14
- if @config.disable_impressions
15
- @config.logger.info('Disabling impressions service by config')
16
- return
17
- end
18
-
19
14
  if ENV['SPLITCLIENT_ENV'] == 'test'
20
15
  post_impressions
21
16
  else
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SplitIoClient
4
+ module Cache
5
+ module Senders
6
+ class LocalhostRepoCleaner
7
+ def initialize(impressions_repository, metrics_repository, events_repository, config)
8
+ @impressions_repository = impressions_repository
9
+ @metrics_repository = metrics_repository
10
+ @events_repository = events_repository
11
+ @config = config
12
+ end
13
+
14
+ def call
15
+ if ENV['SPLITCLIENT_ENV'] == 'test'
16
+ clear_repositories
17
+ else
18
+ cleaner_thread
19
+
20
+ if defined?(PhusionPassenger)
21
+ PhusionPassenger.on_event(:starting_worker_process) do |forked|
22
+ cleaner_thread if forked
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def cleaner_thread
31
+ @config.threads[:repo_cleaner] = Thread.new do
32
+ @config.logger.info('Starting repositories cleanup service')
33
+ loop do
34
+ clear_repositories
35
+
36
+ sleep(SplitIoClient::Utilities.randomize_interval(@config.features_refresh_rate))
37
+ end
38
+ end
39
+ end
40
+
41
+ def clear_repositories
42
+ @impressions_repository.clear
43
+ @metrics_repository.clear
44
+ @events_repository.clear
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end