ff-ruby-server-sdk 0.0.2 → 1.0.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.
- checksums.yaml +4 -4
- data/.run/build.sh.run.xml +17 -0
- data/.run/install.sh.run.xml +17 -0
- data/.run/openapi.sh.run.xml +17 -0
- data/.run/publish.sh.run.xml +17 -0
- data/.run/sdk_test.rb.run.xml +3 -3
- data/.run/unpublish.sh.run.xml +17 -0
- data/CHANGELOG.md +1 -1
- data/Gemfile +20 -3
- data/README.md +155 -7
- data/api.yaml +736 -0
- data/example/example.rb +99 -3
- data/lib/ff/ruby/server/sdk/api/auth_service.rb +91 -0
- data/lib/ff/ruby/server/sdk/api/cf_client.rb +93 -0
- data/lib/ff/ruby/server/sdk/api/client_callback.rb +45 -0
- data/lib/ff/ruby/server/sdk/api/config.rb +140 -0
- data/lib/ff/ruby/server/sdk/api/config_builder.rb +116 -0
- data/lib/ff/ruby/server/sdk/api/default_cache.rb +112 -0
- data/lib/ff/ruby/server/sdk/api/evaluation.rb +29 -0
- data/lib/ff/ruby/server/sdk/api/evaluator.rb +526 -0
- data/lib/ff/ruby/server/sdk/api/file_map_store.rb +60 -0
- data/lib/ff/ruby/server/sdk/api/flag_evaluate_callback.rb +13 -0
- data/lib/ff/ruby/server/sdk/api/inner_client.rb +311 -0
- data/lib/ff/ruby/server/sdk/api/inner_client_flag_evaluate_callback.rb +30 -0
- data/lib/ff/ruby/server/sdk/api/inner_client_metrics_callback.rb +33 -0
- data/lib/ff/ruby/server/sdk/api/inner_client_repository_callback.rb +44 -0
- data/lib/ff/ruby/server/sdk/api/inner_client_updater.rb +63 -0
- data/lib/ff/ruby/server/sdk/api/metrics_callback.rb +19 -0
- data/lib/ff/ruby/server/sdk/api/metrics_event.rb +16 -0
- data/lib/ff/ruby/server/sdk/api/metrics_processor.rb +297 -0
- data/lib/ff/ruby/server/sdk/api/operators.rb +20 -0
- data/lib/ff/ruby/server/sdk/api/polling_processor.rb +164 -0
- data/lib/ff/ruby/server/sdk/api/repository_callback.rb +28 -0
- data/lib/ff/ruby/server/sdk/api/storage_repository.rb +263 -0
- data/lib/ff/ruby/server/sdk/api/summary_metrics.rb +16 -0
- data/lib/ff/ruby/server/sdk/api/update_processor.rb +149 -0
- data/lib/ff/ruby/server/sdk/common/cache.rb +27 -0
- data/lib/ff/ruby/server/sdk/common/closeable.rb +7 -0
- data/lib/ff/ruby/server/sdk/common/destroyable.rb +12 -0
- data/lib/ff/ruby/server/sdk/common/repository.rb +45 -0
- data/lib/ff/ruby/server/sdk/common/storage.rb +29 -0
- data/lib/ff/ruby/server/sdk/connector/connector.rb +44 -0
- data/lib/ff/ruby/server/sdk/connector/events.rb +118 -0
- data/lib/ff/ruby/server/sdk/connector/harness_connector.rb +236 -0
- data/lib/ff/ruby/server/sdk/connector/service.rb +19 -0
- data/lib/ff/ruby/server/sdk/connector/updater.rb +32 -0
- data/lib/ff/ruby/server/sdk/dto/message.rb +13 -0
- data/lib/ff/ruby/server/sdk/dto/target.rb +24 -0
- data/lib/ff/ruby/server/sdk/version.rb +2 -1
- data/lib/ff/ruby/server/sdk.rb +39 -3
- data/openapitools.json +7 -0
- data/scripts/openapi.sh +35 -0
- data/scripts/sdk_specs.sh +1 -1
- metadata +46 -3
- data/lib/ff/ruby/server/sdk/cf_client.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aafd2726a023b297ce97c582bc0270092f8795064c7bd16dd6096d2a5690681d
|
4
|
+
data.tar.gz: 00a0f190db82bdfb225eb7fd8546865ef6d399c2bcc835da436e1b807c90f1ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e839a0f6b68c3e576730a62d836b74b622e50cabb07927fb6cebb1aaee5d9849788c603bf16a96e361d9e8fb25b8b34a71a28c13bf168a68f11b1fc5313484f4
|
7
|
+
data.tar.gz: f65a9e15ccc5f80ac924a4801c58f671cd63f1be24e95875e665af3b787af07cd35cb05e173bd66807ffac7331a83e00ffa30d5b83903deca3b4322608c19f16
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
2
|
+
<configuration default="false" name="build.sh" type="ShConfigurationType">
|
3
|
+
<option name="SCRIPT_TEXT" value="" />
|
4
|
+
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
|
5
|
+
<option name="SCRIPT_PATH" value="$PROJECT_DIR$/scripts/build.sh" />
|
6
|
+
<option name="SCRIPT_OPTIONS" value="" />
|
7
|
+
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
|
8
|
+
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/scripts" />
|
9
|
+
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
|
10
|
+
<option name="INTERPRETER_PATH" value="/bin/zsh" />
|
11
|
+
<option name="INTERPRETER_OPTIONS" value="" />
|
12
|
+
<option name="EXECUTE_IN_TERMINAL" value="true" />
|
13
|
+
<option name="EXECUTE_SCRIPT_FILE" value="true" />
|
14
|
+
<envs />
|
15
|
+
<method v="2" />
|
16
|
+
</configuration>
|
17
|
+
</component>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
2
|
+
<configuration default="false" name="install.sh" type="ShConfigurationType">
|
3
|
+
<option name="SCRIPT_TEXT" value="" />
|
4
|
+
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
|
5
|
+
<option name="SCRIPT_PATH" value="$PROJECT_DIR$/scripts/install.sh" />
|
6
|
+
<option name="SCRIPT_OPTIONS" value="" />
|
7
|
+
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
|
8
|
+
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/scripts" />
|
9
|
+
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
|
10
|
+
<option name="INTERPRETER_PATH" value="/bin/zsh" />
|
11
|
+
<option name="INTERPRETER_OPTIONS" value="" />
|
12
|
+
<option name="EXECUTE_IN_TERMINAL" value="true" />
|
13
|
+
<option name="EXECUTE_SCRIPT_FILE" value="true" />
|
14
|
+
<envs />
|
15
|
+
<method v="2" />
|
16
|
+
</configuration>
|
17
|
+
</component>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
2
|
+
<configuration default="false" name="openapi.sh" type="ShConfigurationType">
|
3
|
+
<option name="SCRIPT_TEXT" value="" />
|
4
|
+
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
|
5
|
+
<option name="SCRIPT_PATH" value="$PROJECT_DIR$/scripts/openapi.sh" />
|
6
|
+
<option name="SCRIPT_OPTIONS" value="" />
|
7
|
+
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
|
8
|
+
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/scripts" />
|
9
|
+
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
|
10
|
+
<option name="INTERPRETER_PATH" value="/bin/zsh" />
|
11
|
+
<option name="INTERPRETER_OPTIONS" value="" />
|
12
|
+
<option name="EXECUTE_IN_TERMINAL" value="true" />
|
13
|
+
<option name="EXECUTE_SCRIPT_FILE" value="true" />
|
14
|
+
<envs />
|
15
|
+
<method v="2" />
|
16
|
+
</configuration>
|
17
|
+
</component>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
2
|
+
<configuration default="false" name="publish.sh" type="ShConfigurationType">
|
3
|
+
<option name="SCRIPT_TEXT" value="" />
|
4
|
+
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
|
5
|
+
<option name="SCRIPT_PATH" value="$PROJECT_DIR$/scripts/publish.sh" />
|
6
|
+
<option name="SCRIPT_OPTIONS" value="" />
|
7
|
+
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
|
8
|
+
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/scripts" />
|
9
|
+
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
|
10
|
+
<option name="INTERPRETER_PATH" value="/bin/zsh" />
|
11
|
+
<option name="INTERPRETER_OPTIONS" value="" />
|
12
|
+
<option name="EXECUTE_IN_TERMINAL" value="true" />
|
13
|
+
<option name="EXECUTE_SCRIPT_FILE" value="true" />
|
14
|
+
<envs />
|
15
|
+
<method v="2" />
|
16
|
+
</configuration>
|
17
|
+
</component>
|
data/.run/sdk_test.rb.run.xml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
<component name="ProjectRunConfigurationManager">
|
2
|
-
<configuration default="false" name="
|
2
|
+
<configuration default="false" name="SDK test" type="TestUnitRunConfigurationType" factoryName="Test::Unit/Shoulda/Minitest">
|
3
3
|
<module name="ff-ruby-server-sdk" />
|
4
4
|
<predefined_log_file enabled="true" id="RUBY_TESTUNIT" />
|
5
5
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-Ilib:test" />
|
@@ -19,8 +19,8 @@
|
|
19
19
|
</EXTENSION>
|
20
20
|
<EXTENSION ID="org.jetbrains.plugins.ruby.rails.run.RailsRunConfigurationExtension" SCRATCH_USE_RAILS_RUNNER="false" />
|
21
21
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
|
22
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/test/ff/ruby/server/sdk_test.rb" />
|
23
|
-
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPTS_PATHS" VALUE="$MODULE_DIR$/test/ff/ruby/server/sdk_test.rb" />
|
22
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/test/ff/ruby/server/sdk/sdk_test.rb" />
|
23
|
+
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPTS_PATHS" VALUE="$MODULE_DIR$/test/ff/ruby/server/sdk/sdk_test.rb" />
|
24
24
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="" />
|
25
25
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_METHOD_NAME" VALUE="" />
|
26
26
|
<RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="CUSTOM_SET_OF_FILES" />
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
2
|
+
<configuration default="false" name="unpublish.sh" type="ShConfigurationType">
|
3
|
+
<option name="SCRIPT_TEXT" value="" />
|
4
|
+
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
|
5
|
+
<option name="SCRIPT_PATH" value="$PROJECT_DIR$/scripts/unpublish.sh" />
|
6
|
+
<option name="SCRIPT_OPTIONS" value="" />
|
7
|
+
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
|
8
|
+
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$/scripts" />
|
9
|
+
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
|
10
|
+
<option name="INTERPRETER_PATH" value="/bin/zsh" />
|
11
|
+
<option name="INTERPRETER_OPTIONS" value="" />
|
12
|
+
<option name="EXECUTE_IN_TERMINAL" value="true" />
|
13
|
+
<option name="EXECUTE_SCRIPT_FILE" value="true" />
|
14
|
+
<envs />
|
15
|
+
<method v="2" />
|
16
|
+
</configuration>
|
17
|
+
</component>
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -2,11 +2,28 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
# Specify your gem's dependencies in ff-ruby-server-sdk.gemspec
|
6
5
|
gemspec
|
7
6
|
|
8
7
|
gem "rake", "~> 13.0"
|
9
|
-
|
10
8
|
gem "minitest", "~> 5.0"
|
11
|
-
|
12
9
|
gem "standard", "~> 1.3"
|
10
|
+
|
11
|
+
# OpenAPI:
|
12
|
+
gem "openapi_client", "~> 1.0.0"
|
13
|
+
|
14
|
+
# Caching support:
|
15
|
+
gem "pp"
|
16
|
+
gem "rufus-scheduler"
|
17
|
+
gem "libcache"
|
18
|
+
gem "jwt"
|
19
|
+
gem "moneta"
|
20
|
+
|
21
|
+
# SSE support:
|
22
|
+
gem "rest-client"
|
23
|
+
gem "sse-client"
|
24
|
+
|
25
|
+
# Concurrency support:
|
26
|
+
gem "concurrent-ruby", require: "concurrent"
|
27
|
+
|
28
|
+
# Evaluator dependencies:
|
29
|
+
gem "murmurhash3"
|
data/README.md
CHANGED
@@ -1,14 +1,162 @@
|
|
1
|
-
|
1
|
+
Harness CF Ruby Server SDK
|
2
|
+
========================
|
2
3
|
|
3
|
-
|
4
|
+
## Overview
|
4
5
|
|
5
|
-
|
6
|
+
-------------------------
|
7
|
+
[Harness](https://www.harness.io/) is a feature management platform that helps teams to build better software and to
|
8
|
+
test features quicker.
|
6
9
|
|
7
|
-
|
10
|
+
-------------------------
|
8
11
|
|
9
|
-
|
12
|
+
## Setup
|
13
|
+
|
14
|
+
Add the following snippet to your project's `Gemfile` file:
|
15
|
+
|
16
|
+
```
|
17
|
+
gem "ff-ruby-server-sdk"
|
18
|
+
```
|
19
|
+
|
20
|
+
## Cloning the SDK repository
|
21
|
+
|
22
|
+
In order to clone SDK repository properly perform cloning like in the following example:
|
23
|
+
|
24
|
+
```
|
25
|
+
git clone --recurse-submodules git@github.com:harness/ff-ruby-server-sdk.git
|
26
|
+
```
|
27
|
+
|
28
|
+
After dependency has been added, the SDK elements, primarily `CfClient` should be accessible in the main application.
|
29
|
+
|
30
|
+
## Initialization
|
31
|
+
|
32
|
+
`CfClient` is a base class that provides all features of the SDK.
|
33
|
+
|
34
|
+
We can instantiate by calling the `instance` method or by using public
|
35
|
+
constructor (making multiple instances).
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
require 'ff/ruby/server/sdk/api/config'
|
39
|
+
require 'ff/ruby/server/sdk/dto/target'
|
40
|
+
require 'ff/ruby/server/sdk/api/cf_client'
|
41
|
+
require 'ff/ruby/server/sdk/api/config_builder'
|
42
|
+
|
43
|
+
client = CfClient.instance
|
44
|
+
|
45
|
+
key = "YOUR_API_KEY_GOES_HERE"
|
46
|
+
|
47
|
+
logger = Logger.new(STDOUT)
|
48
|
+
|
49
|
+
# Or saving logs into the filesystem with daily rotation:
|
50
|
+
# logger = Logger.new("example.log", "daily")
|
51
|
+
|
52
|
+
config = ConfigBuilder.new
|
53
|
+
.logger(logger)
|
54
|
+
.build
|
55
|
+
|
56
|
+
client.init(key, config)
|
57
|
+
|
58
|
+
config.logger.debug 'We will wait for the initialization'
|
59
|
+
|
60
|
+
client.wait_for_initialization
|
61
|
+
|
62
|
+
config.logger.debug 'Initialization is complete'
|
63
|
+
|
64
|
+
target = Target.new("YOUR_TARGET_NAME")
|
65
|
+
```
|
66
|
+
|
67
|
+
`target` represents the desired target for which we want features to be evaluated.
|
68
|
+
|
69
|
+
`"YOUR_API_KEY"` is an authentication key, needed for access to Harness services.
|
70
|
+
|
71
|
+
**Your Harness SDK is now initialized. Congratulations!**
|
72
|
+
|
73
|
+
### Public API Methods ###
|
74
|
+
|
75
|
+
The Public API exposes a few methods that you can utilize:
|
76
|
+
|
77
|
+
Instantiate, initialize and close when done:
|
78
|
+
|
79
|
+
* `def initialize(api_key = nil, config = nil, connector = nil)`
|
80
|
+
* `def init(api_key = nil, config = nil, connector = nil)`
|
81
|
+
* `def wait_for_initialization`
|
82
|
+
* `def close`
|
83
|
+
|
84
|
+
Evaluations:
|
85
|
+
|
86
|
+
* `def bool_variation(identifier, target, default_value)`
|
87
|
+
* `def string_variation(identifier, target, default_value)`
|
88
|
+
* `def number_variation(identifier, target, default_value)`
|
89
|
+
* `def json_variation(identifier, target, default_value)`
|
90
|
+
|
91
|
+
## Fetch evaluation's value
|
92
|
+
|
93
|
+
It is possible to fetch a value for a given evaluation. Evaluation is performed based on a different type. In case there
|
94
|
+
is no evaluation with provided id, the default value is returned.
|
95
|
+
|
96
|
+
Use the appropriate method to fetch the desired Evaluation of a certain type.
|
97
|
+
|
98
|
+
### Bool variation
|
99
|
+
|
100
|
+
```
|
101
|
+
bool_result = client.bool_variation(bool_flag, target, false)
|
102
|
+
```
|
103
|
+
|
104
|
+
### Number variation
|
105
|
+
|
106
|
+
```
|
107
|
+
number_result = client.number_variation(number_flag, target, -1)
|
108
|
+
```
|
109
|
+
|
110
|
+
### String variation
|
111
|
+
|
112
|
+
```
|
113
|
+
string_result = client.string_variation(string_flag, target, "unavailable !!!")
|
114
|
+
```
|
115
|
+
|
116
|
+
### JSON variation
|
117
|
+
|
118
|
+
```
|
119
|
+
json_result = client.json_variation(json_flag, target, JSON.parse("{}"))
|
120
|
+
```
|
121
|
+
|
122
|
+
## Using feature flags metrics
|
123
|
+
|
124
|
+
Metrics API endpoint can be changed like this (if ever needed):
|
125
|
+
|
126
|
+
```
|
127
|
+
config = ConfigBuilder.new
|
128
|
+
.event_url("SOME_ENDPOINT_URL")
|
129
|
+
.build
|
130
|
+
```
|
131
|
+
|
132
|
+
Otherwise, the default metrics endpoint URL will be used.
|
133
|
+
|
134
|
+
## Connector
|
135
|
+
|
136
|
+
This is a new feature that allows you to create or use other connectors.
|
137
|
+
Connector is just a proxy to your data. Currently supported connectors:
|
138
|
+
|
139
|
+
* Harness (the default implementation)
|
140
|
+
|
141
|
+
```
|
142
|
+
connector = YourConnectorImplementation.new
|
143
|
+
|
144
|
+
client.init(
|
145
|
+
|
146
|
+
key,
|
147
|
+
config,
|
148
|
+
connector
|
149
|
+
)
|
150
|
+
```
|
151
|
+
|
152
|
+
## Shutting down the SDK
|
153
|
+
|
154
|
+
To avoid potential memory leak, when SDK is no longer needed
|
155
|
+
(when the app is closed, for example), a caller should call the `close` method:
|
156
|
+
|
157
|
+
```
|
158
|
+
client.close
|
159
|
+
```
|
10
160
|
|
11
161
|
|
12
|
-
# Harness FFM Server-side SDK for Ruby
|
13
162
|
|
14
|
-
Tbd.
|