splitclient-rb 6.3.0 → 8.11.0

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.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -0
  3. data/.github/pull_request_template.md +9 -0
  4. data/.github/workflows/ci.yml +90 -0
  5. data/.github/workflows/update-license-year.yml +45 -0
  6. data/.gitignore +4 -0
  7. data/.rubocop.yml +46 -3
  8. data/CHANGES.txt +158 -11
  9. data/CONTRIBUTORS-GUIDE.md +49 -0
  10. data/LICENSE +169 -13
  11. data/NOTICE.txt +5 -0
  12. data/README.md +67 -27
  13. data/Rakefile +1 -8
  14. data/ext/murmurhash/3_x64_128.c +117 -0
  15. data/ext/murmurhash/murmurhash.c +5 -1
  16. data/lib/murmurhash/murmurhash.jar +0 -0
  17. data/lib/splitclient-rb/cache/adapters/cache_adapter.rb +3 -3
  18. data/lib/splitclient-rb/cache/adapters/memory_adapters/map_adapter.rb +4 -0
  19. data/lib/splitclient-rb/cache/adapters/memory_adapters/queue_adapter.rb +7 -0
  20. data/lib/splitclient-rb/cache/adapters/redis_adapter.rb +12 -4
  21. data/lib/splitclient-rb/cache/fetchers/segment_fetcher.rb +83 -0
  22. data/lib/splitclient-rb/cache/fetchers/split_fetcher.rb +70 -0
  23. data/lib/splitclient-rb/cache/filter/bloom_filter.rb +67 -0
  24. data/lib/splitclient-rb/cache/filter/filter_adapter.rb +32 -0
  25. data/lib/splitclient-rb/cache/filter/flag_set_filter.rb +40 -0
  26. data/lib/splitclient-rb/cache/hashers/impression_hasher.rb +34 -0
  27. data/lib/splitclient-rb/cache/observers/impression_observer.rb +22 -0
  28. data/lib/splitclient-rb/cache/observers/noop_impression_observer.rb +10 -0
  29. data/lib/splitclient-rb/cache/repositories/events/memory_repository.rb +26 -14
  30. data/lib/splitclient-rb/cache/repositories/events/redis_repository.rb +9 -14
  31. data/lib/splitclient-rb/cache/repositories/events_repository.rb +31 -10
  32. data/lib/splitclient-rb/cache/repositories/flag_sets/memory_repository.rb +40 -0
  33. data/lib/splitclient-rb/cache/repositories/flag_sets/redis_repository.rb +49 -0
  34. data/lib/splitclient-rb/cache/repositories/impressions/memory_repository.rb +22 -23
  35. data/lib/splitclient-rb/cache/repositories/impressions/redis_repository.rb +15 -22
  36. data/lib/splitclient-rb/cache/repositories/impressions_repository.rb +6 -31
  37. data/lib/splitclient-rb/cache/repositories/repository.rb +6 -5
  38. data/lib/splitclient-rb/cache/repositories/rule_based_segments_repository.rb +136 -0
  39. data/lib/splitclient-rb/cache/repositories/segments_repository.rb +46 -6
  40. data/lib/splitclient-rb/cache/repositories/splits_repository.rb +232 -43
  41. data/lib/splitclient-rb/cache/routers/impression_router.rb +24 -22
  42. data/lib/splitclient-rb/cache/senders/events_sender.rb +12 -29
  43. data/lib/splitclient-rb/cache/senders/impressions_adapter/memory_sender.rb +71 -0
  44. data/lib/splitclient-rb/cache/senders/impressions_adapter/redis_sender.rb +69 -0
  45. data/lib/splitclient-rb/cache/senders/impressions_count_sender.rb +43 -0
  46. data/lib/splitclient-rb/cache/senders/impressions_formatter.rb +27 -13
  47. data/lib/splitclient-rb/cache/senders/impressions_sender.rb +11 -25
  48. data/lib/splitclient-rb/cache/senders/impressions_sender_adapter.rb +21 -0
  49. data/lib/splitclient-rb/cache/senders/localhost_repo_cleaner.rb +47 -0
  50. data/lib/splitclient-rb/cache/stores/localhost_split_builder.rb +95 -0
  51. data/lib/splitclient-rb/cache/stores/localhost_split_store.rb +110 -0
  52. data/lib/splitclient-rb/cache/stores/store_utils.rb +13 -0
  53. data/lib/splitclient-rb/clients/split_client.rb +385 -138
  54. data/lib/splitclient-rb/constants.rb +16 -0
  55. data/lib/splitclient-rb/engine/api/client.rb +38 -43
  56. data/lib/splitclient-rb/engine/api/events.rb +19 -11
  57. data/lib/splitclient-rb/engine/api/faraday_middleware/gzip.rb +1 -0
  58. data/lib/splitclient-rb/engine/api/impressions.rb +49 -14
  59. data/lib/splitclient-rb/engine/api/segments.rb +31 -24
  60. data/lib/splitclient-rb/engine/api/splits.rb +108 -33
  61. data/lib/splitclient-rb/engine/api/telemetry_api.rb +47 -0
  62. data/lib/splitclient-rb/engine/auth_api_client.rb +96 -0
  63. data/lib/splitclient-rb/engine/back_off.rb +26 -0
  64. data/lib/splitclient-rb/engine/common/impressions_counter.rb +45 -0
  65. data/lib/splitclient-rb/engine/common/impressions_manager.rb +165 -0
  66. data/lib/splitclient-rb/engine/common/noop_impressions_counter.rb +27 -0
  67. data/lib/splitclient-rb/engine/events/events_delivery.rb +20 -0
  68. data/lib/splitclient-rb/engine/events/events_manager.rb +194 -0
  69. data/lib/splitclient-rb/engine/events/events_manager_config.rb +96 -0
  70. data/lib/splitclient-rb/engine/events/events_task.rb +50 -0
  71. data/lib/splitclient-rb/engine/events/noop_events_queue.rb +13 -0
  72. data/lib/splitclient-rb/engine/fallback_treatment_calculator.rb +48 -0
  73. data/lib/splitclient-rb/engine/impressions/noop_unique_keys_tracker.rb +17 -0
  74. data/lib/splitclient-rb/engine/impressions/unique_keys_tracker.rb +144 -0
  75. data/lib/splitclient-rb/engine/matchers/all_keys_matcher.rb +1 -1
  76. data/lib/splitclient-rb/engine/matchers/between_matcher.rb +7 -5
  77. data/lib/splitclient-rb/engine/matchers/between_semver_matcher.rb +33 -0
  78. data/lib/splitclient-rb/engine/matchers/combining_matcher.rb +10 -8
  79. data/lib/splitclient-rb/engine/matchers/contains_all_matcher.rb +2 -6
  80. data/lib/splitclient-rb/engine/matchers/contains_any_matcher.rb +1 -5
  81. data/lib/splitclient-rb/engine/matchers/contains_matcher.rb +7 -5
  82. data/lib/splitclient-rb/engine/matchers/dependency_matcher.rb +6 -5
  83. data/lib/splitclient-rb/engine/matchers/ends_with_matcher.rb +5 -4
  84. data/lib/splitclient-rb/engine/matchers/equal_to_boolean_matcher.rb +3 -2
  85. data/lib/splitclient-rb/engine/matchers/equal_to_matcher.rb +6 -4
  86. data/lib/splitclient-rb/engine/matchers/equal_to_semver_matcher.rb +28 -0
  87. data/lib/splitclient-rb/engine/matchers/equal_to_set_matcher.rb +1 -5
  88. data/lib/splitclient-rb/engine/matchers/greater_than_or_equal_to_matcher.rb +6 -4
  89. data/lib/splitclient-rb/engine/matchers/greater_than_or_equal_to_semver_matcher.rb +28 -0
  90. data/lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb +36 -0
  91. data/lib/splitclient-rb/engine/matchers/less_than_or_equal_to_matcher.rb +6 -4
  92. data/lib/splitclient-rb/engine/matchers/less_than_or_equal_to_semver_matcher.rb +28 -0
  93. data/lib/splitclient-rb/engine/matchers/matcher.rb +22 -0
  94. data/lib/splitclient-rb/engine/matchers/matches_string_matcher.rb +3 -2
  95. data/lib/splitclient-rb/engine/matchers/negation_matcher.rb +3 -2
  96. data/lib/splitclient-rb/engine/matchers/part_of_set_matcher.rb +2 -6
  97. data/lib/splitclient-rb/engine/matchers/prerequisites_matcher.rb +31 -0
  98. data/lib/splitclient-rb/engine/matchers/rule_based_segment_matcher.rb +78 -0
  99. data/lib/splitclient-rb/engine/matchers/semver.rb +201 -0
  100. data/lib/splitclient-rb/engine/matchers/set_matcher.rb +2 -1
  101. data/lib/splitclient-rb/engine/matchers/starts_with_matcher.rb +4 -3
  102. data/lib/splitclient-rb/engine/matchers/user_defined_segment_matcher.rb +3 -2
  103. data/lib/splitclient-rb/engine/matchers/whitelist_matcher.rb +7 -5
  104. data/lib/splitclient-rb/engine/metrics/binary_search_latency_tracker.rb +3 -65
  105. data/lib/splitclient-rb/engine/models/evaluation_options.rb +9 -0
  106. data/lib/splitclient-rb/engine/models/event_active_subscriptions.rb +14 -0
  107. data/lib/splitclient-rb/engine/models/events_metadata.rb +10 -0
  108. data/lib/splitclient-rb/engine/models/fallback_treatment.rb +11 -0
  109. data/lib/splitclient-rb/engine/models/fallback_treatments_configuration.rb +36 -0
  110. data/lib/splitclient-rb/engine/models/label.rb +3 -0
  111. data/lib/splitclient-rb/engine/models/sdk_event.rb +4 -0
  112. data/lib/splitclient-rb/engine/models/sdk_event_type.rb +4 -0
  113. data/lib/splitclient-rb/engine/models/sdk_internal_event.rb +8 -0
  114. data/lib/splitclient-rb/engine/models/sdk_internal_event_notification.rb +14 -0
  115. data/lib/splitclient-rb/engine/models/segment_type.rb +4 -0
  116. data/lib/splitclient-rb/engine/models/split_http_response.rb +19 -0
  117. data/lib/splitclient-rb/engine/models/valid_sdk_event.rb +14 -0
  118. data/lib/splitclient-rb/engine/parser/condition.rb +81 -20
  119. data/lib/splitclient-rb/engine/parser/evaluator.rb +40 -51
  120. data/lib/splitclient-rb/engine/push_manager.rb +66 -0
  121. data/lib/splitclient-rb/engine/status_manager.rb +39 -0
  122. data/lib/splitclient-rb/engine/sync_manager.rb +180 -0
  123. data/lib/splitclient-rb/engine/synchronizer.rb +231 -0
  124. data/lib/splitclient-rb/exceptions.rb +20 -1
  125. data/lib/splitclient-rb/helpers/decryption_helper.rb +25 -0
  126. data/lib/splitclient-rb/helpers/evaluator_helper.rb +37 -0
  127. data/lib/splitclient-rb/helpers/repository_helper.rb +61 -0
  128. data/lib/splitclient-rb/helpers/thread_helper.rb +24 -0
  129. data/lib/splitclient-rb/helpers/util.rb +26 -0
  130. data/lib/splitclient-rb/managers/split_manager.rb +58 -20
  131. data/lib/splitclient-rb/spec.rb +9 -0
  132. data/lib/splitclient-rb/split_config.rb +336 -54
  133. data/lib/splitclient-rb/split_factory.rb +219 -33
  134. data/lib/splitclient-rb/split_factory_builder.rb +1 -22
  135. data/lib/splitclient-rb/split_factory_registry.rb +63 -0
  136. data/lib/splitclient-rb/split_logger.rb +9 -10
  137. data/lib/splitclient-rb/sse/event_source/client.rb +263 -0
  138. data/lib/splitclient-rb/sse/event_source/event_parser.rb +65 -0
  139. data/lib/splitclient-rb/sse/event_source/event_types.rb +15 -0
  140. data/lib/splitclient-rb/sse/event_source/stream_data.rb +22 -0
  141. data/lib/splitclient-rb/sse/notification_manager_keeper.rb +84 -0
  142. data/lib/splitclient-rb/sse/notification_processor.rb +48 -0
  143. data/lib/splitclient-rb/sse/sse_handler.rb +44 -0
  144. data/lib/splitclient-rb/sse/workers/segments_worker.rb +62 -0
  145. data/lib/splitclient-rb/sse/workers/splits_worker.rb +149 -0
  146. data/lib/splitclient-rb/telemetry/domain/constants.rb +48 -0
  147. data/lib/splitclient-rb/telemetry/domain/structs.rb +35 -0
  148. data/lib/splitclient-rb/telemetry/evaluation_consumer.rb +14 -0
  149. data/lib/splitclient-rb/telemetry/evaluation_producer.rb +21 -0
  150. data/lib/splitclient-rb/telemetry/init_consumer.rb +14 -0
  151. data/lib/splitclient-rb/telemetry/init_producer.rb +19 -0
  152. data/lib/splitclient-rb/telemetry/memory/memory_evaluation_consumer.rb +32 -0
  153. data/lib/splitclient-rb/telemetry/memory/memory_evaluation_producer.rb +24 -0
  154. data/lib/splitclient-rb/telemetry/memory/memory_init_consumer.rb +28 -0
  155. data/lib/splitclient-rb/telemetry/memory/memory_init_producer.rb +34 -0
  156. data/lib/splitclient-rb/telemetry/memory/memory_runtime_consumer.rb +119 -0
  157. data/lib/splitclient-rb/telemetry/memory/memory_runtime_producer.rb +87 -0
  158. data/lib/splitclient-rb/telemetry/memory/memory_synchronizer.rb +213 -0
  159. data/lib/splitclient-rb/telemetry/redis/redis_evaluation_producer.rb +38 -0
  160. data/lib/splitclient-rb/telemetry/redis/redis_init_producer.rb +37 -0
  161. data/lib/splitclient-rb/telemetry/redis/redis_synchronizer.rb +27 -0
  162. data/lib/splitclient-rb/telemetry/runtime_consumer.rb +25 -0
  163. data/lib/splitclient-rb/telemetry/runtime_producer.rb +25 -0
  164. data/lib/splitclient-rb/telemetry/storages/memory.rb +159 -0
  165. data/lib/splitclient-rb/telemetry/sync_task.rb +36 -0
  166. data/lib/splitclient-rb/telemetry/synchronizer.rb +33 -0
  167. data/lib/splitclient-rb/utilitites.rb +8 -0
  168. data/lib/splitclient-rb/validators.rb +142 -38
  169. data/lib/splitclient-rb/version.rb +1 -1
  170. data/lib/splitclient-rb.rb +101 -16
  171. data/sonar-project.properties +6 -0
  172. data/splitclient-rb.gemspec +28 -23
  173. metadata +262 -82
  174. data/.travis.yml +0 -11
  175. data/Appraisals +0 -10
  176. data/Detailed-README.md +0 -588
  177. data/NEWS +0 -141
  178. data/lib/splitclient-rb/cache/repositories/metrics/memory_repository.rb +0 -127
  179. data/lib/splitclient-rb/cache/repositories/metrics/redis_repository.rb +0 -96
  180. data/lib/splitclient-rb/cache/repositories/metrics_repository.rb +0 -21
  181. data/lib/splitclient-rb/cache/senders/metrics_sender.rb +0 -56
  182. data/lib/splitclient-rb/cache/stores/sdk_blocker.rb +0 -46
  183. data/lib/splitclient-rb/cache/stores/segment_store.rb +0 -81
  184. data/lib/splitclient-rb/cache/stores/split_store.rb +0 -102
  185. data/lib/splitclient-rb/clients/localhost_split_client.rb +0 -183
  186. data/lib/splitclient-rb/engine/api/faraday_adapter/patched_net_http_persistent.rb +0 -46
  187. data/lib/splitclient-rb/engine/api/metrics.rb +0 -60
  188. data/lib/splitclient-rb/engine/metrics/metrics.rb +0 -80
  189. data/lib/splitclient-rb/engine/parser/split_adapter.rb +0 -81
  190. data/lib/splitclient-rb/localhost_split_factory.rb +0 -13
  191. data/lib/splitclient-rb/localhost_utils.rb +0 -59
  192. data/lib/splitclient-rb/managers/localhost_split_manager.rb +0 -60
data/LICENSE CHANGED
@@ -1,13 +1,169 @@
1
- Copyright 2018 Split Software, Co.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
5
+ 1. Definitions.
6
+ "License" shall mean the terms and conditions for use, reproduction,
7
+ and distribution as defined by Sections 1 through 9 of this document.
8
+ "Licensor" shall mean the copyright owner or entity authorized by
9
+ the copyright owner that is granting the License.
10
+ "Legal Entity" shall mean the union of the acting entity and all
11
+ other entities that control, are controlled by, or are under common
12
+ control with that entity. For the purposes of this definition,
13
+ "control" means (i) the power, direct or indirect, to cause the
14
+ direction or management of such entity, whether by contract or
15
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
16
+ outstanding shares, or (iii) beneficial ownership of such entity.
17
+ "You" (or "Your") shall mean an individual or Legal Entity
18
+ exercising permissions granted by this License.
19
+ "Source" form shall mean the preferred form for making modifications,
20
+ including but not limited to software source code, documentation
21
+ source, and configuration files.
22
+ "Object" form shall mean any form resulting from mechanical
23
+ transformation or translation of a Source form, including but
24
+ not limited to compiled object code, generated documentation,
25
+ and conversions to other media types.
26
+ "Work" shall mean the work of authorship, whether in Source or
27
+ Object form, made available under the License, as indicated by a
28
+ copyright notice that is included in or attached to the work
29
+ (an example is provided in the Appendix below).
30
+ "Derivative Works" shall mean any work, whether in Source or Object
31
+ form, that is based on (or derived from) the Work and for which the
32
+ editorial revisions, annotations, elaborations, or other modifications
33
+ represent, as a whole, an original work of authorship. For the purposes
34
+ of this License, Derivative Works shall not include works that remain
35
+ separable from, or merely link (or bind by name) to the interfaces of,
36
+ the Work and Derivative Works thereof.
37
+ "Contribution" shall mean any work of authorship, including
38
+ the original version of the Work and any modifications or additions
39
+ to that Work or Derivative Works thereof, that is intentionally
40
+ submitted to Licensor for inclusion in the Work by the copyright owner
41
+ or by an individual or Legal Entity authorized to submit on behalf of
42
+ the copyright owner. For the purposes of this definition, "submitted"
43
+ means any form of electronic, verbal, or written communication sent
44
+ to the Licensor or its representatives, including but not limited to
45
+ communication on electronic mailing lists, source code control systems,
46
+ and issue tracking systems that are managed by, or on behalf of, the
47
+ Licensor for the purpose of discussing and improving the Work, but
48
+ excluding communication that is conspicuously marked or otherwise
49
+ designated in writing by the copyright owner as "Not a Contribution."
50
+ "Contributor" shall mean Licensor and any individual or Legal Entity
51
+ on behalf of whom a Contribution has been received by Licensor and
52
+ subsequently incorporated within the Work.
53
+ 2. Grant of Copyright License. Subject to the terms and conditions of
54
+ this License, each Contributor hereby grants to You a perpetual,
55
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
56
+ copyright license to reproduce, prepare Derivative Works of,
57
+ publicly display, publicly perform, sublicense, and distribute the
58
+ Work and such Derivative Works in Source or Object form.
59
+ 3. Grant of Patent License. Subject to the terms and conditions of
60
+ this License, each Contributor hereby grants to You a perpetual,
61
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
62
+ (except as stated in this section) patent license to make, have made,
63
+ use, offer to sell, sell, import, and otherwise transfer the Work,
64
+ where such license applies only to those patent claims licensable
65
+ by such Contributor that are necessarily infringed by their
66
+ Contribution(s) alone or by combination of their Contribution(s)
67
+ with the Work to which such Contribution(s) was submitted. If You
68
+ institute patent litigation against any entity (including a
69
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
70
+ or a Contribution incorporated within the Work constitutes direct
71
+ or contributory patent infringement, then any patent licenses
72
+ granted to You under this License for that Work shall terminate
73
+ as of the date such litigation is filed.
74
+ 4. Redistribution. You may reproduce and distribute copies of the
75
+ Work or Derivative Works thereof in any medium, with or without
76
+ modifications, and in Source or Object form, provided that You
77
+ meet the following conditions:
78
+ (a) You must give any other recipients of the Work or
79
+ Derivative Works a copy of this License; and
80
+ (b) You must cause any modified files to carry prominent notices
81
+ stating that You changed the files; and
82
+ (c) You must retain, in the Source form of any Derivative Works
83
+ that You distribute, all copyright, patent, trademark, and
84
+ attribution notices from the Source form of the Work,
85
+ excluding those notices that do not pertain to any part of
86
+ the Derivative Works; and
87
+ (d) If the Work includes a "NOTICE" text file as part of its
88
+ distribution, then any Derivative Works that You distribute must
89
+ include a readable copy of the attribution notices contained
90
+ within such NOTICE file, excluding those notices that do not
91
+ pertain to any part of the Derivative Works, in at least one
92
+ of the following places: within a NOTICE text file distributed
93
+ as part of the Derivative Works; within the Source form or
94
+ documentation, if provided along with the Derivative Works; or,
95
+ within a display generated by the Derivative Works, if and
96
+ wherever such third-party notices normally appear. The contents
97
+ of the NOTICE file are for informational purposes only and
98
+ do not modify the License. You may add Your own attribution
99
+ notices within Derivative Works that You distribute, alongside
100
+ or as an addendum to the NOTICE text from the Work, provided
101
+ that such additional attribution notices cannot be construed
102
+ as modifying the License.
103
+ You may add Your own copyright statement to Your modifications and
104
+ may provide additional or different license terms and conditions
105
+ for use, reproduction, or distribution of Your modifications, or
106
+ for any such Derivative Works as a whole, provided Your use,
107
+ reproduction, and distribution of the Work otherwise complies with
108
+ the conditions stated in this License.
109
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
110
+ any Contribution intentionally submitted for inclusion in the Work
111
+ by You to the Licensor shall be under the terms and conditions of
112
+ this License, without any additional terms or conditions.
113
+ Notwithstanding the above, nothing herein shall supersede or modify
114
+ the terms of any separate license agreement you may have executed
115
+ with Licensor regarding such Contributions.
116
+ 6. Trademarks. This License does not grant permission to use the trade
117
+ names, trademarks, service marks, or product names of the Licensor,
118
+ except as required for reasonable and customary use in describing the
119
+ origin of the Work and reproducing the content of the NOTICE file.
120
+ 7. Disclaimer of Warranty. Unless required by applicable law or
121
+ agreed to in writing, Licensor provides the Work (and each
122
+ Contributor provides its Contributions) on an "AS IS" BASIS,
123
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
124
+ implied, including, without limitation, any warranties or conditions
125
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
126
+ PARTICULAR PURPOSE. You are solely responsible for determining the
127
+ appropriateness of using or redistributing the Work and assume any
128
+ risks associated with Your exercise of permissions under this License.
129
+ 8. Limitation of Liability. In no event and under no legal theory,
130
+ whether in tort (including negligence), contract, or otherwise,
131
+ unless required by applicable law (such as deliberate and grossly
132
+ negligent acts) or agreed to in writing, shall any Contributor be
133
+ liable to You for damages, including any direct, indirect, special,
134
+ incidental, or consequential damages of any character arising as a
135
+ result of this License or out of the use or inability to use the
136
+ Work (including but not limited to damages for loss of goodwill,
137
+ work stoppage, computer failure or malfunction, or any and all
138
+ other commercial damages or losses), even if such Contributor
139
+ has been advised of the possibility of such damages.
140
+ 9. Accepting Warranty or Additional Liability. While redistributing
141
+ the Work or Derivative Works thereof, You may choose to offer,
142
+ and charge a fee for, acceptance of support, warranty, indemnity,
143
+ or other liability obligations and/or rights consistent with this
144
+ License. However, in accepting such obligations, You may act only
145
+ on Your own behalf and on Your sole responsibility, not on behalf
146
+ of any other Contributor, and only if You agree to indemnify,
147
+ defend, and hold each Contributor harmless for any liability
148
+ incurred by, or claims asserted against, such Contributor by reason
149
+ of your accepting any such warranty or additional liability.
150
+ END OF TERMS AND CONDITIONS
151
+ APPENDIX: How to apply the Apache License to your work.
152
+ To apply the Apache License to your work, attach the following
153
+ boilerplate notice, with the fields enclosed by brackets "[]"
154
+ replaced with your own identifying information. (Don't include
155
+ the brackets!) The text should be enclosed in the appropriate
156
+ comment syntax for the file format. We also recommend that a
157
+ file or class name and description of purpose be included on the
158
+ same "printed page" as the copyright notice for easier
159
+ identification within third-party archives.
160
+ Copyright [yyyy] [name of copyright owner]
161
+ Licensed under the Apache License, Version 2.0 (the "License");
162
+ you may not use this file except in compliance with the License.
163
+ You may obtain a copy of the License at
164
+ http://www.apache.org/licenses/LICENSE-2.0
165
+ Unless required by applicable law or agreed to in writing, software
166
+ distributed under the License is distributed on an "AS IS" BASIS,
167
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
168
+ See the License for the specific language governing permissions and
169
+ limitations under the License.
data/NOTICE.txt ADDED
@@ -0,0 +1,5 @@
1
+ Harness Feature Management JavaScript SDK Copyright 2024-2026 Harness Inc.
2
+
3
+ This product includes software developed at Harness Inc. (https://harness.io/).
4
+
5
+ This product includes software originally developed by Split Software, Inc. (https://www.split.io/). Copyright 2016-2024 Split Software, Inc.
data/README.md CHANGED
@@ -1,44 +1,84 @@
1
- [ ![Codeship Status for splitio/ruby-client](https://app.codeship.com/projects/306c6b60-c164-0133-e179-16471d4e6045/status?branch=master)](https://app.codeship.com/projects/137510)
1
+ # Split SDK for Ruby
2
+ [![build status](https://github.com/splitio/ruby-client/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/splitio/ruby-client/actions)
3
+ [![Documentation](https://img.shields.io/badge/ruby_client-documentation-informational)](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
2
4
 
3
- # Split Ruby SDK
5
+ ## Overview
6
+ This SDK is designed to work with Split, the platform for controlled rollouts, which serves features to your users via feature flags to manage your complete customer experience.
4
7
 
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.
8
+ [![Twitter Follow](https://img.shields.io/twitter/follow/splitsoftware.svg?style=social&label=Follow&maxAge=1529000)](https://twitter.com/intent/follow?screen_name=splitsoftware)
6
9
 
7
- ### Quick setup
10
+ ## Compatibility
11
+ The Ruby SDK support Ruby version 2.5.0 or later and JRuby or 9.1.17 o later.
8
12
 
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).
13
+ Also the Ruby SDK has been tested as a standalone app as well as using the following web servers:
14
+ - Puma
15
+ - Passenger
16
+ - Unicorn
10
17
 
11
- ### Commitment to Quality:
18
+ For other setups, please reach out to [support@split.io](mailto:support@split.io).
12
19
 
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.
20
+ ## Getting started
21
+ Below is a simple example that describes the instantiation and most basic usage of our SDK:
22
+ ```ruby
23
+ require 'splitclient-rb'
14
24
 
15
- ### About Split:
25
+ split_factory = SplitIoClient::SplitFactory.new('YOUR_SDK_KEY')
26
+ split_client = split_factory.client
16
27
 
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.
28
+ begin
29
+ split_client.block_until_ready
30
+ rescue SplitIoClient::SDKBlockerTimeoutExpiredException
31
+ puts 'SDK is not ready. Decide whether to continue or abort execution'
32
+ end
18
33
 
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.
34
+ treatment = split_client.get_treatment('CUSTOMER_ID', 'FEATURE_FLAG_NAME');
20
35
 
21
- To learn more about Split, contact hello@split.io, or start a 14-day trial at https://www.split.io/signup/.
36
+ if treatment == 'on'
37
+ # insert code here to show on treatment
38
+ elsif treatment == 'off'
39
+ # insert code here to show off treatment
40
+ else
41
+ # insert your control treatment code here
42
+ end
43
+ ```
44
+ 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)
22
45
 
23
- Split has built and maintains a SDKs for:
46
+ 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.
24
47
 
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)
48
+ ## Submitting issues
49
+ 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.
35
50
 
36
- For a comprehensive list of opensource projects visit our [Github page](https://github.com/splitio?utf8=%E2%9C%93&query=%20only%3Apublic%20).
51
+ ## Contributing
52
+ Please see [Contributors Guide](CONTRIBUTORS-GUIDE.md) to find all you need to submit a Pull Request (PR).
37
53
 
38
- **Learn more about Split:**
54
+ ## License
55
+ Licensed under the Apache License, Version 2.0. See: [Apache License](http://www.apache.org/licenses/).
39
56
 
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.
57
+ ## About Split
58
+ 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.
41
59
 
42
- **System Status:**
60
+ To learn more about Split, contact hello@split.io, or get started with feature flags for free at https://www.split.io/signup.
43
61
 
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).
62
+ Split has built and maintains SDKs for:
63
+
64
+ * .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
65
+ * Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
66
+ * Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities)
67
+ * GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
68
+ * iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
69
+ * Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
70
+ * JavaScript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
71
+ * JavaScript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
72
+ * Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
73
+ * PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
74
+ * Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
75
+ * React [Github](https://github.com/splitio/react-client) [Docs](https://help.split.io/hc/en-us/articles/360038825091-React-SDK)
76
+ * React Native [Github](https://github.com/splitio/react-native-client) [Docs](https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK)
77
+ * Redux [Github](https://github.com/splitio/redux-client) [Docs](https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK)
78
+ * Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
79
+
80
+ For a comprehensive list of open source projects visit our [Github page](https://github.com/splitio?utf8=%E2%9C%93&query=%20only%3Apublic%20).
81
+
82
+ **Learn more about Split:**
83
+
84
+ 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.
data/Rakefile CHANGED
@@ -3,7 +3,6 @@
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
5
  require 'rubocop/rake_task'
6
- require 'appraisal'
7
6
 
8
7
  Dir['tasks/**/*.rake'].each { |rake| load rake }
9
8
 
@@ -26,10 +25,4 @@ else
26
25
  end
27
26
  end
28
27
 
29
- if !ENV['APPRAISAL_INITIALIZED']
30
- task :default do
31
- sh 'appraisal install && rake appraisal && rake rubocop'
32
- end
33
- else
34
- task default: %i[spec rubocop]
35
- end
28
+ task default: %i[spec rubocop]
@@ -0,0 +1,117 @@
1
+ /*
2
+ * MurmurHash3_x64_128 (C) Austin Appleby
3
+ */
4
+
5
+ #include "murmurhash.h"
6
+
7
+ void
8
+ murmur_hash_process3_x64_128(const char * key, uint32_t len, uint32_t seed, void *out)
9
+ {
10
+ const uint8_t * data = (const uint8_t*)key;
11
+ const int nblocks = len / 16;
12
+
13
+ uint64_t h1 = seed;
14
+ uint64_t h2 = seed;
15
+
16
+ const uint64_t c1 = (uint64_t)BIG_CONSTANT(0x87c37b91114253d5);
17
+ const uint64_t c2 = (uint64_t)BIG_CONSTANT(0x4cf5ad432745937f);
18
+
19
+ //----------
20
+ // body
21
+
22
+ const uint64_t * blocks = (const uint64_t *)(data);
23
+
24
+ int i;
25
+
26
+ for(i = 0; i < nblocks; i++)
27
+ {
28
+ uint64_t k1 = getblock64(blocks,i*2+0);
29
+ uint64_t k2 = getblock64(blocks,i*2+1);
30
+
31
+ k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
32
+
33
+ h1 = ROTL64(h1,27); h1 += h2; h1 = h1*5+0x52dce729;
34
+
35
+ k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2;
36
+
37
+ h2 = ROTL64(h2,31); h2 += h1; h2 = h2*5+0x38495ab5;
38
+ }
39
+
40
+ //----------
41
+ // tail
42
+
43
+ const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
44
+
45
+ uint64_t k1 = 0;
46
+ uint64_t k2 = 0;
47
+
48
+ switch(len & 15)
49
+ {
50
+ case 15: k2 ^= ((uint64_t)tail[14]) << 48;
51
+ case 14: k2 ^= ((uint64_t)tail[13]) << 40;
52
+ case 13: k2 ^= ((uint64_t)tail[12]) << 32;
53
+ case 12: k2 ^= ((uint64_t)tail[11]) << 24;
54
+ case 11: k2 ^= ((uint64_t)tail[10]) << 16;
55
+ case 10: k2 ^= ((uint64_t)tail[ 9]) << 8;
56
+ case 9: k2 ^= ((uint64_t)tail[ 8]) << 0;
57
+ k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2;
58
+
59
+ case 8: k1 ^= ((uint64_t)tail[ 7]) << 56;
60
+ case 7: k1 ^= ((uint64_t)tail[ 6]) << 48;
61
+ case 6: k1 ^= ((uint64_t)tail[ 5]) << 40;
62
+ case 5: k1 ^= ((uint64_t)tail[ 4]) << 32;
63
+ case 4: k1 ^= ((uint64_t)tail[ 3]) << 24;
64
+ case 3: k1 ^= ((uint64_t)tail[ 2]) << 16;
65
+ case 2: k1 ^= ((uint64_t)tail[ 1]) << 8;
66
+ case 1: k1 ^= ((uint64_t)tail[ 0]) << 0;
67
+ k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
68
+ };
69
+
70
+ //----------
71
+ // finalization
72
+
73
+ h1 ^= len; h2 ^= len;
74
+
75
+ h1 += h2;
76
+ h2 += h1;
77
+
78
+ h1 = fmix64(h1);
79
+ h2 = fmix64(h2);
80
+
81
+ h1 += h2;
82
+ h2 += h1;
83
+
84
+ ((uint64_t*)out)[0] = h1;
85
+ ((uint64_t*)out)[1] = h2;
86
+ }
87
+
88
+ VALUE
89
+ murmur3_x64_128_finish(VALUE self)
90
+ {
91
+ uint8_t digest[16];
92
+ uint64_t out[2];
93
+
94
+ _murmur_finish128(self, out, murmur_hash_process3_x64_128);
95
+ assign_by_endian_128(digest, out);
96
+ return rb_str_new((const char*) digest, 16);
97
+ }
98
+
99
+ VALUE
100
+ murmur3_x64_128_s_digest(int argc, VALUE *argv, VALUE klass)
101
+ {
102
+ uint8_t digest[16];
103
+ uint64_t out[2];
104
+
105
+ _murmur_s_digest128(argc, argv, klass, (void*)out, murmur_hash_process3_x64_128);
106
+ assign_by_endian_128(digest, out);
107
+ return rb_str_new((const char*) digest, 16);
108
+ }
109
+
110
+ VALUE
111
+ murmur3_x64_128_s_rawdigest(int argc, VALUE *argv, VALUE klass)
112
+ {
113
+ uint64_t out[2];
114
+
115
+ _murmur_s_digest128(argc, argv, klass, (void*)out, murmur_hash_process3_x64_128);
116
+ return rb_assoc_new(ULL2NUM(out[0]), ULL2NUM(out[1]));
117
+ }
@@ -243,9 +243,13 @@ Init_murmurhash(void)
243
243
  iv_seed = rb_intern("@seed");
244
244
  iv_buffer = rb_intern("@buffer");
245
245
 
246
-
247
246
  cDigest_MurmurHash3_x86_32 = rb_path2class("Digest::MurmurHashMRI3_x86_32");
248
247
  rb_define_singleton_method(cDigest_MurmurHash3_x86_32, "digest", murmur3_x86_32_s_digest, -1);
249
248
  rb_define_singleton_method(cDigest_MurmurHash3_x86_32, "rawdigest", murmur3_x86_32_s_rawdigest, -1);
250
249
  rb_define_private_method(cDigest_MurmurHash3_x86_32, "finish", murmur3_x86_32_finish, 0);
250
+
251
+ cDigest_MurmurHash3_x64_128 = rb_path2class("Digest::MurmurHashMRI3_x64_128");
252
+ rb_define_singleton_method(cDigest_MurmurHash3_x64_128, "digest", murmur3_x64_128_s_digest, -1);
253
+ rb_define_singleton_method(cDigest_MurmurHash3_x64_128, "rawdigest", murmur3_x64_128_s_rawdigest, -1);
254
+ rb_define_private_method(cDigest_MurmurHash3_x64_128, "finish", murmur3_x64_128_finish, 0);
251
255
  }
Binary file
@@ -7,9 +7,9 @@ module SplitIoClient
7
7
  extend Forwardable
8
8
  def_delegators :@adapter, :initialize_set, :set_bool, :pipelined
9
9
 
10
- def initialize(adapter)
11
- @cache = LruRedux::TTL::ThreadSafeCache.new(SplitIoClient.configuration.max_cache_size, SplitIoClient.configuration.cache_ttl)
12
- @adapter = adapter
10
+ def initialize(config)
11
+ @cache = LruRedux::TTL::ThreadSafeCache.new(config.max_cache_size, config.cache_ttl)
12
+ @adapter = config.cache_adapter
13
13
  end
14
14
 
15
15
  def delete(key)
@@ -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)
@@ -39,6 +39,13 @@ module SplitIoClient
39
39
  items
40
40
  end
41
41
 
42
+ def length
43
+ @current_size.value
44
+ end
45
+
46
+ def empty?
47
+ @queue.empty?
48
+ end
42
49
  end
43
50
  end
44
51
  end
@@ -17,6 +17,10 @@ module SplitIoClient
17
17
  @redis = Redis.new(connection)
18
18
  end
19
19
 
20
+ def hincrby(key, field, increment)
21
+ @redis.hincrby(key, field, increment)
22
+ end
23
+
20
24
  # Map
21
25
  def initialize_map(key)
22
26
  # No need to initialize hash/map in Redis
@@ -56,10 +60,14 @@ module SplitIoClient
56
60
  end
57
61
 
58
62
  def find_strings_by_prefix(prefix)
63
+ find_strings_by_pattern("#{prefix}*")
64
+ end
65
+
66
+ def find_strings_by_pattern(pattern)
59
67
  memo = { items: [], cursor: 0 }
60
68
 
61
69
  loop do
62
- memo[:cursor], items = @redis.scan(memo[:cursor], match: "#{prefix}*", count: SCAN_SLICE)
70
+ memo[:cursor], items = @redis.scan(memo[:cursor], match: "#{pattern}", count: SCAN_SLICE)
63
71
 
64
72
  memo[:items].push(*items)
65
73
 
@@ -91,7 +99,7 @@ module SplitIoClient
91
99
  alias find_sets_by_prefix find_strings_by_prefix
92
100
 
93
101
  def add_to_set(key, val)
94
- @redis.sadd(key, val)
102
+ @redis.sadd?(key, val)
95
103
  end
96
104
 
97
105
  def delete_from_set(key, val)
@@ -138,7 +146,7 @@ module SplitIoClient
138
146
 
139
147
  # General
140
148
  def exists?(key)
141
- @redis.exists(key)
149
+ @redis.exists?(key)
142
150
  end
143
151
 
144
152
  def delete(key)
@@ -152,7 +160,7 @@ module SplitIoClient
152
160
  end
153
161
 
154
162
  def pipelined
155
- @redis.pipelined do
163
+ @redis.pipelined do |pipeline|
156
164
  yield
157
165
  end
158
166
  end
@@ -0,0 +1,83 @@
1
+ module SplitIoClient
2
+ module Cache
3
+ module Fetchers
4
+ class SegmentFetcher
5
+ attr_reader :segments_repository
6
+
7
+ def initialize(segments_repository, api_key, config, telemetry_runtime_producer)
8
+ @segments_repository = segments_repository
9
+ @api_key = api_key
10
+ @config = config
11
+ @semaphore = Mutex.new
12
+ @telemetry_runtime_producer = telemetry_runtime_producer
13
+ end
14
+
15
+ def call
16
+ if ENV['SPLITCLIENT_ENV'] == 'test'
17
+ fetch_segments
18
+ return
19
+ end
20
+
21
+ segments_thread
22
+ end
23
+
24
+ def fetch_segments_if_not_exists(names, cache_control_headers = false)
25
+ names.each do |name|
26
+ change_number = @segments_repository.get_change_number(name)
27
+
28
+ if change_number == -1
29
+ fetch_options = { cache_control_headers: cache_control_headers, till: nil }
30
+ fetch_segment(name, fetch_options) if change_number == -1
31
+ end
32
+ end
33
+ rescue StandardError => e
34
+ @config.log_found_exception(__method__.to_s, e)
35
+ end
36
+
37
+ def fetch_segment(name, fetch_options = { cache_control_headers: false, till: nil })
38
+ @semaphore.synchronize do
39
+ segments_api.fetch_segments_by_names([name], fetch_options)
40
+ end
41
+ rescue StandardError => e
42
+ @config.log_found_exception(__method__.to_s, e)
43
+ end
44
+
45
+ def fetch_segments
46
+ @semaphore.synchronize do
47
+ segments_api.fetch_segments_by_names(@segments_repository.used_segment_names)
48
+
49
+ true
50
+ end
51
+ rescue StandardError => e
52
+ @config.log_found_exception(__method__.to_s, e)
53
+ false
54
+ end
55
+
56
+ def stop_segments_thread
57
+ SplitIoClient::Helpers::ThreadHelper.stop(:segment_fetcher, @config)
58
+ end
59
+
60
+ private
61
+
62
+ def segments_thread
63
+ @config.threads[:segment_fetcher] = Thread.new do
64
+ @config.logger.info('Starting segments fetcher service') if @config.debug_enabled
65
+
66
+ loop do
67
+ fetch_segments
68
+ @config.logger.debug("Segment names: #{@segments_repository.used_segment_names.to_a}") if @config.debug_enabled
69
+
70
+ sleep_for = SplitIoClient::Cache::Stores::StoreUtils.random_interval(@config.segments_refresh_rate)
71
+ @config.logger.debug("Segments fetcher is sleeping for: #{sleep_for} seconds") if @config.debug_enabled
72
+ sleep(sleep_for)
73
+ end
74
+ end
75
+ end
76
+
77
+ def segments_api
78
+ @segments_api ||= SplitIoClient::Api::Segments.new(@api_key, @segments_repository, @config, @telemetry_runtime_producer)
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end