You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+105Lines changed: 105 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,111 @@ gem install optimizely-sdk
23
23
To access the Feature Management configuration in the Optimizely dashboard, please contact your Optimizely account executive.
24
24
25
25
### Using the SDK
26
+
27
+
You can initialize the Optimizely instance in two ways: directly with a datafile, or by using a factory class, `OptimizelyFactory`, which provides methods to create an Optimizely instance with the default configuration.
28
+
29
+
#### Initialization with datafile
30
+
31
+
Initialize Optimizely with a datafile. This datafile will be used as ProjectConfig throughout the life of the Optimizely instance.
1. Initialize Optimizely by providing an `sdk_key` and an optional `datafile`. This will initialize an HTTPConfigManager that makes an HTTP GET request to the URL (formed using your provided `sdk_key` and the default datafile CDN url template) to asynchronously download the project datafile at regular intervals and update ProjectConfig when a new datafile is recieved.
**Note:** You must provide either the `sdk_key` or URL. If you provide both, the URL takes precedence.
93
+
94
+
**sdk_key**
95
+
The `sdk_key` is used to compose the outbound HTTP request to the default datafile location on the Optimizely CDN.
96
+
97
+
**datafile**
98
+
You can provide an initial datafile to bootstrap the `DataFileProjectConfig` so that it can be used immediately. The initial datafile also serves as a fallback datafile if HTTP connection cannot be established. The initial datafile will be discarded after the first successful datafile poll.
99
+
100
+
**polling_interval**
101
+
The polling_interval is used to specify a fixed delay in seconds between consecutive HTTP requests for the datafile.
102
+
103
+
**url_template**
104
+
A string with placeholder `{sdk_key}` can be provided so that this template along with the provided `sdk_key` is used to form the target URL.
105
+
106
+
**start_by_default**
107
+
Boolean flag used to start the `AsyncScheduler` for datafile polling if set to `True`.
108
+
109
+
**blocking_timeout**
110
+
Maximum time in seconds to block the `get_config` call until config has been initialized.
111
+
112
+
You may also provide your own logger, error handler, or notification center.
113
+
114
+
115
+
#### Advanced configuration
116
+
The following properties can be set to override the default configurations for `HTTPConfigManager`.
| datafile | nil | Initial datafile, typically sourced from a local cached source
125
+
| auto_update | true | Boolean flag to specify if callback needs to execute infinitely or only once
126
+
| start_by_default | true | Boolean flag to specify if datafile polling should start right away as soon as `HTTPConfigManager` initializes
127
+
| blocking_timeout | 15 seconds | Maximum time in seconds to block the `get_config` call until config has been initialized
128
+
129
+
A notification signal will be triggered whenever a _new_ datafile is fetched and Project Config is updated. To subscribe to these notifications, use the `notification_center.add_notification_listener(Optimizely::NotificationCenter::NOTIFICATION_TYPES[:OPTIMIZELY_CONFIG_UPDATE], @callback)`
130
+
26
131
See the Optimizely Full Stack [developer documentation](http://developers.optimizely.com/server/reference/index.html) to learn how to set up your first Full Stack project and use the SDK.
0 commit comments