unleash 6.0.3.pre → 6.0.4.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +93 -117
- data/lib/unleash/version.rb +1 -1
- data/unleash-client.gemspec +1 -1
- data/v6_MIGRATION_GUIDE.md +21 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8c7833c6fe488f327921b8289efd0c5d4e75fd3a33294b59d57fd0958c72ec8
|
4
|
+
data.tar.gz: 7331eac17d8e1b213abacf08fc0d93f6cf77b56eac8ff3903a8aec307584eaa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 772a21fb32488d74b84c3d78d47ba67dc35fe581e11bc3d4a754343ead7ec3f8eb1140fc00e9b9528ec88112c1ada6b0a68df3d7b8315d1043546455edabb7f2
|
7
|
+
data.tar.gz: 8e6de7dfa3b910fb7562a93f8ce520c43d07b5ff8674e212bbe4cd40e1029800fbe67e9a056618ac6ab56458e0dcc41676310e5804edc959030b13600362fcd8
|
data/README.md
CHANGED
@@ -6,33 +6,12 @@
|
|
6
6
|
|
7
7
|
Ruby client for the [Unleash](https://github.com/Unleash/unleash) feature management service.
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- [Usage in a Rails Application](#usage-in-a-rails-application)
|
16
|
-
- [1. Add Initializer](#1-add-initializer)
|
17
|
-
- [1.a Initializer for standard Rails applications](#1a-initializer-for-standard-rails-applications)
|
18
|
-
- [1.b Add Initializer if using Puma in clustered mode](#1b-add-initializer-if-using-puma-in-clustered-mode)
|
19
|
-
- [with `preload_app!`](#with-preload_app)
|
20
|
-
- [without `preload_app!`](#without-preload_app)
|
21
|
-
- [1.c Add Initializer if using Phusion Passenger](#1c-add-initializer-if-using-phusion-passenger)
|
22
|
-
- [1.d Add Initializer hooks when using within Sidekiq](#1d-add-initializer-hooks-when-using-within-sidekiq)
|
23
|
-
- [2. Set Unleash::Context](#2-set-unleashcontext)
|
24
|
-
- [3. Sample usage](#3-sample-usage)
|
25
|
-
- [Variations](#variations)
|
26
|
-
- [Bootstrapping](#bootstrapping)
|
27
|
-
- [Client methods](#client-methods)
|
28
|
-
- [Local test client](#local-test-client)
|
29
|
-
- [Available Strategies](#available-strategies)
|
30
|
-
- [Custom Strategies](#custom-strategies)
|
31
|
-
- [Development](#development)
|
32
|
-
- [Releasing](#releasing)
|
33
|
-
- [Contributing](#contributing)
|
34
|
-
|
35
|
-
## Supported Ruby Interpreters
|
9
|
+
> **Migrating to v6**
|
10
|
+
>
|
11
|
+
> If you use [custom strategies](#custom-strategies) or override built-in ones, read the complete [migration guide](./v6_MIGRATION_GUIDE.md) before upgrading to v6.
|
12
|
+
|
13
|
+
|
14
|
+
## Supported Ruby interpreters
|
36
15
|
|
37
16
|
- MRI 3.3
|
38
17
|
- MRI 3.2
|
@@ -59,72 +38,70 @@ Or install it yourself as:
|
|
59
38
|
|
60
39
|
$ gem install unleash
|
61
40
|
|
62
|
-
##
|
41
|
+
## Configuration
|
63
42
|
|
64
43
|
It is **required** to configure:
|
65
44
|
|
66
|
-
- `
|
67
|
-
- `
|
68
|
-
- `custom_http_headers` with `{'Authorization': '<
|
69
|
-
|
70
|
-
Please substitute the example `'https://unleash.herokuapp.com/api'` for the url of your own instance.
|
45
|
+
- `app_name` with the name of the running application
|
46
|
+
- `url` of your Unleash server
|
47
|
+
- `custom_http_headers` with `{'Authorization': '<YOUR_API_TOKEN>'}` when using Unleash v4+
|
71
48
|
|
72
49
|
It is **highly recommended** to configure:
|
73
50
|
|
74
|
-
- `instance_id` parameter with a unique identifier for the running instance
|
51
|
+
- `instance_id` parameter with a unique identifier for the running instance
|
75
52
|
|
76
53
|
```ruby
|
77
54
|
Unleash.configure do |config|
|
78
55
|
config.app_name = 'my_ruby_app'
|
79
|
-
config.url = '
|
80
|
-
config.custom_http_headers = {'Authorization': '<
|
56
|
+
config.url = '<YOUR_UNLEASH_URL>/api'
|
57
|
+
config.custom_http_headers = {'Authorization': '<YOUR_API_TOKEN>'}
|
81
58
|
end
|
82
59
|
```
|
83
60
|
|
84
61
|
or instantiate the client with the valid configuration:
|
85
62
|
|
86
63
|
```ruby
|
87
|
-
UNLEASH = Unleash::Client.new(url: '
|
64
|
+
UNLEASH = Unleash::Client.new(url: '<YOUR_UNLEASH_URL>/api', app_name: 'my_ruby_app', custom_http_headers: {'Authorization': '<YOUR_API_TOKEN>'})
|
88
65
|
```
|
89
66
|
|
90
67
|
## Dynamic custom HTTP headers
|
91
68
|
|
92
|
-
If you need custom HTTP headers that change during the lifetime of the client,
|
69
|
+
If you need custom HTTP headers that change during the lifetime of the client, you can pass `custom_http_headers` as a `Proc`.
|
93
70
|
|
94
71
|
```ruby
|
95
72
|
Unleash.configure do |config|
|
96
73
|
config.app_name = 'my_ruby_app'
|
97
|
-
config.url = '
|
74
|
+
config.url = '<YOUR_UNLEASH_URL>/api'
|
98
75
|
config.custom_http_headers = proc do
|
99
76
|
{
|
100
|
-
'Authorization': '<
|
77
|
+
'Authorization': '<YOUR_API_TOKEN>',
|
101
78
|
'X-Client-Request-Time': Time.now.iso8601
|
102
79
|
}
|
103
80
|
end
|
104
81
|
end
|
105
82
|
```
|
106
83
|
|
107
|
-
#### List of
|
84
|
+
#### List of arguments
|
108
85
|
|
109
|
-
| Argument | Description | Required? | Type | Default
|
86
|
+
| Argument | Description | Required? | Type | Default value |
|
110
87
|
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | --------------------------------- | ---------------------------------------------- |
|
111
88
|
| `url` | Unleash server URL. | Y | String | N/A |
|
112
89
|
| `app_name` | Name of your program. | Y | String | N/A |
|
113
|
-
| `instance_id` | Identifier for the running instance of program
|
114
|
-
| `environment` | Unleash context option
|
115
|
-
| `project_name` | Name of the project to retrieve
|
116
|
-
| `refresh_interval` | How often the
|
117
|
-
| `metrics_interval` | How often the
|
118
|
-
| `disable_client` | Disables all communication with the Unleash server, effectively taking it _offline_. If set, `is_enabled?`
|
90
|
+
| `instance_id` | Identifier for the running instance of your program—set this to be able trace where metrics are being collected from. | N | String | random UUID |
|
91
|
+
| `environment` | Unleash context option, for example, `prod` or `dev`. Not yet in use. **Not** the same as the SDK's [Unleash environment](https://docs.getunleash.io/reference/environments). | N | String | `default` |
|
92
|
+
| `project_name` | Name of the project to retrieve feature flags from. If not set, all feature flags will be retrieved. | N | String | nil |
|
93
|
+
| `refresh_interval` | How often the Unleash client should check with the server for configuration changes. | N | Integer | 15 |
|
94
|
+
| `metrics_interval` | How often the Unleash client should send metrics to server. | N | Integer | 60 |
|
95
|
+
| `disable_client` | Disables all communication with the Unleash server, effectively taking it _offline_. If set, `is_enabled?` always answer with the `default_value` and configuration validation is skipped. Will also forcefully set `disable_metrics` to `true`. Defeats the entire purpose of using Unleash, except when running tests. | N | Boolean | `false` |
|
119
96
|
| `disable_metrics` | Disables sending metrics to Unleash server. If the `disable_client` option is set to `true`, then this option will also be set to `true`, regardless of the value provided. | N | Boolean | `false` |
|
120
|
-
| `custom_http_headers` | Custom headers to send to Unleash. As of Unleash v4.0.0, the `Authorization` header is required. For example: `{'Authorization': '<
|
97
|
+
| `custom_http_headers` | Custom headers to send to Unleash. As of Unleash v4.0.0, the `Authorization` header is required. For example: `{'Authorization': '<YOUR_API_TOKEN>'}`. | N | Hash/Proc | {} |
|
121
98
|
| `timeout` | How long to wait for the connection to be established or wait in reading state (open_timeout/read_timeout) | N | Integer | 30 |
|
122
99
|
| `retry_limit` | How many consecutive failures in connecting to the Unleash server are allowed before giving up. The default is to retry indefinitely. | N | Float::INFINITY | 5 |
|
123
|
-
| `backup_file` | Filename to store the last known state from the Unleash server.
|
100
|
+
| `backup_file` | Filename to store the last known state from the Unleash server. It is best to not change this from the default. | N | String | `Dir.tmpdir + "/unleash-#{app_name}-repo.json` |
|
124
101
|
| `logger` | Specify a custom `Logger` class to handle logs for the Unleash client. | N | Class | `Logger.new(STDOUT)` |
|
125
102
|
| `log_level` | Change the log level for the `Logger` class. Constant from `Logger::Severity`. | N | Constant | `Logger::WARN` |
|
126
|
-
| `bootstrap_config` | Bootstrap config
|
127
|
-
| `strategies` | Strategies manager that holds all strategies and allows to add custom strategies | N | Unleash::Strategies | `Unleash::Strategies.new` |
|
103
|
+
| `bootstrap_config` | Bootstrap config for loading data on startup—useful for loading large states on startup without (or before) hitting the network. | N | Unleash::Bootstrap::Configuration | `nil` |
|
104
|
+
| `strategies` | Strategies manager that holds all strategies and allows to add custom strategies. | N | Unleash::Strategies | `Unleash::Strategies.new` |
|
128
105
|
|
129
106
|
For a more in-depth look, please see `lib/unleash/configuration.rb`.
|
130
107
|
|
@@ -133,13 +110,13 @@ For a more in-depth look, please see `lib/unleash/configuration.rb`.
|
|
133
110
|
| `UNLEASH_BOOTSTRAP_FILE` | File to read bootstrap data from |
|
134
111
|
| `UNLEASH_BOOTSTRAP_URL` | URL to read bootstrap data from |
|
135
112
|
|
136
|
-
## Usage in a plain Ruby
|
113
|
+
## Usage in a plain Ruby application
|
137
114
|
|
138
115
|
```ruby
|
139
116
|
require 'unleash'
|
140
117
|
require 'unleash/context'
|
141
118
|
|
142
|
-
@unleash = Unleash::Client.new(app_name: 'my_ruby_app', url: '
|
119
|
+
@unleash = Unleash::Client.new(app_name: 'my_ruby_app', url: '<YOUR_UNLEASH_URL>/api', custom_http_headers: { 'Authorization': '<YOUR_API_TOKEN>' })
|
143
120
|
|
144
121
|
feature_name = "AwesomeFeature"
|
145
122
|
unleash_context = Unleash::Context.new
|
@@ -158,7 +135,7 @@ else
|
|
158
135
|
end
|
159
136
|
```
|
160
137
|
|
161
|
-
## Usage in a Rails
|
138
|
+
## Usage in a Rails application
|
162
139
|
|
163
140
|
### 1. Add Initializer
|
164
141
|
|
@@ -183,10 +160,8 @@ UNLEASH = Unleash::Client.new
|
|
183
160
|
# Rails.configuration.unleash = Unleash::Client.new
|
184
161
|
```
|
185
162
|
|
186
|
-
For `config.instance_id` use a string with a unique identification for the running instance.
|
187
|
-
|
188
|
-
Or the docker container id, if you are running in docker.
|
189
|
-
If it is not set the client will generate an unique UUID for each execution.
|
163
|
+
For `config.instance_id` use a string with a unique identification for the running instance. For example, it could be the hostname if you only run one App per host, or the docker container ID, if you are running in Docker.
|
164
|
+
If not set, the client will generate a unique UUID for each execution.
|
190
165
|
|
191
166
|
To have it available in the `rails console` command as well, also add to the file above:
|
192
167
|
|
@@ -213,12 +188,12 @@ Then you may keep the client configuration still in `config/initializers/unleash
|
|
213
188
|
```ruby
|
214
189
|
Unleash.configure do |config|
|
215
190
|
config.app_name = Rails.application.class.parent.to_s
|
216
|
-
config.url = '
|
217
|
-
config.custom_http_headers = {'Authorization': '<
|
191
|
+
config.url = '<YOUR_UNLEASH_URL>/api'
|
192
|
+
config.custom_http_headers = {'Authorization': '<YOUR_API_TOKEN>'}
|
218
193
|
end
|
219
194
|
```
|
220
195
|
|
221
|
-
But you must ensure that the
|
196
|
+
But you must ensure that the Unleash client is instantiated only after the process is forked.
|
222
197
|
This is done by creating the client inside the `on_worker_boot` code block in `puma.rb` as below:
|
223
198
|
|
224
199
|
```ruby
|
@@ -241,14 +216,14 @@ end
|
|
241
216
|
|
242
217
|
By not using `preload_app!`:
|
243
218
|
|
244
|
-
-
|
245
|
-
-
|
219
|
+
- The `Rails` constant will **not** be available.
|
220
|
+
- Phased restarts will be possible.
|
246
221
|
|
247
222
|
You need to ensure that in `puma.rb`:
|
248
223
|
|
249
|
-
-
|
250
|
-
-
|
251
|
-
-
|
224
|
+
- The Unleash SDK is loaded with `require 'unleash'` explicitly, as it will not be pre-loaded.
|
225
|
+
- All parameters are set explicitly in the `on_worker_boot` block, as `config/initializers/unleash.rb` is not read.
|
226
|
+
- There are no references to `Rails` constant, as that is not yet available.
|
252
227
|
|
253
228
|
Example for `puma.rb`:
|
254
229
|
|
@@ -263,8 +238,8 @@ on_worker_boot do
|
|
263
238
|
|
264
239
|
::UNLEASH = Unleash::Client.new(
|
265
240
|
app_name: 'my_rails_app',
|
266
|
-
url: '
|
267
|
-
custom_http_headers: {'Authorization': '<
|
241
|
+
url: '<YOUR_UNLEASH_URL>/api',
|
242
|
+
custom_http_headers: {'Authorization': '<YOUR_API_TOKEN>'},
|
268
243
|
)
|
269
244
|
end
|
270
245
|
|
@@ -277,7 +252,7 @@ Note that we also added shutdown hooks in `on_worker_shutdown`, to ensure a clea
|
|
277
252
|
|
278
253
|
#### 1.c Add Initializer if using [Phusion Passenger](https://github.com/phusion/passenger)
|
279
254
|
|
280
|
-
The
|
255
|
+
The Unleash client needs to be configured and instantiated inside the `PhusionPassenger.on_event(:starting_worker_process)` code block due to [smart spawning](https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/#smart-spawning-caveats):
|
281
256
|
|
282
257
|
The initializer in `config/initializers/unleash.rb` should look like:
|
283
258
|
|
@@ -288,8 +263,8 @@ PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
|
288
263
|
config.app_name = Rails.application.class.parent.to_s
|
289
264
|
# config.instance_id = "#{Socket.gethostname}"
|
290
265
|
config.logger = Rails.logger
|
291
|
-
config.url = '
|
292
|
-
config.custom_http_headers = {'Authorization': '<
|
266
|
+
config.url = '<YOUR_UNLEASH_URL>/api'
|
267
|
+
config.custom_http_headers = {'Authorization': '<YOUR_API_TOKEN>'}
|
293
268
|
end
|
294
269
|
|
295
270
|
UNLEASH = Unleash::Client.new
|
@@ -299,7 +274,7 @@ end
|
|
299
274
|
|
300
275
|
#### 1.d Add Initializer hooks when using within [Sidekiq](https://github.com/mperham/sidekiq)
|
301
276
|
|
302
|
-
Note that in this case we require that the code block for `Unleash.configure` is set beforehand.
|
277
|
+
Note that in this case, we require that the code block for `Unleash.configure` is set beforehand.
|
303
278
|
For example in `config/initializers/unleash.rb`.
|
304
279
|
|
305
280
|
```ruby
|
@@ -316,7 +291,7 @@ end
|
|
316
291
|
|
317
292
|
### 2. Set Unleash::Context
|
318
293
|
|
319
|
-
|
294
|
+
Add the following method and callback in the application controller to have `@unleash_context` set for all requests:
|
320
295
|
|
321
296
|
Add in `app/controllers/application_controller.rb`:
|
322
297
|
|
@@ -333,7 +308,7 @@ Add in `app/controllers/application_controller.rb`:
|
|
333
308
|
end
|
334
309
|
```
|
335
310
|
|
336
|
-
|
311
|
+
Alternatively, you can add this method only to the controllers that use Unleash.
|
337
312
|
|
338
313
|
### 3. Sample usage
|
339
314
|
|
@@ -406,11 +381,11 @@ end
|
|
406
381
|
|
407
382
|
Note:
|
408
383
|
|
409
|
-
- The block/lambda/proc can use feature name and context as
|
384
|
+
- The block/lambda/proc can use the feature name and context as arguments.
|
410
385
|
- The client will evaluate the fallback function once per call of `is_enabled()`.
|
411
|
-
Please keep this in mind when creating your fallback function
|
386
|
+
Please keep this in mind when creating your fallback function.
|
412
387
|
- The returned value of the block should be a boolean.
|
413
|
-
However, the client will coerce the result to boolean via `!!`.
|
388
|
+
However, the client will coerce the result to a boolean via `!!`.
|
414
389
|
- If both a `default_value` and `fallback_function` are supplied,
|
415
390
|
the client will define the default value by `OR`ing the default value and the output of the fallback function.
|
416
391
|
|
@@ -442,21 +417,21 @@ Bootstrapping can be configured by providing a bootstrap configuration when init
|
|
442
417
|
|
443
418
|
```ruby
|
444
419
|
@unleash = Unleash::Client.new(
|
445
|
-
url: '
|
420
|
+
url: '<YOUR_UNLEASH_URL>/api',
|
446
421
|
app_name: 'my_ruby_app',
|
447
|
-
custom_http_headers: { 'Authorization': '<
|
422
|
+
custom_http_headers: { 'Authorization': '<YOUR_API_TOKEN>' },
|
448
423
|
bootstrap_config: Unleash::Bootstrap::Configuration.new({
|
449
|
-
url: "
|
450
|
-
url_headers: {'Authorization': '<
|
424
|
+
url: "<YOUR_UNLEASH_URL>/api/client/features",
|
425
|
+
url_headers: {'Authorization': '<YOUR_API_TOKEN>'}
|
451
426
|
})
|
452
427
|
)
|
453
428
|
```
|
454
429
|
|
455
430
|
The `Bootstrap::Configuration` initializer takes a hash with one of the following options specified:
|
456
431
|
|
457
|
-
- `file_path` - An absolute or relative path to a file containing a JSON string of the response body from the Unleash server. This can also be set
|
458
|
-
- `url` - A url pointing to an Unleash server's features endpoint, the code sample above is illustrative. This can also be set
|
459
|
-
- `url_headers` - Headers for the GET
|
432
|
+
- `file_path` - An absolute or relative path to a file containing a JSON string of the response body from the Unleash server. This can also be set through the `UNLEASH_BOOTSTRAP_FILE` environment variable.
|
433
|
+
- `url` - A url pointing to an Unleash server's features endpoint, the code sample above is illustrative. This can also be set through the `UNLEASH_BOOTSTRAP_URL` environment variable.
|
434
|
+
- `url_headers` - Headers for the GET HTTP request to the `url` above. Only used if the `url` parameter is also set. If this option isn't set then the bootstrapper will use the same url headers as the Unleash client.
|
460
435
|
- `data` - A raw JSON string as returned by the Unleash server.
|
461
436
|
- `block` - A lambda containing custom logic if you need it, an example is provided below.
|
462
437
|
|
@@ -470,13 +445,13 @@ The order of preference is as follows:
|
|
470
445
|
|
471
446
|
Example usage:
|
472
447
|
|
473
|
-
First
|
448
|
+
First, save the toggles locally:
|
474
449
|
|
475
450
|
```shell
|
476
|
-
curl -H 'Authorization: <
|
451
|
+
curl -H 'Authorization: <YOUR_API_TOKEN>' -XGET '<YOUR_UNLEASH_URL>/api' > ./default-toggles.json
|
477
452
|
```
|
478
453
|
|
479
|
-
|
454
|
+
Then use them on startup:
|
480
455
|
|
481
456
|
```ruby
|
482
457
|
|
@@ -486,8 +461,8 @@ custom_boostrapper = lambda {
|
|
486
461
|
|
487
462
|
@unleash = Unleash::Client.new(
|
488
463
|
app_name: 'my_ruby_app',
|
489
|
-
url: '
|
490
|
-
custom_http_headers: { 'Authorization': '<
|
464
|
+
url: '<YOUR_UNLEASH_URL>/api',
|
465
|
+
custom_http_headers: { 'Authorization': '<YOUR_API_TOKEN>' },
|
491
466
|
bootstrap_config: Unleash::Bootstrap::Configuration.new({
|
492
467
|
block: custom_boostrapper
|
493
468
|
})
|
@@ -499,19 +474,19 @@ Be aware that the client initializer will block until bootstrapping is complete.
|
|
499
474
|
|
500
475
|
#### Client methods
|
501
476
|
|
502
|
-
| Method
|
477
|
+
| Method name | Description | Return type |
|
503
478
|
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
|
504
|
-
| `is_enabled?` |
|
505
|
-
| `enabled?` |
|
506
|
-
| `if_enabled` |
|
507
|
-
| `is_disabled?` |
|
508
|
-
| `disabled?` |
|
509
|
-
| `if_disabled` |
|
510
|
-
| `get_variant` |
|
511
|
-
| `shutdown` |
|
512
|
-
| `shutdown!` |
|
513
|
-
|
514
|
-
For the full method signatures,
|
479
|
+
| `is_enabled?` | Checks if a feature toggle is enabled or not | Boolean |
|
480
|
+
| `enabled?` | A more idiomatic Ruby alias for the `is_enabled?` method | Boolean |
|
481
|
+
| `if_enabled` | Runs a code block, if a feature is enabled | `yield` |
|
482
|
+
| `is_disabled?` | Checks if feature toggle is enabled or not | Boolean |
|
483
|
+
| `disabled?` | A more idiomatic Ruby alias for the `is_disabled?` method | Boolean |
|
484
|
+
| `if_disabled` | Runs a code block, if a feature is disabled | `yield` |
|
485
|
+
| `get_variant` | Gets variant for a given feature | `Unleash::Variant` |
|
486
|
+
| `shutdown` | Saves metrics to disk, flushes metrics to server, and then kills `ToggleFetcher` and `MetricsReporter` threads—a safe shutdown, not generally needed in long-running applications, like web applications | nil |
|
487
|
+
| `shutdown!` | Kills `ToggleFetcher` and `MetricsReporter` threads immediately | nil |
|
488
|
+
|
489
|
+
For the full method signatures, see [client.rb](lib/unleash/client.rb).
|
515
490
|
|
516
491
|
## Local test client
|
517
492
|
|
@@ -523,9 +498,9 @@ bundle exec bin/unleash-client --help
|
|
523
498
|
bundle exec examples/simple.rb
|
524
499
|
```
|
525
500
|
|
526
|
-
## Available
|
501
|
+
## Available strategies
|
527
502
|
|
528
|
-
This client comes with
|
503
|
+
This client comes with all the required strategies out of the box:
|
529
504
|
|
530
505
|
- ApplicationHostnameStrategy
|
531
506
|
- DefaultStrategy
|
@@ -537,10 +512,10 @@ This client comes with the all the required strategies out of the box:
|
|
537
512
|
- UnknownStrategy
|
538
513
|
- UserWithIdStrategy
|
539
514
|
|
540
|
-
## Custom
|
515
|
+
## Custom strategies
|
541
516
|
|
542
|
-
|
543
|
-
In order for strategy to work correctly it should support two methods `name` and `is_enabled
|
517
|
+
You can add [custom activation strategies](https://docs.getunleash.io/advanced/custom_activation_strategy) using configuration.
|
518
|
+
In order for the strategy to work correctly it should support two methods `name` and `is_enabled?`.
|
544
519
|
|
545
520
|
```ruby
|
546
521
|
class MyCustomStrategy
|
@@ -575,16 +550,17 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
575
550
|
|
576
551
|
## Releasing
|
577
552
|
|
578
|
-
|
553
|
+
To release a new version, follow these steps:
|
579
554
|
|
580
|
-
|
581
|
-
-
|
582
|
-
|
583
|
-
-
|
584
|
-
-
|
585
|
-
|
586
|
-
|
587
|
-
|
555
|
+
1. Update version number:
|
556
|
+
- Increment the version number in the `./lib/unleash/version.rb` file according to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) guidelines.
|
557
|
+
2. Update documentation:
|
558
|
+
- If the update includes a major or minor version change, update the [Installation section](#installation) in [README.md](README.md).
|
559
|
+
- Update [CHANGELOG.md](CHANGELOG.md) following the format on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
560
|
+
3. Commit changes:
|
561
|
+
- Commit the changes with a message like: `chore: bump version to x.y.z.`
|
562
|
+
4. Release the gem:
|
563
|
+
- Run `bundle exec rake release` to create a git tag for the new version, push commits and tags to origin, and publish `.gem` file to [rubygems.org](https://rubygems.org).
|
588
564
|
|
589
565
|
## Contributing
|
590
566
|
|
@@ -594,4 +570,4 @@ Be sure to run both `bundle exec rspec` and `bundle exec rubocop` in your branch
|
|
594
570
|
|
595
571
|
Please include tests with any pull requests, to avoid regressions.
|
596
572
|
|
597
|
-
Check out our guide for more information on how to build and scale [feature flag systems](https://docs.getunleash.io/topics/feature-flags/feature-flag-best-practices)
|
573
|
+
Check out our guide for more information on how to build and scale [feature flag systems](https://docs.getunleash.io/topics/feature-flags/feature-flag-best-practices).
|
data/lib/unleash/version.rb
CHANGED
data/unleash-client.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.required_ruby_version = ">= 2.6"
|
25
25
|
|
26
26
|
spec.add_dependency "murmurhash3", "~> 0.1.7"
|
27
|
-
spec.add_dependency "yggdrasil-engine", "~> 0.0.6.beta.
|
27
|
+
spec.add_dependency "yggdrasil-engine", "~> 0.0.6.beta.5"
|
28
28
|
|
29
29
|
spec.add_development_dependency "bundler", "~> 2.1"
|
30
30
|
spec.add_development_dependency "rake", "~> 12.3"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Migrating to Unleash-Client-Ruby 6.0.0
|
2
|
+
|
3
|
+
This guide highlights the key changes you should be aware of when upgrading to v6.0.0 of the Unleash client.
|
4
|
+
|
5
|
+
## Custom strategy changes
|
6
|
+
|
7
|
+
In version 6+, custom strategies cannot override the built-in strategies. Specifically, strategies `applicationHostname`, `default`, `flexibleRollout`, `gradualRolloutRandom`, `gradualRolloutSessionId`, `gradualRolloutUserId`, `remoteAddress` or `userWithId` throw an error on startup. Previously, creating a custom strategy would only generate a warning in the logs.
|
8
|
+
|
9
|
+
The deprecated `register_custom_strategies` method has been removed. You can continue to [register custom strategies](./README.md#custom-strategies) using configuration.
|
10
|
+
|
11
|
+
## Direct access to strategy objects
|
12
|
+
|
13
|
+
**Note:** If you're not using the method `known_strategies` this section doesn't affect you
|
14
|
+
|
15
|
+
The objects for base strategies are no longer directly accessible via the SDK. The `known_strategies` method only returns custom strategies registered by the user. To check if a custom strategy will override either a built-in or custom strategy, use the `includes?` method (returns false if the name is available).
|
16
|
+
|
17
|
+
It is strongly discouraged to access or modify any properties of the built-in strategies other than the name. In version 6+, this is a hard requirement.
|
18
|
+
|
19
|
+
## ARM requirements
|
20
|
+
|
21
|
+
Version 6.0.0 introduces a new dependency on a native binary. Currently, only ARM binaries for macOS are distributed. If you require ARM support for Linux or Windows, please open a GitHub issue.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unleash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.4.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renato Arruda
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0.6.beta.
|
33
|
+
version: 0.0.6.beta.5
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.0.6.beta.
|
40
|
+
version: 0.0.6.beta.5
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- lib/unleash/variant.rb
|
198
198
|
- lib/unleash/version.rb
|
199
199
|
- unleash-client.gemspec
|
200
|
+
- v6_MIGRATION_GUIDE.md
|
200
201
|
homepage: https://github.com/unleash/unleash-client-ruby
|
201
202
|
licenses:
|
202
203
|
- Apache-2.0
|